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

CSS Workflow for Grown-ups

CSS Workflow for Grown-ups

Spesso chi lavora in ambito front-end tende a sottovalutare l'importanza di un workflow di lavoro strutturato che copra la fase di progettazione, realizzazione e pacchettizzazione di un design CSS. Questo perché spesso passare qualche ora senza far codice sembra essere una perdita di tempo.

In questo talk esporrò un workflow, per certi versi opinionato, che spazia dalle tecniche di normalizzazione delle grafica e progettazione OOCSS fino alla scelta degli strumenti da adottare in fase di sviluppo e build (preprocessori, linters ecc); il tutto per garantire affidabilità e manutenibilità del codice senza perdere la salute e litigare con il grafico.

Marco Solazzi

March 27, 2015
Tweet

More Decks by Marco Solazzi

Other Decks in Programming

Transcript

  1. Disclaimer • This is kinda opinionated stuff • Something heard,

    something for grantend • Might (not) work on every project • Won’t save you from bad design(ers)
  2. Frontend’s 4 Noble Truths 1. PSD 2 HTML is painful

    2. From pixel pushing comes pain 3. Emancipate from PSD thinking 4. Embrace the path of frontend’s impermanence and decide in browser
  3. The path to painless CSS 1. Modular planning 2. Limit

    complexity 3. Codebase predictability
  4. /* ========================================================================== Media Object ==== ``` <div class="media"> <img src=//placehold.it/150x150

    alt="" class="media__image"> <div class="media__wrap"> <h1 class="media__title">Media Title</h1> <p class="media__body"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </p> </div> </div> ``` ========================================================================== */
  5. “He’s able to reproduce every bit of the PSD design.

    He is a great developer!” - random co-worker
  6. “He’s able to reproduce every bit of the PSD design.

    He is a great developer!” - random co-worker # F A I L
  7. Statistical mode $font-sizes: ( xl: 32px, l: 26px, m: 22px,

    s: 14px, xs: 11px ); @each $f-size, $f-px in $font-sizes { .u-type--#{$f-size} { font-size: $f-px; } }
  8. Rationalization #header { margin-bottom: 24px; } .media { margin-bottom: 22px;

    padding: 12px 16px 14px; } .panel { margin-bottom: 28px; }
  9. Rationalization #header { margin-bottom: 24px; } .media { margin-bottom: 24px;

    padding: 12px 16px 14px; } .panel { margin-bottom: 24px; }
  10. Rationalization $gutter-default: 24px; #header { margin-bottom: $gutter-default; } .media {

    margin-bottom: $gutter-default; padding: 12px 16px 14px; } .panel { margin-bottom: $gutter-default; }
  11. Rationalization $gutter-default: 24px; #header { margin-bottom: $gutter-default; } .media {

    margin-bottom: $gutter-default; padding: $gutter-default / 2; } .panel { margin-bottom: $gutter-default; }
  12. What about? %gutter { margin-bottom: $gutter-default; } .media { @extend

    %gutter; padding: $gutter-default / 2; } .panel { @extend %gutter; }
  13. %gutter { margin-bottom: $gutter-default; } .media { @extend %gutter; padding:

    $gutter-default / 2; } .panel { @extend %gutter; } What about? WORTH IT?
  14. -webkit-transition: -webkit-transform 1s; transition: transform 1s background: resolve(‘logo.png’); -webkit-transition: -webkit-transform

    1s; transition: transform 1s background: url(‘/assets/images/logo.png’); transition: transform 1s; background: resolve(‘logo.png’); background: url(‘/assets/images/logo.png’); -webkit-transition: -webkit-transform 1s; transition: transform 1s CSS post-processing
  15. -webkit-transition: -webkit-transform 1s; transition: transform 1s background: resolve(‘logo.png’); -webkit-transition: -webkit-transform

    1s; transition: transform 1s background: url(‘/assets/images/logo.png’); transition: transform 1s; background: resolve(‘logo.png’); background: url(‘/assets/images/logo.png’); -webkit-transition: -webkit-transform 1s; transition: transform 1s CSS post-processing LOOK MA! NO SASS!
  16. “The personal nature of coding style is a challenge in

    a team atmosphere.” - Nicholas C. Zakas
  17. “...the perceived and actual properties of the thing […] that

    determine just how the thing could be possibly be used. ” - Donald Norman