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

Sass Me Up, Scotty

Sass Me Up, Scotty

This tutorial was delivered at Pycon Canada on August 11th, 2013.

Ricardo Vazquez

August 11, 2013
Tweet

More Decks by Ricardo Vazquez

Other Decks in Design

Transcript

  1. S e p a r a t e your CSS,

    or I’m coming after you.
  2. No.

  3. Sass is an extension of CSS3 which adds nested rules,

    variables, mixins, selector inheritance, and more. Sass generates well formatted CSS and makes your stylesheets easier to organize and maintain.
  4. A computer program that modifies data to conform with the

    input requirements of another program.
  5. .photo-details display: none &.active display: block h4 color: $blue font-size:

    14px font-family: $helvetica font-weight: bold text-transform: uppercase .select width: 236px
  6. %sidebar-box margin: 0 0 10px 0 background: $bg padding: 10px

    .sidebar-auth-box @extend %sidebar-box input[type=text] padding: 10px border: 1px solid #ccc
  7. v A function is very similar to a mixin, however

    the output from a function is a single value.
  8. target / context = result 650px / 1000px = 65%

    @function calc-p($target, $container) @return ($target / $container) * 100%
  9. target / context = result 650px / 1000px = 65%

    @function calc-p($target, $container) @return ($target / $container) * 100% .my-module width: calc-p(650px, 1000px)
  10. $base: #2c3e50 darken($base, 8%) lighten($base, 8%) saturate(%base, 20%) desaturate(%base, 20%)

    adjust-hue($base, 20%) rgba($base, .5) tint($base, 10%) shade($base, 10%)
  11. The @if directive takes a condition to evaluate and returns

    the nested styles if the condition is truthy (not false or null). Specifying what to return if the condition is falsey can be done using the @else statement.
  12. The @each directive takes the form @each $var in <list>

    $var can be any variable name, and <list> is a SassScript expression that returns a list
  13. Still, we shouldn’t be spending our time writing mixins and

    extending all over the place. There’s gotta be something better.
  14. Our vision is optimized to see structure Know your user

    State visualization Focus Help User testing Aesthetics