back

by statenjason·16y ago·view on hn ↗
Interesting. Made me think to write a simple mixin for sass.

    @mixin fg-contrast($bg) {
      background: $bg;
      $textcolor: #ffffff;
      @if lightness($bg) > 50% {
        $textcolor: #000000;
      }
      color: $textcolor;
    }
Could also be done by using the red(), green(), and blue() functions, but lightness was simpler.
1 comments
Bingo! Such logic is supposed to live in the stylesheets with the design.