SlideShare una empresa de Scribd logo
1 de 23
Descargar para leer sin conexión
@mlteal | #WCPhilly | June 2015
Getting Started with SASS
or: All the things I wished for with CSS
@mlteal | #WCPhilly | June 2015
Maura Teal
Web Developer at FanSided
@mlteal | mlteal.com
@mlteal | #WCPhilly | June 2015
What is it?
Syntactically Awesome StyleSheets
A CSS pre-processor that allows us to use logic similar to
real programming languages.
@mlteal | #WCPhilly | June 2015
What do you get?
More organization, sanity because variables,
mixins, and functions.
TL;DR: Build and adjust stylesheets efficiently.
@mlteal | #WCPhilly | June 2015
How Does it Work?
Watch your code while you
work locally and continually
compile into the CSS file
you’ll use in your project.
@mlteal | #WCPhilly | June 2015
Getting Started
1. Install Ruby
2. Install Sass Gem
3. Watch those files:
Alternatively, download a GUI
that takes care of things:
Codekit ($)
Koala (free)
Scout (free)
From the Command Line:
cd path/to/my/sass/folder
sass --watch input.scss:output.css
Ctrl+C to stop watching
@mlteal | #WCPhilly | June 2015
Just want to try it out?
Codepen: http://codepen.io/
Sassmeister: http://sassmeister.com/
@mlteal | #WCPhilly | June 2015
Features
• Nesting
• Variables
• Mixins
• Functions
• Minification
• Libraries
To name a few…
@mlteal | #WCPhilly | June 2015
Nesting
Xzibit knows you like selectors
@mlteal | #WCPhilly | June 2015
Nesting
SASS
.parent {

blockquote, p {

font-family: Times;

}

a {

color: teal;

}

span {

background: yellow;

}

}
CSS
.parent blockquote, 

.parent p {

font-family: Times;

}

.parent a {

color: teal;

}

.parent span {

background: yellow;

}
@mlteal | #WCPhilly | June 2015
Nesting
a {

color: teal;

&.special {

color: gold;

}

&:hover, 

&:active {

font-style: italic;

}

}
a {

color: teal;

}

a.special {

color: gold;

}

a:hover, 

a:active {

font-style: italic;

}
@mlteal | #WCPhilly | June 2015
Variables
$variable-name : /* variable properties here */;
Think colors (hex values or rgba), fonts, sizes,
or even previously defined vars:
$fuchsia : #f0f;
$border-style : 1px solid $fuchsia;
$heading-size : 30px;
$subheading-size : $heading-size / 2;
@mlteal | #WCPhilly | June 2015
Variables
1. Define your color
palette just this one time


$white : #FFFFFF;

$teal : #27ba9a;

$french-blue : #3196da;

$purple : #9a58b5;

$light-grey : #7e8c8d;
2. Abstract it in case all
headings change from
$purple to $teal someday
$heading : $purple;

$sub-heading : $white;

$body-text : $light-grey;

$link : $french-blue;

$accent : $teal;
@mlteal | #WCPhilly | June 2015
Mixins
add candy to your code
@mlteal | #WCPhilly | June 2015
Mixins
Create reusable chunks of CSS
@mixin border-radius($radius) {
-moz-border-radius: $radius;
-webkit-border-radius: $radius;
border-radius: $radius;
}
.container {
@include border-radius(18px);
} .footer {
@include border-radius(6px);
}
.container {
-moz-border-radius: 18px;
-webkit-border-radius: 18px;
border-radius: 18px;
}
.footer {
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
border-radius: 6px;
}
@mlteal | #WCPhilly | June 2015
Functions
Create reusable logic
@function remy($pxsize) {
@return: ($pxsize / 16 )+rem;
}
.container {
font-size: remy(32);
}
.container {
font-size: 2rem;
}
Ref: http://sass-lang.com/documentation/Sass/Script/Functions.html
@mlteal | #WCPhilly | June 2015
Putting it all together
Combining map-get() function with array maps
$iconfont-map : (
arrow: "f063",
caret-down: “f0d7",
wordpress: “f19a",
);
@mixin icon( $icon ) {
font-family: “Icon Font”;
content: '#{map-get( $iconfont-map, $icon )}';
}
.my-list a {
&:before {
@include icon( arrow );
}
}
@mlteal | #WCPhilly | June 2015
Sass Frameworks
Utilize libraries & extensions
with Sass to get an even
more powerful preprocessor.
Many make built-in functions
available like transform() or
include their own grid systems.
• Compass
• Breakpoint
• Susy
• Bourbon
• Bootstrap
@mlteal | #WCPhilly | June 2015
Test Drive in a Project
Plugins:
Jetpack Custom CSS module: for adding custom CSS
directly on site
Admin Color Schemes: https://wordpress.org/plugins/
admin-color-schemes/
@mlteal | #WCPhilly | June 2015
Test Drive in a Project
Starter Themes:
Underscores: http://underscores.me/
Bones (need Compass): http://themble.com/bones/
Foundation: http://foundationpress.olefredrik.com/
Roots (now Sage): https://roots.io/sage/
Some Like it Neat: http://somelikeitneat.com/
@mlteal | #WCPhilly | June 2015
Workflows
Utilize task-based build tools (either
Grunt or Gulp) to watch and compile all
the things.
Config files make life easier, and
actively watch more than just your
stylesheets (think minifying JS and
more)
@mlteal | #WCPhilly | June 2015
Future & Performance
Ruby Sass - The original Sass we know & love

- Simple installation

- Lots of compatible frameworks

- Compiling can get slow on larger projects
LibSass - A C/C++ port of Sass

- Just a Sass library, so it needs a wrapper

- Not 100% caught up to Ruby Sass (but so close!)

- Stricter on syntax

- Much faster (up to 4000x)!
@mlteal | #WCPhilly | June 2015
Resources
Sass Documentation: 

http://sass-lang.com/documentation/file.SASS_REFERENCE.html
Codepen: http://codepen.io

Sassmeister: http://sassmeister.com
Underscores: http://underscores.me

Bones: http://themble.com/bones/
Ruby Sass vs LibSass: http://sassbreak.com/ruby-sass-libsass-differences/

Sass Compatibility Guide: http://sass-compatibility.github.io/

Más contenido relacionado

Destacado (7)

Getting SASSy with front end development
Getting SASSy with front end developmentGetting SASSy with front end development
Getting SASSy with front end development
 
SASS - Syntactically Awesome Stylesheet
SASS - Syntactically Awesome StylesheetSASS - Syntactically Awesome Stylesheet
SASS - Syntactically Awesome Stylesheet
 
Sass: Introduction
Sass: IntroductionSass: Introduction
Sass: Introduction
 
Introduction to SASS
Introduction to SASSIntroduction to SASS
Introduction to SASS
 
CSS3 secrets: 10 things you might not know about CSS3
CSS3 secrets: 10 things you might not know about CSS3CSS3 secrets: 10 things you might not know about CSS3
CSS3 secrets: 10 things you might not know about CSS3
 
Sass - Getting Started with Sass!
Sass - Getting Started with Sass!Sass - Getting Started with Sass!
Sass - Getting Started with Sass!
 
Fundamental CSS3
Fundamental CSS3Fundamental CSS3
Fundamental CSS3
 

Similar a Getting Started With Sass | WC Philly 2015

Freelancer Weapons of mass productivity
Freelancer Weapons of mass productivityFreelancer Weapons of mass productivity
Freelancer Weapons of mass productivity
Gregg Coppen
 

Similar a Getting Started With Sass | WC Philly 2015 (20)

Advanced sass/compass
Advanced sass/compassAdvanced sass/compass
Advanced sass/compass
 
CSS Workflow. Pre & Post
CSS Workflow. Pre & PostCSS Workflow. Pre & Post
CSS Workflow. Pre & Post
 
Branding SharePoint from Prototype to Deployment - Workshop
Branding SharePoint from Prototype to Deployment - WorkshopBranding SharePoint from Prototype to Deployment - Workshop
Branding SharePoint from Prototype to Deployment - Workshop
 
CSS3
CSS3CSS3
CSS3
 
UNIT 3.ppt
UNIT 3.pptUNIT 3.ppt
UNIT 3.ppt
 
Modern Front-End Development
Modern Front-End DevelopmentModern Front-End Development
Modern Front-End Development
 
Open Data Science Conference Big Data Infrastructure – Introduction to Hadoop...
Open Data Science Conference Big Data Infrastructure – Introduction to Hadoop...Open Data Science Conference Big Data Infrastructure – Introduction to Hadoop...
Open Data Science Conference Big Data Infrastructure – Introduction to Hadoop...
 
Volunteer.rb
Volunteer.rbVolunteer.rb
Volunteer.rb
 
Brand Your Community Using Less and Gulp
Brand Your Community Using Less and GulpBrand Your Community Using Less and Gulp
Brand Your Community Using Less and Gulp
 
Utilizing jQuery in SharePoint: Get More Done Faster
Utilizing jQuery in SharePoint: Get More Done FasterUtilizing jQuery in SharePoint: Get More Done Faster
Utilizing jQuery in SharePoint: Get More Done Faster
 
#SPSTC Maximizing the SharePoint User Experience with Free 3rd Party jQuery L...
#SPSTC Maximizing the SharePoint User Experience with Free 3rd Party jQuery L...#SPSTC Maximizing the SharePoint User Experience with Free 3rd Party jQuery L...
#SPSTC Maximizing the SharePoint User Experience with Free 3rd Party jQuery L...
 
Jina bolton - Refactoring Web Interfaces
Jina bolton - Refactoring Web InterfacesJina bolton - Refactoring Web Interfaces
Jina bolton - Refactoring Web Interfaces
 
Accessibility Hacks Version 2
Accessibility Hacks Version 2Accessibility Hacks Version 2
Accessibility Hacks Version 2
 
Accessibility Hacks version 2
Accessibility Hacks version 2Accessibility Hacks version 2
Accessibility Hacks version 2
 
Brand Your Community Using Less and Gulp
Brand Your Community Using Less and GulpBrand Your Community Using Less and Gulp
Brand Your Community Using Less and Gulp
 
Accessibility Hacks Wordcamp Manchester October 2018
Accessibility Hacks Wordcamp Manchester October 2018Accessibility Hacks Wordcamp Manchester October 2018
Accessibility Hacks Wordcamp Manchester October 2018
 
Making your site printable: WordCamp Buffalo 2013
Making your site printable: WordCamp Buffalo 2013Making your site printable: WordCamp Buffalo 2013
Making your site printable: WordCamp Buffalo 2013
 
Team styles
Team stylesTeam styles
Team styles
 
Building rednoseday.com on Drupal 8
Building rednoseday.com on Drupal 8Building rednoseday.com on Drupal 8
Building rednoseday.com on Drupal 8
 
Freelancer Weapons of mass productivity
Freelancer Weapons of mass productivityFreelancer Weapons of mass productivity
Freelancer Weapons of mass productivity
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 

Getting Started With Sass | WC Philly 2015

  • 1. @mlteal | #WCPhilly | June 2015 Getting Started with SASS or: All the things I wished for with CSS
  • 2. @mlteal | #WCPhilly | June 2015 Maura Teal Web Developer at FanSided @mlteal | mlteal.com
  • 3. @mlteal | #WCPhilly | June 2015 What is it? Syntactically Awesome StyleSheets A CSS pre-processor that allows us to use logic similar to real programming languages.
  • 4. @mlteal | #WCPhilly | June 2015 What do you get? More organization, sanity because variables, mixins, and functions. TL;DR: Build and adjust stylesheets efficiently.
  • 5. @mlteal | #WCPhilly | June 2015 How Does it Work? Watch your code while you work locally and continually compile into the CSS file you’ll use in your project.
  • 6. @mlteal | #WCPhilly | June 2015 Getting Started 1. Install Ruby 2. Install Sass Gem 3. Watch those files: Alternatively, download a GUI that takes care of things: Codekit ($) Koala (free) Scout (free) From the Command Line: cd path/to/my/sass/folder sass --watch input.scss:output.css Ctrl+C to stop watching
  • 7. @mlteal | #WCPhilly | June 2015 Just want to try it out? Codepen: http://codepen.io/ Sassmeister: http://sassmeister.com/
  • 8. @mlteal | #WCPhilly | June 2015 Features • Nesting • Variables • Mixins • Functions • Minification • Libraries To name a few…
  • 9. @mlteal | #WCPhilly | June 2015 Nesting Xzibit knows you like selectors
  • 10. @mlteal | #WCPhilly | June 2015 Nesting SASS .parent {
 blockquote, p {
 font-family: Times;
 }
 a {
 color: teal;
 }
 span {
 background: yellow;
 }
 } CSS .parent blockquote, 
 .parent p {
 font-family: Times;
 }
 .parent a {
 color: teal;
 }
 .parent span {
 background: yellow;
 }
  • 11. @mlteal | #WCPhilly | June 2015 Nesting a {
 color: teal;
 &.special {
 color: gold;
 }
 &:hover, 
 &:active {
 font-style: italic;
 }
 } a {
 color: teal;
 }
 a.special {
 color: gold;
 }
 a:hover, 
 a:active {
 font-style: italic;
 }
  • 12. @mlteal | #WCPhilly | June 2015 Variables $variable-name : /* variable properties here */; Think colors (hex values or rgba), fonts, sizes, or even previously defined vars: $fuchsia : #f0f; $border-style : 1px solid $fuchsia; $heading-size : 30px; $subheading-size : $heading-size / 2;
  • 13. @mlteal | #WCPhilly | June 2015 Variables 1. Define your color palette just this one time 
 $white : #FFFFFF;
 $teal : #27ba9a;
 $french-blue : #3196da;
 $purple : #9a58b5;
 $light-grey : #7e8c8d; 2. Abstract it in case all headings change from $purple to $teal someday $heading : $purple;
 $sub-heading : $white;
 $body-text : $light-grey;
 $link : $french-blue;
 $accent : $teal;
  • 14. @mlteal | #WCPhilly | June 2015 Mixins add candy to your code
  • 15. @mlteal | #WCPhilly | June 2015 Mixins Create reusable chunks of CSS @mixin border-radius($radius) { -moz-border-radius: $radius; -webkit-border-radius: $radius; border-radius: $radius; } .container { @include border-radius(18px); } .footer { @include border-radius(6px); } .container { -moz-border-radius: 18px; -webkit-border-radius: 18px; border-radius: 18px; } .footer { -moz-border-radius: 6px; -webkit-border-radius: 6px; border-radius: 6px; }
  • 16. @mlteal | #WCPhilly | June 2015 Functions Create reusable logic @function remy($pxsize) { @return: ($pxsize / 16 )+rem; } .container { font-size: remy(32); } .container { font-size: 2rem; } Ref: http://sass-lang.com/documentation/Sass/Script/Functions.html
  • 17. @mlteal | #WCPhilly | June 2015 Putting it all together Combining map-get() function with array maps $iconfont-map : ( arrow: "f063", caret-down: “f0d7", wordpress: “f19a", ); @mixin icon( $icon ) { font-family: “Icon Font”; content: '#{map-get( $iconfont-map, $icon )}'; } .my-list a { &:before { @include icon( arrow ); } }
  • 18. @mlteal | #WCPhilly | June 2015 Sass Frameworks Utilize libraries & extensions with Sass to get an even more powerful preprocessor. Many make built-in functions available like transform() or include their own grid systems. • Compass • Breakpoint • Susy • Bourbon • Bootstrap
  • 19. @mlteal | #WCPhilly | June 2015 Test Drive in a Project Plugins: Jetpack Custom CSS module: for adding custom CSS directly on site Admin Color Schemes: https://wordpress.org/plugins/ admin-color-schemes/
  • 20. @mlteal | #WCPhilly | June 2015 Test Drive in a Project Starter Themes: Underscores: http://underscores.me/ Bones (need Compass): http://themble.com/bones/ Foundation: http://foundationpress.olefredrik.com/ Roots (now Sage): https://roots.io/sage/ Some Like it Neat: http://somelikeitneat.com/
  • 21. @mlteal | #WCPhilly | June 2015 Workflows Utilize task-based build tools (either Grunt or Gulp) to watch and compile all the things. Config files make life easier, and actively watch more than just your stylesheets (think minifying JS and more)
  • 22. @mlteal | #WCPhilly | June 2015 Future & Performance Ruby Sass - The original Sass we know & love
 - Simple installation
 - Lots of compatible frameworks
 - Compiling can get slow on larger projects LibSass - A C/C++ port of Sass
 - Just a Sass library, so it needs a wrapper
 - Not 100% caught up to Ruby Sass (but so close!)
 - Stricter on syntax
 - Much faster (up to 4000x)!
  • 23. @mlteal | #WCPhilly | June 2015 Resources Sass Documentation: 
 http://sass-lang.com/documentation/file.SASS_REFERENCE.html Codepen: http://codepen.io
 Sassmeister: http://sassmeister.com Underscores: http://underscores.me
 Bones: http://themble.com/bones/ Ruby Sass vs LibSass: http://sassbreak.com/ruby-sass-libsass-differences/
 Sass Compatibility Guide: http://sass-compatibility.github.io/