SlideShare uma empresa Scribd logo
1 de 58
Advanced


      http://picklebums.com/wp-content/uploads/2010/06/crayon-drawing.jpg
Who is this guy?

                        Nick Cooley
       Principal Front-End Architect,
                       TandemSeven:
               http://www.tandemseven.com


              @nickcooley
  http://www.github.com/nickcooley
Who is this guy?

                        Nick Cooley
       Principal Front-End Architect,
                       TandemSeven:
               http://www.tandemseven.com


              @nickcooley
  http://www.github.com/nickcooley
What we’ll talk about in this session...

• Recap of Sass/Compass
• Advanced Sass
 • Control Structures
 • Color Functions
• Advanced Compass
 • Geometric functions and constants
• Application to Sencha Touch
• DEMOS!
What this Presentation ISN’T

 • Sass vs LESS vs Stylus
 • Why using a CSS Preprocessor is better than not using
    one

 • A conversation about how Preprocessors can bloat your
    CSS
Many great articles arguing the merits/gotchas of using a
pre-processor. Here’s one I really agree with:
http://bit.ly/Sassisntbad
My personal opinion: “Like everything in technology,
preprocessors are a tool in your arsenal. You should
understand the fundamentals of CSS before relying on them.”
What this Presentation ISN’T

 • Sass vs LESS vs Stylus
 • Why using a CSS Preprocessor is better than not using
    one

 • A conversation about how Preprocessors can bloat your
    CSS
Many great articles arguing the merits/gotchas of using a
pre-processor. Here’s one I really agree with:
http://bit.ly/Sassisntbad
My personal opinion: “Like everything in technology,
preprocessors are a tool in your arsenal. You should
understand the fundamentals of CSS before relying on them.”
What this Presentation ISN’T

 • How to code/structure CSS
The hope is that you have *some* CSS
knowledge and are aware of best practices. If
not, here’s a great article for you: kiano.sh/
Inxxym

 • How to build apps with Sencha Touch
While we will go over examples that include
demo Sencha Touch apps, the focus really is on
the Sass/Compass and resulting CSS
Let’s Recap:
What is Sass?
• Stands for “Syntactically Awesome
  StyleSheets”

• “Sass both provides a simpler, more elegant
  syntax for CSS and implements various
  features that are useful for creating
  manageable stylesheets.”

• The foundation for style implementations in
  ExtJS and Sencha Touch
What is Sass?
• Stands for “Syntactically Awesome
  StyleSheets”

• “Sass both provides a simpler, more elegant
  syntax for CSS and implements various
  features that are useful for creating
  manageable stylesheets.”

• The foundation for style implementations in
  ExtJS and Sencha Touch
Sass
Most Popular Features:

• Nesting
• Variables
• Mixins
• Functions
• @extend
Sass
Most Popular Features:

• Nesting
• Variables
• Mixins
• Functions
• @extend
Sass: Nesting
•Sass: Allows you to nest selectors
 within a parent selector.

•This provides an approach that’s
 clean, concise, unique and DRY
Sass: Nesting
•Sass: Allows you to nest selectors
 within a parent selector.

•This provides an approach that’s
 clean, concise, unique and DRY
  div {
    &.content {
      .element {
        h1 {...}
      }
    }
  }

  //outputs
  div.content .element h1 {...}
Sass: Variables
• Allow you to quickly parameterize
  your CSS

• Create diverse variations in
  seconds!

• Helps you create design standards
  for your CSS.

• Using a main color in a number of
Sass: Variables
• Allow you to quickly parameterize
  your CSS

• Create diverse variations in
  seconds!

• Helps you create design standards
  for your CSS.

• Using a main color in a number of
  $color: #fff;
  $pxHeight: 10px;
Sass: Mixins
• Mixins:Sass :: Functions:Javascript
• Allow you to define patterns for
  reuse

• Mixins can be imported across
  projects, helping you to create your
  own framework
Sass: Mixins
    • Mixins:Sass :: Functions:Javascript
    • Allow you to define patterns for
       reuse

    • Mixins can be imported across
        projects, helping you to create your
@mixin  own framework
       pictos-iconmask($name) {
  .x-button .x-button-icon.x-icon-mask.#{$name} {
    -webkit-mask-image: theme_image($theme-name, "pictos/" +
$name + ".png");
  }
}
Compass
•   Collection of Sass mixins and variables

•   X-Browser CSS3 mixins

    •   Rounded Corners             •   Box Shadow
    •   Gradients                   •   Text Shadow

•   Common CSS development Patterns

    •   Reset.css                   •   Sprites

    •   Clearfix                     •   Web Fonts

    •   CSS3 Pie                    •   More!
Let’s turn it up to 11



          http://4.bp.blogspot.com/_8lK2el5pnbU/S-dDjMziqsI/AAAAAAAAGMc/YkZMHVA2-5k/s1600/SpinalTap_.jpg
Control Directives
       in Sass
Very similar to a number of control
directives in languages like javascript,
ruby, PHP -- Sass provides some
rudimentary functionality:

• if/else if/else
• for
• while
@if
Works like every “if” directive you’ve
ever used (if, else if, else)

• create exceptional cases determined
  by CSS controlled attribute
  OR

• Sass also contains an “if” function
  which works as: if($condition, $if-
@if examples
• Example of default @if method
  implementation




• Example of if() function method
@if examples
• Example of default @if method
   implementation
@if $type == bevel {...}
@else if $type == matte {...}
@else {...}



• Example of if() function method
@if examples
• Example of default @if method
   implementation
@if $type == bevel {...}
@else if $type == matte {...}
@else {...}



• Example of if() function method
border: if($i%2==0, 1px solid #000, 4px solid #333);
@for
Is different from the “for” directive in
most programming languages

• two types: “to” and “through”
• cannot count down
• can only iterate by one
@for examples
• Example of “to”


• Example of “through”
@for examples
• Example of “to”
 @for $i from 1 to 3 {
   .item-#{$i} { width: 2em * $i; }
 }

 //outputs
 .item-1 {width: 2em; }
 .item-2 {width: 4em; }


• Example of “through”
@for examples
• Example of “to”
 @for $i from 1 to 3 {
   .item-#{$i} { width: 2em * $i; }
 }

 //outputs
 .item-1 {width: 2em; }
 .item-2 {width: 4em; }


• Example of “through”
 @for $i from 1 through 3 {
   .item-#{$i} { width: 2em * $i; }
 }

 //outputs
 .item-1 {width: 2em; }
 .item-2 {width: 4em; }
 .item-3 {width: 6em; }
@while
Iterates across a range of values using
a statement evaluation until it results in
false

• can evaluate to < > ==
• WARNING: you must adjust the
  evaluation variable manually
@while
Iterates across a range of values using
a statement evaluation until it results in
false

• can evaluate to < > ==
• WARNING: you must adjust the
                   $i: 8;
                   @while $i > 0 {
  evaluation variable manually
                      .box#{$i} {
                          $factor: 100px - ($i * 10);
                          height:$factor !important;
                          width:$factor !important;
                          background: #333;
                          $i: $i - 1;
                      }
                   }
@each
Iterates through a list of items
individually

• Can include list as parameter or
  variable
@each
Iterates through a list of items
individually

• Can include list as parameter or
   variable
$list: (bob, steve, rob);

@each $person in $list {
      .#{$person}{background-image: url($person);}
   }

// CSS output
.bob {background-image:url(bob); }
.steve {background-image:url(steve); }
.rob {background-image:url(rob); }
Colors in Sass
One of the least discussed features in
Sass are color features

• Create themes/schemes/palettes
  based on harmonious color
  relationships

• Mix colors using color relationships
• Sass has operations for RGB and HSL
Color Functions
• complement
• adjust-hue
• lighten/darken
• color math
• AND MANY MORE!
The Boxes
• A really basic demo which shows
  various color functions/control
  directives
Advance processing
   in Compass
Compass may be a framework, but it
provides a number of helpful functions
which can make interesting results:

• Geometry functions:
   • sin(), cos(), tan(), pi()
• Additional math functions:
   • e(), log(), sqrt()
The benefits of
  advanced functions
With these functions, you can:

• Offload some of the processing for things you
  might do in javascript for faster performance

• Be able to calculate in one place and not worry
  about it.

• Do things like:
   • calculate coordinates on a circle
   • plot points on a graph
   • create some interesting designs using math!
Demos
HSL.clrpick.me
• Starting off with a base color,
  generate related color-sets
  based on hsl relationships.

• This can help you determine
  what colors might go
  with your initial color.

• Color relationships
  are based on Sass
  color functions
HSL.clrpick.me
• Starting off with a base color,
  generate related color-sets
  based on hsl relationships.

• This can help you determine
  what colors might go
  with your initial color.

• Color relationships
  are based on Sass
  color functions
So let’s put it all
       together
HSL clrpick.me uses Sass/Compass for

• Iterators
• Positioning color swatches in 360
  using Compass geometry

• Adjusts color using pre-defined
  relationships
So let’s put it all
       together
HSL clrpick.me uses Sass/Compass for

• Iterators
• Positioning color swatches in 360
  using Compass geometry

• Adjusts color using pre-defined
  relationships
First, an example
First, an example
The Color Wheel
The Color Wheel
The Color Wheel
The Color Wheel
@include circlefy(200, $deg);

@mixin circlefy($radius, $deg){
   $rad: angleToRadians($deg);
   @include radiansToCartesian($rad, $radius);
}

@function angleToRadians($a){
   $pi: pi();
   $angle: ($a) / 180;
   $radians: $pi * $angle;
   @return $radians;
}

@mixin radiansToCartesian($r, $radius){
   $x: round($radius * cos($r));
   $y: round($radius * sin($r));

    top: #{$y}px;
    left:#{$x}px;
}
The S & L Bars
The S & L Bars
The S and L bars
The S and L bars
$light : lightness($colorwheel1);
@for $i from 0 through 10 {
   &:nth-child(#{$i + 1}){
      $startBackground: lighten($colorwheel1, 100);
      $val: $i * 10;
      background: darken($startBackground, $val );
      span {margin-left:0; right:55px;}
      span:after {content: "lightness: #{$val} color:
#{darken($startBackground, $val )}";}
   }
}
But hey, you said
    “Sencha Touch”
Sencha Touch is a javascript framework
which relies on Sass/Compass for its
look/feel.

• Sencha has put together a really solid
  set of mixins: buttons, pictomasks,
  toolbars

• There’s really no limit to what you
  can add using Sass/Compass specific
But hey, you said
    “Sencha Touch”
Sencha Touch is a javascript framework
which relies on Sass/Compass for its
look/feel.

• Sencha has put together a really solid
  set of mixins: buttons, pictomasks,
  toolbars

• There’s really no limit to what you
  can add using Sass/Compass specific
Sencha Touch Docs
Throughout the Sencha Touch
documentation, you’ll find predefined
mixins which you can use out-of-the-
box
ST2 Demo
Just to show you that modifying Sass/
Compass for Sencha Touch is just as
easy as it is for anything else....
Links
•   Sass Site: sass-lang.com

•   Compass Site: compass-style.org

•   Compass.app Site: compass.handlino.com

•   HSL Color Picker: hsl.clrpick.me or github.com/nickcooley/clrpick.me

•   Manning Sass Book : manning.com/netherland/

•   LiveReload : livereload.com

•   FireSass : addons.mozilla.org/en-US/firefox/addon/firesass-for-firebug/

Mais conteúdo relacionado

Mais procurados

Deep dive into sass
Deep dive into sassDeep dive into sass
Deep dive into sassKnoldus Inc.
 
Introduction to SASS
Introduction to SASSIntroduction to SASS
Introduction to SASSJon Dean
 
Write LESS. DO more.
Write LESS. DO more.Write LESS. DO more.
Write LESS. DO more.Eugene Nor
 
An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)Folio3 Software
 
CSS Preprocessors: LESS is more or look SASS-y trying
CSS Preprocessors: LESS is more or look SASS-y tryingCSS Preprocessors: LESS is more or look SASS-y trying
CSS Preprocessors: LESS is more or look SASS-y tryingJames Cryer
 
HTML5, CSS, JavaScript Style guide and coding conventions
HTML5, CSS, JavaScript Style guide and coding conventionsHTML5, CSS, JavaScript Style guide and coding conventions
HTML5, CSS, JavaScript Style guide and coding conventionsKnoldus Inc.
 
CSS preprocessor: why and how
CSS preprocessor: why and howCSS preprocessor: why and how
CSS preprocessor: why and howmirahman
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With LessDavid Engel
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassLucien Lee
 
CSS: a rapidly changing world
CSS: a rapidly changing worldCSS: a rapidly changing world
CSS: a rapidly changing worldRuss Weakley
 

Mais procurados (20)

Deep dive into sass
Deep dive into sassDeep dive into sass
Deep dive into sass
 
Introduction to SASS
Introduction to SASSIntroduction to SASS
Introduction to SASS
 
Introduction to sass
Introduction to sassIntroduction to sass
Introduction to sass
 
Write LESS. DO more.
Write LESS. DO more.Write LESS. DO more.
Write LESS. DO more.
 
An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)
 
Sass
SassSass
Sass
 
CSS Preprocessors: LESS is more or look SASS-y trying
CSS Preprocessors: LESS is more or look SASS-y tryingCSS Preprocessors: LESS is more or look SASS-y trying
CSS Preprocessors: LESS is more or look SASS-y trying
 
Less vs sass
Less vs sassLess vs sass
Less vs sass
 
Css to-scss
Css to-scssCss to-scss
Css to-scss
 
HTML5, CSS, JavaScript Style guide and coding conventions
HTML5, CSS, JavaScript Style guide and coding conventionsHTML5, CSS, JavaScript Style guide and coding conventions
HTML5, CSS, JavaScript Style guide and coding conventions
 
Compass
CompassCompass
Compass
 
Sass_Cubet seminar
Sass_Cubet seminarSass_Cubet seminar
Sass_Cubet seminar
 
CSS3
CSS3CSS3
CSS3
 
Css 3
Css 3Css 3
Css 3
 
Css 3
Css 3Css 3
Css 3
 
CSS preprocessor: why and how
CSS preprocessor: why and howCSS preprocessor: why and how
CSS preprocessor: why and how
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With Less
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & Compass
 
CSS
CSSCSS
CSS
 
CSS: a rapidly changing world
CSS: a rapidly changing worldCSS: a rapidly changing world
CSS: a rapidly changing world
 

Destaque

CSS Sanity with Sass: The Inverted Triangle Approach
CSS Sanity with Sass: The Inverted Triangle ApproachCSS Sanity with Sass: The Inverted Triangle Approach
CSS Sanity with Sass: The Inverted Triangle ApproachJulie Kuehl
 
JavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayJavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayChamnap Chhorn
 
Javascript Prototype Visualized
Javascript Prototype VisualizedJavascript Prototype Visualized
Javascript Prototype Visualized军 沈
 
Getting Started with Sass & Compass
Getting Started with Sass & CompassGetting Started with Sass & Compass
Getting Started with Sass & CompassRob Davarnia
 
Smart CSS theming with Sass and Compass
Smart CSS theming with Sass and CompassSmart CSS theming with Sass and Compass
Smart CSS theming with Sass and CompassMihaela
 
Object Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptObject Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptForziatech
 
Advanced JavaScript Concepts
Advanced JavaScript ConceptsAdvanced JavaScript Concepts
Advanced JavaScript ConceptsNaresh Kumar
 
Object Oriented Programming in JavaScript
Object Oriented Programming in JavaScriptObject Oriented Programming in JavaScript
Object Oriented Programming in JavaScriptzand3rs
 
JavaScript Prototype and Module Pattern
JavaScript Prototype and Module PatternJavaScript Prototype and Module Pattern
JavaScript Prototype and Module PatternNarendra Sisodiya
 
Sass: The Future of Stylesheets
Sass: The Future of StylesheetsSass: The Future of Stylesheets
Sass: The Future of Stylesheetschriseppstein
 
Sass and compass workshop
Sass and compass workshopSass and compass workshop
Sass and compass workshopShaho Toofani
 
The ultimate guide to prototyping
The ultimate guide to prototypingThe ultimate guide to prototyping
The ultimate guide to prototypingMarcelo Graciolli
 
Prototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScriptPrototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScriptSunny Sharma
 
Prototype-based Programming with JavaScript
Prototype-based Programming with JavaScriptPrototype-based Programming with JavaScript
Prototype-based Programming with JavaScriptlienhard
 

Destaque (19)

CSS Sanity with Sass: The Inverted Triangle Approach
CSS Sanity with Sass: The Inverted Triangle ApproachCSS Sanity with Sass: The Inverted Triangle Approach
CSS Sanity with Sass: The Inverted Triangle Approach
 
JavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayJavaScript in Object-Oriented Way
JavaScript in Object-Oriented Way
 
Prototype
PrototypePrototype
Prototype
 
Javascript Prototype Visualized
Javascript Prototype VisualizedJavascript Prototype Visualized
Javascript Prototype Visualized
 
Getting Started with Sass & Compass
Getting Started with Sass & CompassGetting Started with Sass & Compass
Getting Started with Sass & Compass
 
Smart CSS theming with Sass and Compass
Smart CSS theming with Sass and CompassSmart CSS theming with Sass and Compass
Smart CSS theming with Sass and Compass
 
Object Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptObject Oriented Programming In JavaScript
Object Oriented Programming In JavaScript
 
JavaScript OOPs
JavaScript OOPsJavaScript OOPs
JavaScript OOPs
 
Advanced JavaScript Concepts
Advanced JavaScript ConceptsAdvanced JavaScript Concepts
Advanced JavaScript Concepts
 
Object Oriented Programming in JavaScript
Object Oriented Programming in JavaScriptObject Oriented Programming in JavaScript
Object Oriented Programming in JavaScript
 
JavaScript Prototype and Module Pattern
JavaScript Prototype and Module PatternJavaScript Prototype and Module Pattern
JavaScript Prototype and Module Pattern
 
Sass: The Future of Stylesheets
Sass: The Future of StylesheetsSass: The Future of Stylesheets
Sass: The Future of Stylesheets
 
Sass and compass workshop
Sass and compass workshopSass and compass workshop
Sass and compass workshop
 
Sas demo
Sas demoSas demo
Sas demo
 
The ultimate guide to prototyping
The ultimate guide to prototypingThe ultimate guide to prototyping
The ultimate guide to prototyping
 
Business Plan
Business PlanBusiness Plan
Business Plan
 
Prototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScriptPrototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScript
 
Prototype-based Programming with JavaScript
Prototype-based Programming with JavaScriptPrototype-based Programming with JavaScript
Prototype-based Programming with JavaScript
 
K to 12 Mechanical Drafting Learning Module
K to 12 Mechanical Drafting Learning ModuleK to 12 Mechanical Drafting Learning Module
K to 12 Mechanical Drafting Learning Module
 

Semelhante a Advanced sass/compass

DrupalCamp Chattanooga - September 2014 - Sass 101
DrupalCamp Chattanooga - September 2014 - Sass 101DrupalCamp Chattanooga - September 2014 - Sass 101
DrupalCamp Chattanooga - September 2014 - Sass 101Eric Sembrat
 
Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01Anam Hossain
 
What is-sass-by-lucas-castro
What is-sass-by-lucas-castroWhat is-sass-by-lucas-castro
What is-sass-by-lucas-castroLucas Castro
 
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
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockMarco Pinheiro
 
CSS Workflow. Pre & Post
CSS Workflow. Pre & PostCSS Workflow. Pre & Post
CSS Workflow. Pre & PostAnton Dosov
 
Joes sass presentation
Joes sass presentationJoes sass presentation
Joes sass presentationJoeSeckelman
 
Spectrum 2015 going online with style - an intro to css
Spectrum 2015   going online with style - an intro to cssSpectrum 2015   going online with style - an intro to css
Spectrum 2015 going online with style - an intro to cssNeil Perlin
 
Modern Front-End Development
Modern Front-End DevelopmentModern Front-End Development
Modern Front-End Developmentmwrather
 
Responsive Design in Drupal with Zen and Zen Grids
Responsive Design in Drupal with Zen and Zen GridsResponsive Design in Drupal with Zen and Zen Grids
Responsive Design in Drupal with Zen and Zen GridsSuzanne Dergacheva
 
Advanced Technology for Web Application Design
Advanced Technology for Web Application DesignAdvanced Technology for Web Application Design
Advanced Technology for Web Application DesignBryce Kerley
 
Keep calm and let's play CSS3
Keep calm and let's play CSS3Keep calm and let's play CSS3
Keep calm and let's play CSS3A2 Comunicação
 
Front-End Frameworks: a quick overview
Front-End Frameworks: a quick overviewFront-End Frameworks: a quick overview
Front-End Frameworks: a quick overviewDiacode
 
October 2014 - USG Rock Eagle - Sass 101
October 2014 - USG Rock Eagle - Sass 101October 2014 - USG Rock Eagle - Sass 101
October 2014 - USG Rock Eagle - Sass 101Eric Sembrat
 

Semelhante a Advanced sass/compass (20)

DrupalCamp Chattanooga - September 2014 - Sass 101
DrupalCamp Chattanooga - September 2014 - Sass 101DrupalCamp Chattanooga - September 2014 - Sass 101
DrupalCamp Chattanooga - September 2014 - Sass 101
 
Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01
 
What is-sass-by-lucas-castro
What is-sass-by-lucas-castroWhat is-sass-by-lucas-castro
What is-sass-by-lucas-castro
 
UNIT 3.ppt
UNIT 3.pptUNIT 3.ppt
UNIT 3.ppt
 
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
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, Greensock
 
CSS Workflow. Pre & Post
CSS Workflow. Pre & PostCSS Workflow. Pre & Post
CSS Workflow. Pre & Post
 
Sass compass
Sass compassSass compass
Sass compass
 
Joes sass presentation
Joes sass presentationJoes sass presentation
Joes sass presentation
 
Spectrum 2015 going online with style - an intro to css
Spectrum 2015   going online with style - an intro to cssSpectrum 2015   going online with style - an intro to css
Spectrum 2015 going online with style - an intro to css
 
Modern Front-End Development
Modern Front-End DevelopmentModern Front-End Development
Modern Front-End Development
 
LESS CSS
LESS CSSLESS CSS
LESS CSS
 
Responsive Design in Drupal with Zen and Zen Grids
Responsive Design in Drupal with Zen and Zen GridsResponsive Design in Drupal with Zen and Zen Grids
Responsive Design in Drupal with Zen and Zen Grids
 
CSS
CSSCSS
CSS
 
Advanced Technology for Web Application Design
Advanced Technology for Web Application DesignAdvanced Technology for Web Application Design
Advanced Technology for Web Application Design
 
Keep calm and let's play CSS3
Keep calm and let's play CSS3Keep calm and let's play CSS3
Keep calm and let's play CSS3
 
Front-End Frameworks: a quick overview
Front-End Frameworks: a quick overviewFront-End Frameworks: a quick overview
Front-End Frameworks: a quick overview
 
October 2014 - USG Rock Eagle - Sass 101
October 2014 - USG Rock Eagle - Sass 101October 2014 - USG Rock Eagle - Sass 101
October 2014 - USG Rock Eagle - Sass 101
 
Beautifying senc
Beautifying sencBeautifying senc
Beautifying senc
 
Team styles
Team stylesTeam styles
Team styles
 

Último

Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
[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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
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
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Último (20)

Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
[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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
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
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

Advanced sass/compass

  • 1. Advanced http://picklebums.com/wp-content/uploads/2010/06/crayon-drawing.jpg
  • 2. Who is this guy? Nick Cooley Principal Front-End Architect, TandemSeven: http://www.tandemseven.com @nickcooley http://www.github.com/nickcooley
  • 3. Who is this guy? Nick Cooley Principal Front-End Architect, TandemSeven: http://www.tandemseven.com @nickcooley http://www.github.com/nickcooley
  • 4. What we’ll talk about in this session... • Recap of Sass/Compass • Advanced Sass • Control Structures • Color Functions • Advanced Compass • Geometric functions and constants • Application to Sencha Touch • DEMOS!
  • 5. What this Presentation ISN’T • Sass vs LESS vs Stylus • Why using a CSS Preprocessor is better than not using one • A conversation about how Preprocessors can bloat your CSS Many great articles arguing the merits/gotchas of using a pre-processor. Here’s one I really agree with: http://bit.ly/Sassisntbad My personal opinion: “Like everything in technology, preprocessors are a tool in your arsenal. You should understand the fundamentals of CSS before relying on them.”
  • 6. What this Presentation ISN’T • Sass vs LESS vs Stylus • Why using a CSS Preprocessor is better than not using one • A conversation about how Preprocessors can bloat your CSS Many great articles arguing the merits/gotchas of using a pre-processor. Here’s one I really agree with: http://bit.ly/Sassisntbad My personal opinion: “Like everything in technology, preprocessors are a tool in your arsenal. You should understand the fundamentals of CSS before relying on them.”
  • 7. What this Presentation ISN’T • How to code/structure CSS The hope is that you have *some* CSS knowledge and are aware of best practices. If not, here’s a great article for you: kiano.sh/ Inxxym • How to build apps with Sencha Touch While we will go over examples that include demo Sencha Touch apps, the focus really is on the Sass/Compass and resulting CSS
  • 9. What is Sass? • Stands for “Syntactically Awesome StyleSheets” • “Sass both provides a simpler, more elegant syntax for CSS and implements various features that are useful for creating manageable stylesheets.” • The foundation for style implementations in ExtJS and Sencha Touch
  • 10. What is Sass? • Stands for “Syntactically Awesome StyleSheets” • “Sass both provides a simpler, more elegant syntax for CSS and implements various features that are useful for creating manageable stylesheets.” • The foundation for style implementations in ExtJS and Sencha Touch
  • 11. Sass Most Popular Features: • Nesting • Variables • Mixins • Functions • @extend
  • 12. Sass Most Popular Features: • Nesting • Variables • Mixins • Functions • @extend
  • 13. Sass: Nesting •Sass: Allows you to nest selectors within a parent selector. •This provides an approach that’s clean, concise, unique and DRY
  • 14. Sass: Nesting •Sass: Allows you to nest selectors within a parent selector. •This provides an approach that’s clean, concise, unique and DRY div { &.content { .element { h1 {...} } } } //outputs div.content .element h1 {...}
  • 15. Sass: Variables • Allow you to quickly parameterize your CSS • Create diverse variations in seconds! • Helps you create design standards for your CSS. • Using a main color in a number of
  • 16. Sass: Variables • Allow you to quickly parameterize your CSS • Create diverse variations in seconds! • Helps you create design standards for your CSS. • Using a main color in a number of $color: #fff; $pxHeight: 10px;
  • 17. Sass: Mixins • Mixins:Sass :: Functions:Javascript • Allow you to define patterns for reuse • Mixins can be imported across projects, helping you to create your own framework
  • 18. Sass: Mixins • Mixins:Sass :: Functions:Javascript • Allow you to define patterns for reuse • Mixins can be imported across projects, helping you to create your @mixin own framework pictos-iconmask($name) { .x-button .x-button-icon.x-icon-mask.#{$name} { -webkit-mask-image: theme_image($theme-name, "pictos/" + $name + ".png"); } }
  • 19. Compass • Collection of Sass mixins and variables • X-Browser CSS3 mixins • Rounded Corners • Box Shadow • Gradients • Text Shadow • Common CSS development Patterns • Reset.css • Sprites • Clearfix • Web Fonts • CSS3 Pie • More!
  • 20. Let’s turn it up to 11 http://4.bp.blogspot.com/_8lK2el5pnbU/S-dDjMziqsI/AAAAAAAAGMc/YkZMHVA2-5k/s1600/SpinalTap_.jpg
  • 21. Control Directives in Sass Very similar to a number of control directives in languages like javascript, ruby, PHP -- Sass provides some rudimentary functionality: • if/else if/else • for • while
  • 22. @if Works like every “if” directive you’ve ever used (if, else if, else) • create exceptional cases determined by CSS controlled attribute OR • Sass also contains an “if” function which works as: if($condition, $if-
  • 23. @if examples • Example of default @if method implementation • Example of if() function method
  • 24. @if examples • Example of default @if method implementation @if $type == bevel {...} @else if $type == matte {...} @else {...} • Example of if() function method
  • 25. @if examples • Example of default @if method implementation @if $type == bevel {...} @else if $type == matte {...} @else {...} • Example of if() function method border: if($i%2==0, 1px solid #000, 4px solid #333);
  • 26. @for Is different from the “for” directive in most programming languages • two types: “to” and “through” • cannot count down • can only iterate by one
  • 27. @for examples • Example of “to” • Example of “through”
  • 28. @for examples • Example of “to” @for $i from 1 to 3 { .item-#{$i} { width: 2em * $i; } } //outputs .item-1 {width: 2em; } .item-2 {width: 4em; } • Example of “through”
  • 29. @for examples • Example of “to” @for $i from 1 to 3 { .item-#{$i} { width: 2em * $i; } } //outputs .item-1 {width: 2em; } .item-2 {width: 4em; } • Example of “through” @for $i from 1 through 3 { .item-#{$i} { width: 2em * $i; } } //outputs .item-1 {width: 2em; } .item-2 {width: 4em; } .item-3 {width: 6em; }
  • 30. @while Iterates across a range of values using a statement evaluation until it results in false • can evaluate to < > == • WARNING: you must adjust the evaluation variable manually
  • 31. @while Iterates across a range of values using a statement evaluation until it results in false • can evaluate to < > == • WARNING: you must adjust the $i: 8; @while $i > 0 { evaluation variable manually .box#{$i} { $factor: 100px - ($i * 10); height:$factor !important; width:$factor !important; background: #333; $i: $i - 1; } }
  • 32. @each Iterates through a list of items individually • Can include list as parameter or variable
  • 33. @each Iterates through a list of items individually • Can include list as parameter or variable $list: (bob, steve, rob); @each $person in $list { .#{$person}{background-image: url($person);} } // CSS output .bob {background-image:url(bob); } .steve {background-image:url(steve); } .rob {background-image:url(rob); }
  • 34. Colors in Sass One of the least discussed features in Sass are color features • Create themes/schemes/palettes based on harmonious color relationships • Mix colors using color relationships • Sass has operations for RGB and HSL
  • 35. Color Functions • complement • adjust-hue • lighten/darken • color math • AND MANY MORE!
  • 36. The Boxes • A really basic demo which shows various color functions/control directives
  • 37. Advance processing in Compass Compass may be a framework, but it provides a number of helpful functions which can make interesting results: • Geometry functions: • sin(), cos(), tan(), pi() • Additional math functions: • e(), log(), sqrt()
  • 38. The benefits of advanced functions With these functions, you can: • Offload some of the processing for things you might do in javascript for faster performance • Be able to calculate in one place and not worry about it. • Do things like: • calculate coordinates on a circle • plot points on a graph • create some interesting designs using math!
  • 39. Demos
  • 40. HSL.clrpick.me • Starting off with a base color, generate related color-sets based on hsl relationships. • This can help you determine what colors might go with your initial color. • Color relationships are based on Sass color functions
  • 41. HSL.clrpick.me • Starting off with a base color, generate related color-sets based on hsl relationships. • This can help you determine what colors might go with your initial color. • Color relationships are based on Sass color functions
  • 42. So let’s put it all together HSL clrpick.me uses Sass/Compass for • Iterators • Positioning color swatches in 360 using Compass geometry • Adjusts color using pre-defined relationships
  • 43. So let’s put it all together HSL clrpick.me uses Sass/Compass for • Iterators • Positioning color swatches in 360 using Compass geometry • Adjusts color using pre-defined relationships
  • 49. The Color Wheel @include circlefy(200, $deg); @mixin circlefy($radius, $deg){ $rad: angleToRadians($deg); @include radiansToCartesian($rad, $radius); } @function angleToRadians($a){ $pi: pi(); $angle: ($a) / 180; $radians: $pi * $angle; @return $radians; } @mixin radiansToCartesian($r, $radius){ $x: round($radius * cos($r)); $y: round($radius * sin($r)); top: #{$y}px; left:#{$x}px; }
  • 50. The S & L Bars
  • 51. The S & L Bars
  • 52. The S and L bars
  • 53. The S and L bars $light : lightness($colorwheel1); @for $i from 0 through 10 { &:nth-child(#{$i + 1}){ $startBackground: lighten($colorwheel1, 100); $val: $i * 10; background: darken($startBackground, $val ); span {margin-left:0; right:55px;} span:after {content: "lightness: #{$val} color: #{darken($startBackground, $val )}";} } }
  • 54. But hey, you said “Sencha Touch” Sencha Touch is a javascript framework which relies on Sass/Compass for its look/feel. • Sencha has put together a really solid set of mixins: buttons, pictomasks, toolbars • There’s really no limit to what you can add using Sass/Compass specific
  • 55. But hey, you said “Sencha Touch” Sencha Touch is a javascript framework which relies on Sass/Compass for its look/feel. • Sencha has put together a really solid set of mixins: buttons, pictomasks, toolbars • There’s really no limit to what you can add using Sass/Compass specific
  • 56. Sencha Touch Docs Throughout the Sencha Touch documentation, you’ll find predefined mixins which you can use out-of-the- box
  • 57. ST2 Demo Just to show you that modifying Sass/ Compass for Sencha Touch is just as easy as it is for anything else....
  • 58. Links • Sass Site: sass-lang.com • Compass Site: compass-style.org • Compass.app Site: compass.handlino.com • HSL Color Picker: hsl.clrpick.me or github.com/nickcooley/clrpick.me • Manning Sass Book : manning.com/netherland/ • LiveReload : livereload.com • FireSass : addons.mozilla.org/en-US/firefox/addon/firesass-for-firebug/

Notas do Editor

  1. \n
  2. I&amp;#x2019;ve been developing web solutions for over 12 years. I&amp;#x2019;m a Principal Front-End Architect at TandemSeven where I build mobile and portal solutions for clients in the Financial Services, Health Care, Energy industries. \n
  3. \n
  4. 1.) They&apos;re all generally great and do basically the same thing. There are some folks who are passionate about the issue, but we&amp;#x2019;re here to talk about Sass/Compass\n2.) We&apos;re going to assume that you know the basics and buy into it. &amp;#xA0;I&apos;ll point out basic benefits as they come up, but it&apos;s not a focus of this presentation\n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. these features are unique to Sass vs LESS. Stylus has some similar features\n
  15. 2.) Called an &amp;#x201C;instance method&amp;#x201D; which evaluates a boolean condition. This is similiar to the javascript ternary operator for property values. Helpful for conditions you want to implement inline and can be useful in an iterator.\n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. Well, fortunately Sass solves a lot of those problems out of the box. \n
  25. \n
  26. \n
  27. \n
  28. show page of color functions using the various functions above. color_demo.html\n
  29. \n
  30. \n
  31. Should I take the time to show the examples first to illustrate where the talk is going and use the two examples to demonstrate each concept?\n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n