Upgrade to Pro — share decks privately, control downloads, hide ads and more …

0 to 80 in 40 Minutes

Roy Tomeij
November 12, 2015

0 to 80 in 40 Minutes

Sass' built-in functions are incredibly powerful, while massively underused. This talk will address all 80 Sass functions, quickly explaining how they work and what to use them for (and yes, some will only get 5 seconds of fame). Presented at SassConf 2015.

Roy Tomeij

November 12, 2015
Tweet

More Decks by Roy Tomeij

Other Decks in Programming

Transcript

  1. // rgba($red, $green, $blue, $alpha) rgba(204, 102, 153, 1) =>

    #cc6699 // rgba($color, $alpha) rgba(#cc6699, 0.5) => rgba(204, 102, 153, 0.5)
  2. // hsla($h, $s, $l, $alpha) hsla(330, 50, 60, 1) =>

    #cc6699 hsla(330, 50, 60, 0.5) => rgba(204, 102, 153, 0.5)
  3. $number-of-colors: 18; $degrees: 360 / $number-of-colors; @for $i from 0

    to $number-of-colors { background: adjust-hue( red, $i * $degrees ); }
  4. invert(#cc6699) => #339966 $r = red(#cc6699) $g = green(#cc6699) $b

    = blue(#cc6699) rgb(255 - $r, 255 - $g, 255 - $b)
  5. scale-color( hsl(330deg, 50%, 60%), $lightness: 50% ) => hsl(330deg, 50%,

    80%) scale-color( hsl(330deg, 50%, 60%), $lightness: -50% ) => hsl(330deg, 50%, 30%)
  6. $light1: lightness($color1); // 50% $light2: lightness($color2); // 100% $diff: $light1

    - $light2; // -50% $diff: abs($light1 - $light2); // 50%
  7. // set-nth($list, $n, $value) set-nth(a b c d, 2, X)

    => a X c d set-nth(a b c d, -1, X) => a b c X
  8. $list: 320px, 480px $newlist: join($list, 768px 1024px) => 320px, 480px,

    768px, 1024px // $list: join($list, 768px 1024px)
  9. $map: (phone: 320px, tablet: 768px); $map: map-merge( $map, (phone: 460px,

    ereader: 600px) ) => ( phone: 460px, tablet: 768px, ereader: 600px )
  10. call(lighten, #cc6699, 17%) // == lighten(#cc6699, 17%) => #e2a7c4 call(darken,

    #cc6699, 17%) // == darken(#cc6699, 17%) => #a4376e