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

O que eu aprendi com Sass

O que eu aprendi com Sass

Lucas Mazza

April 11, 2014
Tweet

More Decks by Lucas Mazza

Other Decks in Programming

Transcript

  1. Sass (yeap) !main_color = #82fc08 ! #main :width 80% :color

    = !main_color :font :family sans-serif :size 1.3em ! p :color = !main_color - #404040 :font-size 0.8em
  2. .section-developers #petition-inner #main-content- wrapper .services-documentation-version .services- documentation-resources .services-documentation- resource .resource-method-bundle

    .resource- method .implementations .implementation- bundle .implementation .implementation-download { font-weight: bold; text-transform: uppercase; margin: .25em 0; } ಠ_ಠ
  3. The Inception Rule “don’t go more than four levels deep"

    http:/ /thesassway.com/beginner/the-inception-rule 20/11/2011
  4. .close-modal { background-image: url('/assets/sprites.png'); background-repeat: no-repeat; background-position: 0 -20px; //

    ... } ! .delete-post-button { background-image: url('/assets/sprites.png'); background-repeat: no-repeat; background-position: 0 -20px; // ... }
  5. %icons-sprite-cross { background-image: url('/assets/sprites.png'); background-repeat: no-repeat; background-position: 0 -20px; }

    ! .close-modal { @extend %icons-sprite-cross; // ... } ! .delete-post-button { @extend %icons-sprite-cross; // ... }
  6. // application.scss .thingy { @include size(30px 70px); } ! !

    ! ! // application.css .thingy { width: 30px; height: 70px; } vs
  7. @mixin triangle ($size, $color, $direction) { height: 0; width: 0;

    ! $width: nth($size, 1); $height: nth($size, length($size)); ! $foreground-color: nth($color, 1); $background-color: if(length($color) == 2, nth($color, 2), transparent); ! @if ($direction == up) or ($direction == down) or ($direction == right) or ($direction == left) { ! $width: $width / 2; $height: if(length($size) > 1, $height, $height/2); ! @if $direction == up { border-left: $width solid $background-color; border-right: $width solid $background-color; border-bottom: $height solid $foreground-color; ! } @else if $direction == right { border-top: $width solid $background-color; border-bottom: $width solid $background-color; border-left: $height solid $foreground-color; ! } @else if $direction == down { border-left: $width solid $background-color; border-right: $width solid $background-color; border-top: $height solid $foreground-color; ! } @else if $direction == left { border-top: $width solid $background-color; border-bottom: $width solid $background-color; border-right: $height solid $foreground-color; } } ! @else if ($direction == up-right) or ($direction == up-left) { border-top: $height solid $foreground-color; ! @if $direction == up-right { border-left: $width solid $background-color; ! } @else if $direction == up-left { border-right: $width solid $background-color; } } ! @else if ($direction == down-right) or ($direction == down-left) { border-bottom: $height solid $foreground-color; ! @if $direction == down-right { border-left: $width solid $background-color; ! } @else if $direction == down-left { border-right: $width solid $background-color; } } ! @else if ($direction == inset-up) { border-width: $height $width; border-style: solid; border-color: $background-color $background-color $foreground-color; } ! @else if ($direction == inset-down) { border-width: $height $width; border-style: solid; border-color: $foreground-color $background-color $background-color; } ! @else if ($direction == inset-right) { border-width: $width $height; border-style: solid; border-color: $background-color $background-color $background-color $foreground-color; } ! @else if ($direction == inset-left) { border-width: $width $height; border-style: solid; border-color: $background-color $foreground-color $background-color $background-color; } } .thing { @include triangle(12px, gray, down); } ! ! ! ! .thing { height: 0; width: 0; border-color: transparent; border-style: solid; border-width: 6px; border-top-color: gray; }
  8. // ======================================================= // Profile card to display the players in

    the leaderboard. // // Supports an avatar wrapper, follower count and the // user name. Note that the 'avatar' and the ‘follower // count' are wrapped inside an 'a' tag so everything // will be clickable. Descrição
  9. // <div class='profile-card'> // <a href='#' class='profile-card-avatar'> // <img class='profile-card-avatar'

    width='120' height='120'> // <span class='profile-card-follower-count'>13220</span> // <p class='profile-card-star'>@HackerNewsOnion</p> // </a> // <a href='#' class='profile-card-name'>Hacker News Onion</a> // </div> // ============================================================== Exemplos
  10. Modificadores // ============================================================= // A full fledged replacement for '<select>'

    using a list of // unordered items. // // Modifiers: // // :hover - Subtle hover highlight. // .expanded - Expanded state, displaying the choices list. // .right-aligned - Aligns the 'toggle' icon to the right. // ============================================================= ! // Expanded state for the 'combo-selector'. // ============================================================== .combo-selector.expanded { ! }
  11. Kent Beck @ Smalltalk Best Practice Patterns “Code doesn't lie.

    If you're not listening, you won't hear the truths it tells.”