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

Sass nos dias de hoje

Sass nos dias de hoje

Sass é um pre-processador CSS, onde a forma de como vemos o CSS é alterado por meio de variáveis, funções e mixins. A proposta da palestra será apresentar a linguagem de forma objetiva, mostrando boas práticas com a linguagem e focando no melhor resultado final ou seja o output em CSS. Hoje como front-end na Codeminer42 já trabalhei em diversos projetos e todos estes projetos com Sass, não vejo o trabalho hoje sem o workflow do Sass.

Vinícius Palma

April 11, 2015
Tweet

More Decks by Vinícius Palma

Other Decks in Programming

Transcript

  1. css

  2. separação entre o Estilo e o conteúdo .class { display:

    inline-block; width: 100px; height: 100px; border: solid 1px green; background: red; }
  3. FEATURES Variables nav { ul { margin: 0; padding: 0;

    list-style: none; } li {display: inline-block; } a { display: block; padding: 6px 12px; text-decoration: none; } } nesting
  4. FEATURES Variables @mixin border-radius($radius) { -webkit-border-radius: $radius; -moz-border-radius: $radius; -ms-border-radius:

    $radius; border-radius: $radius; } .box { @include border-radius(10px); } nesting mixins
  5. FEATURES Variables .container { width: 100%; } article[role="main"] { float:

    left; width: 600px / 960px * 100%; } aside[role="complimentary"] { float: right; width: 300px / 960px * 100%; } nesting mixins operators
  6. FEATURES Variables @for $i from 1 through 3 { .item-#{$i}

    { width: 2em * $i; } } nesting mixins operators loop .item-1 { width: 2em; } .item-2 { width: 4em; } .item-3 { width: 6em; }
  7. FEATURES Variables @each $animal in puma, sea-slug, egret { .#{$animal}-icon

    { background-image: url('/img/#{$animal}.png'); } } nesting mixins operators loop .puma-icon { background-image: url('/img/puma.png'); } .sea-slug-icon { background-image: url('/img/sea-slug.png'); } .egret-icon { background-image: url('/img/egret.png'); }
  8. FEATURES Variables $i: 6; @while $i > 0 { .item-#{$i}

    { width: 2em * $i; } $i: $i - 2; } nesting mixins operators loop .item-6 { width: 12em; } .item-4 { width: 8em; } .item-2 { width: 4em; }
  9. FEATURES Variables p { @if 1 + 1 == 2

    { border: 1px solid; } @if 5 < 3 { border: 2px dotted; } @if null { border: 3px double; } } nesting mixins operators loop p { border: border: 1px solid; } conditionals
  10. task runners module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), sass:

    { dist: { files: { 'style/style.css' : 'sass/style.scss' } } }, watch: { css: { files: '**/*.scss', tasks: ['sass'] } } }); grunt.loadNpmTasks('grunt-contrib-sass'); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.registerTask('default',['watch']); }
  11. task runners var gulp = require('gulp'); var sass = require('gulp-sass');

    gulp.task('sass', function (){ gulp.src('./assets/sass') .pipe(sass({ outputStyle: 'compressed', sourceComments: 'map', includePaths : './assets/sass' })) .on('error', function(err){ displayError(err); }) .pipe(gulp.dest('./public/css')) }); gulp.task('default', ['sass'], function() { gulp.watch('./assets/sass', ['sass']); });
  12. Ruby on rails @import 'compass', 'normalize-css', 'base/colors', 'base/typography', 'helpers/mixins', 'helpers/placeholders',

    'helpers/utils', 'structure/footer', 'structure/header_footer_internal', 'structure/wrapper', 'base/global_landing', 'structure/global', 'components/buttons', 'components/adaptativa_card', 'components/progress_bar', 'modules/learning_unit/video', 'modules/learning_unit/questions', 'modules/learning_unit/performance', 'modules/dashboard/study_plan', 'modules/disciplines/search', 'modules/disciplines/lessons'
  13. Ruby on rails <!DOCTYPE html> <html> <head> <title> MC champions

    </title> … <%= stylesheet_link_tag 'application', media: 'all' %> <%= csrf_meta_tags %> … </head> <body>
  14. .progress-bar { height: 100px; background: $light-gray; border-bottom: solid 1px darken($light-gray,

    10%); &__title { float: left; font-size: 23px; line-height: 100px; color: $blue-font; } &__info { float: right; &__percentage { font-size: 12px; strong { font-size: 22px; } } &__bar { width: 170px; height: 25px; border-radius: 4px; background: darken($light-gray, 10%); &__progress { display: inline-block; height: 25px; background: $blue-font; border-radius: 4px; } } } }
  15. então <div class="progress-bar"> <div class="progress-bar__info"> <p class=“progress-bar__info__percentage"> <strong><%= discipline.user_progress(current_user) %>%</strong>

    das aulas estudadas </p> <div class="progress-bar__info__bar"> <div class="progress-bar__info__bar__progress" style="width: <%= discipline.user_progress(current_user) %>%”> </div> </div> </div> </div>