SlideShare ist ein Scribd-Unternehmen logo
1 von 32
CSS Pre-Processing
Itai Koren, March 2013


DISCLOSURE:
• I've worked with LESS for two years and switched to SASS.
• I've worked with SASS for 2-3 month.
• Those slides are based entirely on a presentation I gave about a year ago
  explaining why I chose SASS over LESS
SASS is more than LESS
Itai Koren, February 2012


DISCLOSURE:
• I've worked with LESS for two years and switched to SASS.
• I've worked with SASS for 2-3 month.
• Those slides are based entirely on a presentation I gave about a year ago
  explaining why I chose SASS over LESS
CSS Pre-Processing
Itai Koren, March 2013


DISCLOSURE:
• I've worked with LESS for two years and switched to SASS.
• I've worked with SASS for 2-3 month.
• Those slides are based entirely on a presentation I gave about a year ago
  explaining why I chose SASS over LESS
Agenda


 • What are CSS preprocessors?
 • Why Use a CSS Preprocessor?
 • What is the Catch (or Possible Issues)?
 • How Do CSS Preprocessors Work and
   what can it do for us (basic examples)?
 • SASS or LESS?
 • Should We Try It?
What are CSS preprocessors?


• Converts code written in the preprocessed
  language into the same old CSS
• Not bound by the limitations of CSS because
  they aren’t CSS
• The preprocessed language gives much more
  functionality than CSS
• Popular CSS preprocessors are
  SASS, LESS, and Stylus (Here I’ll only refers to the first
  two which are the most popular)
Why Use a CSS Preprocessor?


• Not bound by the limitations of CSS because
  they aren’t CSS (sounds familiar?)
• Developers looks for more abstraction
• We like variables, conditions and methods
• It allows us to write more flexible and
  maintainable CSS
• Will make our CSS DRY (Don't Repeat Yourself)
  as opposed to WET (Write Everything Twice)
What’s the Catch (or Possible
             Issues)?
• All developers in the project must use the same
  preprocessor
• The preprocessed outputted files should not be
  edited directly
• Development process should include a simple
  preprocessing ability
• WARNINNG! Developers who started working
  with CSS preprocessor will never agree to go
  back
This is it, and therefore, many of the medium/large scale projects
today use a CSS Preprocessor – Should we?
But we must remember
though that …
How Do CSS Preprocessors Work?


 • Developers use the preprocessor language to
   create their structured CSS
 • The preprocessor processes the created files
   and outputs a CSS
 • The produced CSS works as ordinary CSS


  Stop bullshit and show us some code
What can it do for us (basic examples)?

                             Variables - changing the value of a variable once is
                             much more maintainable than changing the many
                             instances of it’s value spread over a CSS file

 /* -- .scss -- */
 $color: #efefff;
 body {background: $color;}

 /* -- .less -- */
 @color: #efefef;
 body {background: @color;}


 /* -- resulting css -- */
 body {background: #efefff;}
What can it do for us (basic examples)?

                              Interpolation - extends variables in that you aren’t
                              limited to the values of CSS properties

  /* -- .scss -- */
  $side: left;
  border-#{$side}: 1px solid #000;

  /* -- resulting css -- */
  border-left: 1px solid #000;

  /* -- .less -- */
  @images-url: "http://example.com";
  background-image: url("@{images-url}/images/bg.png");

  /* -- resulting css -- */
  background-image: url("http://myexample.com/images/bg.png");
What can it do for us (basic examples)?

                             Math – Operations, animations, moving towards
                             responsive design and more

 /* -- .scss -- */
 $navbar-width: 700px;
 $items: 7;
 #navbar li {width: $navbar-width/$items - 10px;}

 /* -- resulting css -- */
 #navbar li {width: 90px}

 /* -- .less -- */
 @base-color: #111;
 #header {color: @base-color * 5;}

 /* -- resulting css -- */
 #header {color: #555;}
What can it do for us (basic examples)?


                               Mixins - allows easy reuse of blocks of code

 /* -- .scss -- */
 @mixin rounded-corners {
  $radius: 5px;

     border-radius: $radius;
     -webkit-border-radius: $radius;
     -moz-border-radius: $radius;
 }

 #navbar li { @include rounded-corners; }
 #footer { @include rounded-corners; }
What can it do for us (basic examples)?


                              Mixins - allows easy reuse of blocks of code
                              (Continue)
 /* -- .less -- */
 .rounded-corners {
   @radius: 5px;

     border-radius: @radius;
     -webkit-border-radius: @radius;
     -moz-border-radius: @radius;
 }

 #header {.rounded-corners;}
 #footer { .rounded-corners;}
What can it do for us (basic examples)?


                             Mixins - allows easy reuse of blocks of code
                             (Continue)
 /* -- resulting css -- */
 #header {
   border-radius: 5px;
   -webkit-border-radius: 5px;
   -moz-border-radius: 5px;
 }

 #footer {
   border-radius: 5px;
   -webkit-border-radius: 5px;
   -moz-border-radius: 5px;
 }
What can it do for us (basic examples)?


                                   Nesting - Allow nested formatting

 /* -- .scss or .less -- */
 #navbar {
  width: 70%;
  height: 30px;

     ul { list-style: none; }

     li {
       float: right;
       a { text-decoration: none; }
       &:hover { text-decoration: underline; }
     }
 }

 /* -- resulting css -- */
 #navbar     {width: 70%; height: 30px;}
 #navbar     ul {list-style: none;}
 #navbar     li {float: right;}
 #navbar     li a {text-decoration: none;}
 #navbar     li a:hover {text-decoration: underline;}
SASS or LESS?

                   Here are some facts first:
• LESS has a client side JavaScript
  implementation, which should never be used for
  production (Example)
• SASS (Syntactically Awesome Stylesheets) is a
  rubygem (package) - Since 2006 (influenced by
  YAML)
• LESS (Leaner CSS) was a rubygem but
  converted to JavaScript (nodejs). Has also a
  PHP implementation (LessPHP) - since 2009
  (influenced by SASS)
SASS or LESS?



• We already know that preprocessing is probably
  good for us :)
• It also can define a good working process with
  UI people

So now, Which CSS Preprocessor Is better?

                                  Lets see..
SASS or LESS?
                                   LESS is easier to learn BUT....

                                   SASS has conditional statements (LESS doesn't)

/* -- .scss -- */
@mixin my-mixin($parameters) {
    /* Basic stuff here */
    @if $direction == top {
        /* Conditional stuff here */
    }
}
SASS or LESS?


                                 SASS has loop statements (LESS doesn't)

/* -- .scss -- */
@for $i from 1 through 10 {
    /* My stuff here */
    .my-element:nth-child($i) { animation-name: loading-$i; }
}
SASS or LESS?
                                      SASS extends more efficient than LESS
/* -- .less -- */
.module-less_b {
  .module-less_a(); /* Copies everything from .module-a down here */
}

.module-sass_b {
  /* Some unique styling */
  @extend .module-a;
}

/* -- resulting css -- */
.module-less_a {
  /* A bunch of stuff */
}
.module-less_b {
  /* Same bunch of stuff */
  /* + Some unique styling */
}

.module-sass_a, .module-sass_b {
  /* A bunch of stuff */
}
.module-sass_b {
  /* Some unique styling */
}
SASS or LESS?

                             BUT the winning argument is that SASS has
                             COMPASS, LESS doesn’t


Compass is a collection of helpful tools and "battle-tested best practices” for
SASS

SASS is much more robust than LESS and this what makes Compass
possible (LESS does not have a similar solution)
SASS or LESS?
                                  COMPASS has a mixin called background. It's so robust, you
                                  can pass whatever you want and it will output what you need
/* -- .scss -- */
.babam {
  @include background(
    image-url("foo.png"),
    linear-gradient(top left, #333, #0c0),
    radial-gradient(#c00, #fff 100px)
  );
}

/* -- resulting css -- */
.babam {
  background: url('/foo.png'), -webkit-gradient(linear, 0% 0%, 100% 100%, color-stop(0%, #333333), color-
stop(100%, #00cc00)), -webkit-gradient(radial, 50% 50%, 0, 50% 50%, 100, color-stop(0%, #cc0000), color-
stop(100%, #ffffff));
  background: url('/foo.png'), -webkit-linear-gradient(top left, #333333, #00cc00), -webkit-radial-
gradient(#cc0000, #ffffff 100px);
  background: url('/foo.png'), -moz-linear-gradient(top left, #333333, #00cc00), -moz-radial-
gradient(#cc0000, #ffffff 100px);
  background: url('/foo.png'), -o-linear-gradient(top left, #333333, #00cc00), -o-radial-gradient(#cc0000, #ffffff
100px);
  background: url('/foo.png'), -ms-linear-gradient(top left, #333333, #00cc00), -ms-radial-
gradient(#cc0000, #ffffff 100px);
  background: url('/foo.png'), linear-gradient(top left, #333333, #00cc00), radial-gradient(#cc0000, #ffffff
100px);
}
SASS or LESS?

                                     One weird thing in SASS, is the way variable scope
                                     is treated
$color: black;
.scoped {
  $color: white;
  color: $color;
}
.unscoped {
  // LESS = black (global)
  // SASS = white (overwritten by local)
  color: $color;
}




                             Not so intuitive but acceptable
Stats (always nice to look at)
                           2012/02/03         2013/03/09
Number of open issues on                392                98
LESS
Number of open issues on                104                 68
SASS                                    272                178
Pending pull requests on                86                  6
LESS
Pending pull requests on                32                  2
SASS                                    69                 22
Number of commits in the                11                 95
last two months in LESS
Number of commits in the                48                 20
last two months in SASS                 31                 10
Number of members in                                  > 1000
LESS network
Number of members in                                   < 500
SASS network                                           < 500
Should We Try It?
Should We Try It?

                    So….
• We should use both, SASS & COMPASS
• We should have a solution for development
  phase (file monitoring - IDEA Plugin? External?
  Scout? There is even a firebug extension for
  FF)
• We should have a solution for the build phase
  (probably using GRUNT to run the SASS
  preprocessor)
Further Resources



• http://coding.smashingmagazine.com/2011/09/09/an-
  introduction-to-less-and-comparison-to-sass/
• http://net.tutsplus.com/tutorials/html-css-techniques/sass-vs-
  less-vs-stylus-a-preprocessor-shootout/
• http://thesassway.com/
• http://thesassway.com/beginner/getting-started-with-sass-and-
  compass
• http://thesassway.com/advanced/pure-sass-functions
• http://sass-lang.com/
• http://www.manning.com/netherland/SaCiA_meap_ch01.pdf
Thank You

Weitere ähnliche Inhalte

Was ist angesagt?

Bringing sexy back to CSS: SASS/SCSS, LESS and Compass
Bringing sexy back to CSS: SASS/SCSS, LESS and CompassBringing sexy back to CSS: SASS/SCSS, LESS and Compass
Bringing sexy back to CSS: SASS/SCSS, LESS and CompassClaudina Sarahe
 
Syntactically awesome stylesheets (Sass)
Syntactically awesome stylesheets (Sass)Syntactically awesome stylesheets (Sass)
Syntactically awesome stylesheets (Sass)Tahmina Khatoon
 
Authoring Stylesheets with Compass & Sass
Authoring Stylesheets with Compass & SassAuthoring Stylesheets with Compass & Sass
Authoring Stylesheets with Compass & Sasschriseppstein
 
Compass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS DeveloperCompass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS DeveloperWynn Netherland
 
Introduction to SASS
Introduction to SASSIntroduction to SASS
Introduction to SASSJon Dean
 
Deep dive into sass
Deep dive into sassDeep dive into sass
Deep dive into sassKnoldus Inc.
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With LessDavid Engel
 
Organizing & Simplifying CSS [with Sass]
Organizing & Simplifying CSS [with Sass]Organizing & Simplifying CSS [with Sass]
Organizing & Simplifying CSS [with Sass]Matt Puchlerz
 
Simplifying CSS With Sass
Simplifying CSS With SassSimplifying CSS With Sass
Simplifying CSS With SassThomas Reynolds
 
Advanced sass/compass
Advanced sass/compassAdvanced sass/compass
Advanced sass/compassNick Cooley
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction SassZeeshan Ahmed
 
Wrangling the CSS Beast with Sass
Wrangling the CSS Beast  with SassWrangling the CSS Beast  with Sass
Wrangling the CSS Beast with SassRob Friesel
 

Was ist angesagt? (20)

LESS
LESSLESS
LESS
 
Less vs sass
Less vs sassLess vs sass
Less vs sass
 
Bringing sexy back to CSS: SASS/SCSS, LESS and Compass
Bringing sexy back to CSS: SASS/SCSS, LESS and CompassBringing sexy back to CSS: SASS/SCSS, LESS and Compass
Bringing sexy back to CSS: SASS/SCSS, LESS and Compass
 
Theming and Sass
Theming and SassTheming and Sass
Theming and Sass
 
Syntactically awesome stylesheets (Sass)
Syntactically awesome stylesheets (Sass)Syntactically awesome stylesheets (Sass)
Syntactically awesome stylesheets (Sass)
 
Authoring Stylesheets with Compass & Sass
Authoring Stylesheets with Compass & SassAuthoring Stylesheets with Compass & Sass
Authoring Stylesheets with Compass & Sass
 
Compass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS DeveloperCompass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS Developer
 
Introduction to SASS
Introduction to SASSIntroduction to SASS
Introduction to SASS
 
Sass
SassSass
Sass
 
Sass, Compass
Sass, CompassSass, Compass
Sass, Compass
 
Deep dive into sass
Deep dive into sassDeep dive into sass
Deep dive into sass
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With Less
 
Introduction to sass
Introduction to sassIntroduction to sass
Introduction to sass
 
Organizing & Simplifying CSS [with Sass]
Organizing & Simplifying CSS [with Sass]Organizing & Simplifying CSS [with Sass]
Organizing & Simplifying CSS [with Sass]
 
Simplifying CSS With Sass
Simplifying CSS With SassSimplifying CSS With Sass
Simplifying CSS With Sass
 
Css to-scss
Css to-scssCss to-scss
Css to-scss
 
Advanced sass/compass
Advanced sass/compassAdvanced sass/compass
Advanced sass/compass
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction Sass
 
Accelerated Stylesheets
Accelerated StylesheetsAccelerated Stylesheets
Accelerated Stylesheets
 
Wrangling the CSS Beast with Sass
Wrangling the CSS Beast  with SassWrangling the CSS Beast  with Sass
Wrangling the CSS Beast with Sass
 

Andere mochten auch

Pre-processing for Fronteers by Viking Kristof Houben
Pre-processing for Fronteers by Viking Kristof HoubenPre-processing for Fronteers by Viking Kristof Houben
Pre-processing for Fronteers by Viking Kristof HoubenMobile Vikings
 
We got to france!
We got to france! We got to france!
We got to france! bekyteckno
 
Palestra pré processadores CSS
Palestra pré processadores CSSPalestra pré processadores CSS
Palestra pré processadores CSSJust Digital
 
Modeljeans
ModeljeansModeljeans
Modeljeansyolimary
 
Why are preprocessors divisive
Why are preprocessors divisiveWhy are preprocessors divisive
Why are preprocessors divisiveKianosh Pourian
 

Andere mochten auch (7)

Pre-processing for Fronteers by Viking Kristof Houben
Pre-processing for Fronteers by Viking Kristof HoubenPre-processing for Fronteers by Viking Kristof Houben
Pre-processing for Fronteers by Viking Kristof Houben
 
We got to france!
We got to france! We got to france!
We got to france!
 
Palestra pré processadores CSS
Palestra pré processadores CSSPalestra pré processadores CSS
Palestra pré processadores CSS
 
It seminar 1.0
It seminar 1.0It seminar 1.0
It seminar 1.0
 
Social job search
Social job searchSocial job search
Social job search
 
Modeljeans
ModeljeansModeljeans
Modeljeans
 
Why are preprocessors divisive
Why are preprocessors divisiveWhy are preprocessors divisive
Why are preprocessors divisive
 

Ähnlich wie SASS is more than LESS

CSS előfeldolgozók
CSS előfeldolgozókCSS előfeldolgozók
CSS előfeldolgozókMáté Farkas
 
LESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageLESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageKatsunori Tanaka
 
The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}
The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}
The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}Eric Carlisle
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockMarco Pinheiro
 
Dallas Drupal Days 2012 - Introduction to less sass-compass
Dallas Drupal Days 2012  - Introduction to less sass-compassDallas Drupal Days 2012  - Introduction to less sass-compass
Dallas Drupal Days 2012 - Introduction to less sass-compassChris Lee
 
Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)emrox
 
Create SASSy web parts in SPFx
Create SASSy web parts in SPFxCreate SASSy web parts in SPFx
Create SASSy web parts in SPFxStefan Bauer
 
CSS Less framework overview, Pros and Cons
CSS Less framework overview, Pros and ConsCSS Less framework overview, Pros and Cons
CSS Less framework overview, Pros and ConsSanjoy Kr. Paul
 
CSS Workflow. Pre & Post
CSS Workflow. Pre & PostCSS Workflow. Pre & Post
CSS Workflow. Pre & PostAnton Dosov
 
From CSS to Sass in WordPress
From CSS to Sass in WordPressFrom CSS to Sass in WordPress
From CSS to Sass in WordPressJames Steinbach
 
Less(CSS Pre Processor) Introduction
Less(CSS Pre Processor) IntroductionLess(CSS Pre Processor) Introduction
Less(CSS Pre Processor) Introductionrushi7567
 
LESS(CSS Pre Processor) introduction
LESS(CSS Pre Processor) introductionLESS(CSS Pre Processor) introduction
LESS(CSS Pre Processor) introductionrushi7567
 
Getting Started with Sass & Compass
Getting Started with Sass & CompassGetting Started with Sass & Compass
Getting Started with Sass & CompassRob Davarnia
 
SCSS Implementation
SCSS ImplementationSCSS Implementation
SCSS ImplementationAmey Parab
 
Stop your share point css become a di-sass-ter today - SPS Munich
Stop your share point css become a di-sass-ter today - SPS MunichStop your share point css become a di-sass-ter today - SPS Munich
Stop your share point css become a di-sass-ter today - SPS MunichStefan Bauer
 

Ähnlich wie SASS is more than LESS (20)

CSS előfeldolgozók
CSS előfeldolgozókCSS előfeldolgozók
CSS előfeldolgozók
 
LESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageLESS : The dynamic stylesheet language
LESS : The dynamic stylesheet language
 
The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}
The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}
The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, Greensock
 
UNIT 3.ppt
UNIT 3.pptUNIT 3.ppt
UNIT 3.ppt
 
CSS3
CSS3CSS3
CSS3
 
Dallas Drupal Days 2012 - Introduction to less sass-compass
Dallas Drupal Days 2012  - Introduction to less sass-compassDallas Drupal Days 2012  - Introduction to less sass-compass
Dallas Drupal Days 2012 - Introduction to less sass-compass
 
Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)
 
Create SASSy web parts in SPFx
Create SASSy web parts in SPFxCreate SASSy web parts in SPFx
Create SASSy web parts in SPFx
 
[Bauer] SASSy web parts with SPFX
[Bauer] SASSy web parts with SPFX[Bauer] SASSy web parts with SPFX
[Bauer] SASSy web parts with SPFX
 
CSS Less framework overview, Pros and Cons
CSS Less framework overview, Pros and ConsCSS Less framework overview, Pros and Cons
CSS Less framework overview, Pros and Cons
 
CSS Workflow. Pre & Post
CSS Workflow. Pre & PostCSS Workflow. Pre & Post
CSS Workflow. Pre & Post
 
From CSS to Sass in WordPress
From CSS to Sass in WordPressFrom CSS to Sass in WordPress
From CSS to Sass in WordPress
 
Less(CSS Pre Processor) Introduction
Less(CSS Pre Processor) IntroductionLess(CSS Pre Processor) Introduction
Less(CSS Pre Processor) Introduction
 
LESS(CSS Pre Processor) introduction
LESS(CSS Pre Processor) introductionLESS(CSS Pre Processor) introduction
LESS(CSS Pre Processor) introduction
 
Getting Started with Sass & Compass
Getting Started with Sass & CompassGetting Started with Sass & Compass
Getting Started with Sass & Compass
 
SCSS Implementation
SCSS ImplementationSCSS Implementation
SCSS Implementation
 
Advanced sass
Advanced sassAdvanced sass
Advanced sass
 
Why less?
Why less?Why less?
Why less?
 
Stop your share point css become a di-sass-ter today - SPS Munich
Stop your share point css become a di-sass-ter today - SPS MunichStop your share point css become a di-sass-ter today - SPS Munich
Stop your share point css become a di-sass-ter today - SPS Munich
 

Kürzlich hochgeladen

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 

Kürzlich hochgeladen (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

SASS is more than LESS

  • 1. CSS Pre-Processing Itai Koren, March 2013 DISCLOSURE: • I've worked with LESS for two years and switched to SASS. • I've worked with SASS for 2-3 month. • Those slides are based entirely on a presentation I gave about a year ago explaining why I chose SASS over LESS
  • 2. SASS is more than LESS Itai Koren, February 2012 DISCLOSURE: • I've worked with LESS for two years and switched to SASS. • I've worked with SASS for 2-3 month. • Those slides are based entirely on a presentation I gave about a year ago explaining why I chose SASS over LESS
  • 3. CSS Pre-Processing Itai Koren, March 2013 DISCLOSURE: • I've worked with LESS for two years and switched to SASS. • I've worked with SASS for 2-3 month. • Those slides are based entirely on a presentation I gave about a year ago explaining why I chose SASS over LESS
  • 4. Agenda • What are CSS preprocessors? • Why Use a CSS Preprocessor? • What is the Catch (or Possible Issues)? • How Do CSS Preprocessors Work and what can it do for us (basic examples)? • SASS or LESS? • Should We Try It?
  • 5. What are CSS preprocessors? • Converts code written in the preprocessed language into the same old CSS • Not bound by the limitations of CSS because they aren’t CSS • The preprocessed language gives much more functionality than CSS • Popular CSS preprocessors are SASS, LESS, and Stylus (Here I’ll only refers to the first two which are the most popular)
  • 6. Why Use a CSS Preprocessor? • Not bound by the limitations of CSS because they aren’t CSS (sounds familiar?) • Developers looks for more abstraction • We like variables, conditions and methods • It allows us to write more flexible and maintainable CSS • Will make our CSS DRY (Don't Repeat Yourself) as opposed to WET (Write Everything Twice)
  • 7.
  • 8. What’s the Catch (or Possible Issues)? • All developers in the project must use the same preprocessor • The preprocessed outputted files should not be edited directly • Development process should include a simple preprocessing ability • WARNINNG! Developers who started working with CSS preprocessor will never agree to go back This is it, and therefore, many of the medium/large scale projects today use a CSS Preprocessor – Should we?
  • 9.
  • 10. But we must remember though that …
  • 11. How Do CSS Preprocessors Work? • Developers use the preprocessor language to create their structured CSS • The preprocessor processes the created files and outputs a CSS • The produced CSS works as ordinary CSS Stop bullshit and show us some code
  • 12. What can it do for us (basic examples)? Variables - changing the value of a variable once is much more maintainable than changing the many instances of it’s value spread over a CSS file /* -- .scss -- */ $color: #efefff; body {background: $color;} /* -- .less -- */ @color: #efefef; body {background: @color;} /* -- resulting css -- */ body {background: #efefff;}
  • 13. What can it do for us (basic examples)? Interpolation - extends variables in that you aren’t limited to the values of CSS properties /* -- .scss -- */ $side: left; border-#{$side}: 1px solid #000; /* -- resulting css -- */ border-left: 1px solid #000; /* -- .less -- */ @images-url: "http://example.com"; background-image: url("@{images-url}/images/bg.png"); /* -- resulting css -- */ background-image: url("http://myexample.com/images/bg.png");
  • 14. What can it do for us (basic examples)? Math – Operations, animations, moving towards responsive design and more /* -- .scss -- */ $navbar-width: 700px; $items: 7; #navbar li {width: $navbar-width/$items - 10px;} /* -- resulting css -- */ #navbar li {width: 90px} /* -- .less -- */ @base-color: #111; #header {color: @base-color * 5;} /* -- resulting css -- */ #header {color: #555;}
  • 15. What can it do for us (basic examples)? Mixins - allows easy reuse of blocks of code /* -- .scss -- */ @mixin rounded-corners { $radius: 5px; border-radius: $radius; -webkit-border-radius: $radius; -moz-border-radius: $radius; } #navbar li { @include rounded-corners; } #footer { @include rounded-corners; }
  • 16. What can it do for us (basic examples)? Mixins - allows easy reuse of blocks of code (Continue) /* -- .less -- */ .rounded-corners { @radius: 5px; border-radius: @radius; -webkit-border-radius: @radius; -moz-border-radius: @radius; } #header {.rounded-corners;} #footer { .rounded-corners;}
  • 17. What can it do for us (basic examples)? Mixins - allows easy reuse of blocks of code (Continue) /* -- resulting css -- */ #header { border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; } #footer { border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; }
  • 18. What can it do for us (basic examples)? Nesting - Allow nested formatting /* -- .scss or .less -- */ #navbar { width: 70%; height: 30px; ul { list-style: none; } li { float: right; a { text-decoration: none; } &:hover { text-decoration: underline; } } } /* -- resulting css -- */ #navbar {width: 70%; height: 30px;} #navbar ul {list-style: none;} #navbar li {float: right;} #navbar li a {text-decoration: none;} #navbar li a:hover {text-decoration: underline;}
  • 19. SASS or LESS? Here are some facts first: • LESS has a client side JavaScript implementation, which should never be used for production (Example) • SASS (Syntactically Awesome Stylesheets) is a rubygem (package) - Since 2006 (influenced by YAML) • LESS (Leaner CSS) was a rubygem but converted to JavaScript (nodejs). Has also a PHP implementation (LessPHP) - since 2009 (influenced by SASS)
  • 20. SASS or LESS? • We already know that preprocessing is probably good for us :) • It also can define a good working process with UI people So now, Which CSS Preprocessor Is better? Lets see..
  • 21. SASS or LESS? LESS is easier to learn BUT.... SASS has conditional statements (LESS doesn't) /* -- .scss -- */ @mixin my-mixin($parameters) { /* Basic stuff here */ @if $direction == top { /* Conditional stuff here */ } }
  • 22. SASS or LESS? SASS has loop statements (LESS doesn't) /* -- .scss -- */ @for $i from 1 through 10 { /* My stuff here */ .my-element:nth-child($i) { animation-name: loading-$i; } }
  • 23. SASS or LESS? SASS extends more efficient than LESS /* -- .less -- */ .module-less_b { .module-less_a(); /* Copies everything from .module-a down here */ } .module-sass_b { /* Some unique styling */ @extend .module-a; } /* -- resulting css -- */ .module-less_a { /* A bunch of stuff */ } .module-less_b { /* Same bunch of stuff */ /* + Some unique styling */ } .module-sass_a, .module-sass_b { /* A bunch of stuff */ } .module-sass_b { /* Some unique styling */ }
  • 24. SASS or LESS? BUT the winning argument is that SASS has COMPASS, LESS doesn’t Compass is a collection of helpful tools and "battle-tested best practices” for SASS SASS is much more robust than LESS and this what makes Compass possible (LESS does not have a similar solution)
  • 25. SASS or LESS? COMPASS has a mixin called background. It's so robust, you can pass whatever you want and it will output what you need /* -- .scss -- */ .babam { @include background( image-url("foo.png"), linear-gradient(top left, #333, #0c0), radial-gradient(#c00, #fff 100px) ); } /* -- resulting css -- */ .babam { background: url('/foo.png'), -webkit-gradient(linear, 0% 0%, 100% 100%, color-stop(0%, #333333), color- stop(100%, #00cc00)), -webkit-gradient(radial, 50% 50%, 0, 50% 50%, 100, color-stop(0%, #cc0000), color- stop(100%, #ffffff)); background: url('/foo.png'), -webkit-linear-gradient(top left, #333333, #00cc00), -webkit-radial- gradient(#cc0000, #ffffff 100px); background: url('/foo.png'), -moz-linear-gradient(top left, #333333, #00cc00), -moz-radial- gradient(#cc0000, #ffffff 100px); background: url('/foo.png'), -o-linear-gradient(top left, #333333, #00cc00), -o-radial-gradient(#cc0000, #ffffff 100px); background: url('/foo.png'), -ms-linear-gradient(top left, #333333, #00cc00), -ms-radial- gradient(#cc0000, #ffffff 100px); background: url('/foo.png'), linear-gradient(top left, #333333, #00cc00), radial-gradient(#cc0000, #ffffff 100px); }
  • 26. SASS or LESS? One weird thing in SASS, is the way variable scope is treated $color: black; .scoped { $color: white; color: $color; } .unscoped { // LESS = black (global) // SASS = white (overwritten by local) color: $color; } Not so intuitive but acceptable
  • 27. Stats (always nice to look at) 2012/02/03 2013/03/09 Number of open issues on 392 98 LESS Number of open issues on 104 68 SASS 272 178 Pending pull requests on 86 6 LESS Pending pull requests on 32 2 SASS 69 22 Number of commits in the 11 95 last two months in LESS Number of commits in the 48 20 last two months in SASS 31 10 Number of members in > 1000 LESS network Number of members in < 500 SASS network < 500
  • 29.
  • 30. Should We Try It? So…. • We should use both, SASS & COMPASS • We should have a solution for development phase (file monitoring - IDEA Plugin? External? Scout? There is even a firebug extension for FF) • We should have a solution for the build phase (probably using GRUNT to run the SASS preprocessor)
  • 31. Further Resources • http://coding.smashingmagazine.com/2011/09/09/an- introduction-to-less-and-comparison-to-sass/ • http://net.tutsplus.com/tutorials/html-css-techniques/sass-vs- less-vs-stylus-a-preprocessor-shootout/ • http://thesassway.com/ • http://thesassway.com/beginner/getting-started-with-sass-and- compass • http://thesassway.com/advanced/pure-sass-functions • http://sass-lang.com/ • http://www.manning.com/netherland/SaCiA_meap_ch01.pdf

Hinweis der Redaktion

  1. Give a general explanation about the basic concept of CSS preprocessing
  2. Give a specific example of working with the UI style guide (as defined in the LiveEngage working process with UI people)
  3. Give a simple explanation about the basic work with CSS preprocessing before it was called like this – give the example of the .NET request handlers and PHP from 2006
  4. Remember to explain that the adoption can be done in steps
  5. Adoption should be done carefully and in steps
  6. General explanation about the work flowRemember to give a small overview about the syntax of both preprocessors and the file extensionsExplain what we are going to see in the examples
  7. Explain the idea behind partial properties
  8. Remember to state that mixins can receive parameters from the caller
  9. Explain why client side preprocessing should not be used (although its appeal)Give a small overview of each preprocessor history from my experience
  10. Show what the meaning of efficiency in this example
  11. Explain the additional functionality which compass gives
  12. Explain the exampleflow and why SASStreats it in a weird way
  13. Talk about the presentation given a year a go and about the process of making it
  14. Explain the full process we will have for development and deployment