sass-planifolia

Vanilla Sass helper functions
git clone https://git.ce9e.org/sass-planifolia.git

commit
5b78936b11f69ce413f6fbbaaa0f1b1bd8e29a28
parent
4629e970035d322c598ee46721b6d5980811b555
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2017-07-21 15:53
contrast: separate threshold parsing

Diffstat

M sass/contrast.scss 21 +++++++++++++--------

1 files changed, 13 insertions, 8 deletions


diff --git a/sass/contrast.scss b/sass/contrast.scss

@@ -10,6 +10,18 @@ $planifolia-contrast-dark-default: black !default;
   10    10 /// @type color
   11    11 $planifolia-contrast-light-default: white !default;
   12    12 
   -1    13 @function _pf-threshold($threshold) {
   -1    14   @if ($threshold == 'AA' or $threshold == 'AAALG') {
   -1    15     @return 4.5;
   -1    16   } @elseif ($threshold == 'AALG') {
   -1    17     @return 3;
   -1    18   } @elseif ($threshold == 'AAA') {
   -1    19     @return 7;
   -1    20   } @else {
   -1    21     @return $threshold;
   -1    22   }
   -1    23 }
   -1    24 
   13    25 @function _pf-srgb($channel) {
   14    26   $x: $channel / 255;
   15    27   @if $x <= .03928 {
@@ -135,14 +147,7 @@ $planifolia-contrast-light-default: white !default;
  135   147 /// @param {number} $threshold [4.5]
  136   148 ///    (can also be 'AA', 'AALG', 'AAA', or 'AAALG')
  137   149 @function contrast-check($color1, $color2, $threshold: 4.5) {
  138    -1   @if ($threshold == 'AA' or $threshold == 'AAALG') {
  139    -1     $threshold: 4.5;
  140    -1   } @elseif ($threshold == 'AALG') {
  141    -1     $threshold: 3;
  142    -1   } @elseif ($threshold == 'AAA') {
  143    -1     $threshold: 7;
  144    -1   }
  145    -1 
   -1   150   $threshold: _pf-threshold($threshold);
  146   151   $contrast: contrast($color1, $color2);
  147   152   @if $contrast < $threshold {
  148   153     @warn 'contrast #{$contrast} between #{$color1} and #{$color2} too low!';