Search.
[wolnelektury.git] / src / wolnelektury / static / 2022 / styles / utils / bourbon / utilities / _contrast-ratio.scss
1 @charset "UTF-8";
2
3 /// Programatically determines the contrast ratio between two colors.
4 ///
5 /// Note that the alpha channel is ignored.
6 ///
7 /// @link https://goo.gl/54htLV
8 ///
9 /// @argument {color (hex)} $color-1
10 ///
11 /// @argument {color (hex)} $color-2
12 ///
13 /// @return {number (1-21)}
14 ///
15 /// @example scss
16 ///   _contrast-ratio(black, white)
17 ///
18 /// @require {function} _lightness
19 ///
20 /// @access private
21
22 @function _contrast-ratio($color-1, $color-2) {
23   $-local-lightness-1: _lightness($color-1) + 0.05;
24   $-local-lightness-2: _lightness($color-2) + 0.05;
25
26   @if $-local-lightness-1 > $-local-lightness-2 {
27     @return $-local-lightness-1 / $-local-lightness-2;
28   } @else {
29     @return $-local-lightness-2 / $-local-lightness-1;
30   }
31 }