SlideShare ist ein Scribd-Unternehmen logo
1 von 75
Downloaden Sie, um offline zu lesen
Sassive Aggressive
Using Sass to make your life easier
Who?
Joel Oliveira          Adam Darowski
 Developer, The47th     Web Developer, PatientsLikeMe
What is this “Sass”?

• CSS on steroids.
• Variables, Mixins, Nesting,
  Inheritance, and more…

• Two “flavors” - SASS & SCSS
Compiling?
$ sass --watch ./sass/:./css/
# all .sass files compiled into ./css

$ sass --update 
sass/style.sass:css/style.css
# ... style.sass => style.css
Compiling?
... on the what?
      blech...
Compiling?
... on the what?
      blech...
Why?
Why?
• Vendor Prefixes
• “DRY” - Don’t Repeat Yourself
• Instant Compression / Minification
• Organization - partials (“includes”)
• It’s the future - Chrome team
  already exploring these concepts.
Compress / Minify
~/sites/designsponge joel $ ls -hal style.css
-rw-r--r-- 1 joel staff      32K Mar 18 11:26 style.css

~/sites/designsponge joel $ cp style.css style.scss

~/sites/designsponge joel $ sass -t compressed style.scss
style_compressed.css

~/sites/designsponge joel $ ls -hal *.*css
-rw-r--r-- 1 joel staff      32K Mar 18 11:26 style.css
-rw-r--r-- 1 joel staff      32K Mar 18 11:33 style.scss
-rw-r--r-- 1 joel staff      26K Mar 18 11:34 style_compressed.css
Compress / Minify
The Goods
CSS3 Mix-ins
.foo {
  -moz-border-radius: 10px;
  -webkit-border-radius: 10px;
  border-radius: 10px;
}
  -moz-border-radius: 10px;
  -webkit-border-radius: 10px;
  border-radius: 10px;
}

.bar {
  property: value;
  -moz-border-radius: 10px;
  -webkit-border-radius: 10px;
  border-radius: 10px;
}

.dude {
  property: value;
  property: value;
  -moz-border-radius: 10px;
  -webkit-border-radius: 10px;
  border-radius: 10px;
}

.guy {
  property: value;
  -moz-border-radius: 10px;
When using Sass…

.foo
  +border_radius(10px)


Will render as:
.foo {
  -moz-border-radius: 10px;
  -webkit-border-radius: 10px;
  border-radius: 10px;
}
The mixin:



@mixin border_radius($radius)
  -moz-border-radius: #{$radius}
  -webkit-border-radius: #{$radius}
  border-radius: #{$radius}
Another example:

.foo
  +box_shadow(0, 0, 5, #AAA)


Will render as:
.foo {
  -moz-box-shadow: 0 0 5px #AAA;
  -webkit-box-shadow: 0 0 5px #AAA;
  box-shadow: 0 0 5px #AAA;
}
Or, pre-populate the mixin:


   @mixin box_shadow($h_offset: 0, $v_offset: 0,
   -->$blur_radius: 5, $color: #AAA)
     -moz-box-shadow: #{$h_offset}px #{$v_offset}px
     -->#{$blur_radius}px #{$color}
     -webkit-box-shadow: #{$h_offset}px #{$v_offset}px
     -->#{$blur_radius}px #{$color}
     box-shadow: #{$h_offset}px #{$v_offset}px
     -->#{$blur_radius}px #{$color}




--> Denotes “not a real line break”
Now, no argument is needed:

.foo
  +box_shadow

Will render as:
.foo {
  -moz-box-shadow: 0 0 5px #AAA;
  -webkit-box-shadow: 0 0 5px #AAA;
  box-shadow: 0 0 5px #AAA;
}
Or, you can override:

.foo
  +box_shadow(2, 2, 10, #CCC)

Will render as:
.foo {
  -moz-box-shadow: 2px 2px 10px #CCC;
  -webkit-box-shadow: 2px 2px 10px #CCC;
  box-shadow: 2px 2px 10px #CCC;
}
Gradients!
   .foo
     +box_gradient(#FFFFFF, #000000)

   Will render as:
   .foo {
     background-image: -moz-linear-gradient(top, #FFFFFF,
     -->#000000)
     background-image: -o-linear-gradient(top, #FFFFFF,
     -->#000000);
     background-image: -webkit-gradient(linear,left top,left
     --> bottom,color-stop(0, #FFFFFF),color-stop(1, #000000))
     background-image: -webkit-linear-gradient(#FFFFFF,
     -->#000000)
     background-image: linear-gradient(top, #FFFFFF, #000000)
     filter: progid:DXImageTransform.Microsoft.gradient
     -->(startColorStr='#FFFFFF', EndColorStr='#000000')
   }

--> Denotes “not a real line break”         http://css3please.com/
The mixin:

  @mixin box_gradient($start,$end)
    background-image: -moz-linear-gradient(top, #{!start},
    -->#{!end})
    background-image: -o-linear-gradient(top, #FFFFFF,
    -->#000000);
    background-image: -webkit-gradient(linear,left top,left
    --> bottom,color-stop(0, #{!start}),color-stop(1,
    -->#{!end}))
    background-image: -webkit-linear-gradient(#{!start},
    -->#{!end})
    background-image: linear-gradient(top, #{!start}, #{!end})
    filter: progid:DXImageTransform.Microsoft.gradient
    -->(startColorStr='#{!start}', EndColorStr='#{!end}')




--> Denotes “not a real line break”
http://tech.patientslikeme.com/2010/09/10/deconstructing-my-favorite-sass-mixin/
.dropdown-inner {
  -moz-border-radius: 0 3px 3px 3px;
  -webkit-border-radius: 0 3px 3px 3px;
  border-radius: 0 3px 3px 3px;
  -moz-box-shadow: 1px 1px 4px #CCC;
  -webkit-box-shadow: 1px 1px 4px #CCC;
  box-shadow: 1px 1px 4px #CCC;
  background-image: -moz-linear-gradient(top, #FFFFFF,
  -->#FCF5DE)
  background-image: -o-linear-gradient(top, #FFFFFF,
  -->#000000);
  background-image: -webkit-gradient(linear,left top,left
  --> bottom,color-stop(0, #FFFFFF),color-stop(1, #FCF5DE))
  background-image: -webkit-linear-gradient(#FFFFFF,
  -->#FCF5DE)
  background-image: linear-gradient(top, #FFFFFF, #FCF5DE)
  filter: progid:DXImageTransform.Microsoft.gradient
  -->(startColorStr='#FFFFFF', EndColorStr='#FCF5DE')
}
.dropdown-inner {
  +border_radius(0 3px 3px 3px
  -moz-border-radius: 03px 3px) 3px;
  +box_shadow(1, 1, 4, #CCC)
  -webkit-border-radius: 0 3px 3px 3px;
  border-radius: 0 3px 3px 3px;
  +box_gradient(#FFFFFF, #FCF5DE)
  -moz-box-shadow: 1px 1px 4px #CCC;
  -webkit-box-shadow: 1px 1px 4px #CCC;
  box-shadow: 1px 1px 4px #CCC;
  background-image: -moz-linear-gradient(top, #FFFFFF,
  -->#FCF5DE)
  background-image: -o-linear-gradient(top, #FFFFFF,
  -->#000000);
  background-image: -webkit-gradient(linear,left top,left
  --> bottom,color-stop(0, #FFFFFF),color-stop(1, #FCF5DE))
  background-image: -webkit-linear-gradient(#FFFFFF,
  -->#FCF5DE)
  background-image: linear-gradient(top, #FFFFFF, #FCF5DE)
  filter: progid:DXImageTransform.Microsoft.gradient
  -->(startColorStr='#FFFFFF', EndColorStr='#FCF5DE')
}
More with mixins:


• Re-usable interface elements (buttons,
  headers—with or without arguments).

• Reset styles (data tables, lists, etc.).
• References to frequently-accessed sprites.
• Frequently used IE hacks.
• Etc.
Organization &
 Refactoring
“.Class Soup”
Math
Color Manipulation:



.gray
  background-color: fade_out(#000, 0.4)


Will render as:
.gray {
  background-color: rgba(0, 0, 0, 0.6);
}
lighten & darken:



.lighter
  background-color: lighten(#000064, 30%)


Will render as:
.lighter {
  background-color: #4B4BFF;
}
With a variable:


$default_color: #000064
.level1
  background-color: $default_color
.level2
  background-color: lighten($default_color,   15%)
.level3
  background-color: lighten($default_color,   30%)
.level4
  background-color: lighten($default_color,   45%)
.level5
  background-color: lighten($default_color,   60%)
With a variable:


.level1 {
  background-color:   #000064; }
.level2 {
  background-color:   #0000b1; }
.level3 {
  background-color:   #0000fd; }
.level4 {
  background-color:   #4b4bff; }
.level5 {
  background-color:   #9797ff; }
Simple math:

$container_width: 1000px
$photo_width: 480px
.caption
  width: $container_width - $photo_width

Will render as:
.caption {
  width: 520px;
}
https://github.com/adarowski/The-Hall-of-wWAR
<ul id="timeline-in">
  <li id="dwhite" class="3b level5">White</li>
  <li id="canson" class="1b hof level2">Anson</li>
  <li id="jorourke" class="hof lf level4">O'Rourke</li>
  <li id="pgalvin" class="p hof level2">Galvin</li>
  <li id="mward" class="hof ss level5">Ward</li>
  <li id="jmccormick" class="p level3">McCormick</li>
  <li id="kkelly" class="hof rf level5">Kelly</li>
  <li id="ggore" class="cf level5">Gore</li>
  <li id="jglasscock" class="ss level4">Glasscock</li>
  ...
  <li id="jbagwell" class="1b level2"></li>
</ul>
ul
  list-style: none
  padding: 40px 0 0
  margin: 0
li
  cursor: pointer
  margin: 0 0 5px
  padding: 0
  display: block
  padding: 2px
  color: white
  position: relative
We need
padding-left
 and width.
The mixin:



@mixin bar($start,$end)
  $start_value: $start - 1870
  margin-left: ($start_value*8) + px
  $length: $end - $start
  width: ($length*8) - 4px
The mixin:



@mixin bar($start,$end)
  $start_value: $start - 1870             Pass in
  margin-left: ($start_value*8) + px   arguments for
                                       start and end
  $length: $end - $start
                                            year.
  width: ($length*8) - 4px
The mixin:



@mixin bar($start,$end)
                                       $start_value is
  $start_value: $start - 1870
                                       the difference
  margin-left: ($start_value*8) + px    between the
  $length: $end - $start               start year and
  width: ($length*8) - 4px                 1870.
The mixin:



@mixin bar($start,$end)
  $start_value: $start - 1870               Multiply
                                        $start_value by
  margin-left: ($start_value*8) + px
                                       8 to get the left-
  $length: $end - $start               margin (8 pixels
  width: ($length*8) - 4px                 per year).
The mixin:



@mixin bar($start,$end)
  $start_value: $start - 1870          Career $length
                                       will be used to
  margin-left: ($start_value*8) + px
                                       determine the
  $length: $end - $start                width of the
  width: ($length*8) - 4px                   box.
The mixin:



@mixin bar($start,$end)
  $start_value: $start - 1870           Again, multiply
  margin-left: ($start_value*8) + px    by 8 to get the
                                        width, and also
  $length: $end - $start
                                       subtract 4 pixels
  width: ($length*8) - 4px                (padding).
The magic:

#jbagwell
  +bar(1991, 2005)


@mixin bar(1991,2005)
  $start_value: 1991 -   1870 = 121
  margin-left: (121*8)   + px = 968px
  $length: 2005 - 1991   = 14
  width: (14*8) - 4px)   = 108px
The magic:

#jbagwell
  +bar(1991, 2005)


Will render as:
#jbagwell {
  margin-left: 968px;
  width: 108px;
}
margin-left: 16px;
            width: 164px; }
          #pgalvin {

Repeat:     margin-left: 40px;
            width: 132px; }
          #kkelly {
            margin-left: 64px;
            width: 116px; }
          #mward {
            margin-left: 64px;
            width: 124px; }
          #dbrouthers {
            margin-left: 72px;
            width: 196px; }
          #mwelch {
            margin-left: 80px;
            width: 92px; }
          #tkeefe {
            margin-left: 80px;
            width: 100px; }
          #rconnor {
            margin-left: 80px;
            width: 132px; }
          #bewing {
            margin-left: 80px;
            width: 132px; }
          #cradbourn {
            margin-left: 88px;
            width: 76px; }
          #jclarkson {
            margin-left: 96px;
            width: 92px; }
          #bmcphee {
            margin-left: 96px;
            width: 132px; }
          #tmccarthy {
            margin-left: 112px;
            width: 92px; }
https://github.com/adarowski/The-Hall-of-wWAR
Wrapping Up
Installation
$ sudo gem install haml

c:> ruby gem install haml
Resources
• sass-lang.com
• beta.compass-style.org
• @sasswatch
• wiseheartdesign.com/weblog/
• rubyinstaller.org (windows)
• github.com/adarowski
• github.com/jayroh
Joel @jayroh

Adam @adarowski
Questions?

Weitere ähnliche Inhalte

Was ist angesagt?

Advanced Technology for Web Application Design
Advanced Technology for Web Application DesignAdvanced Technology for Web Application Design
Advanced Technology for Web Application Design
Bryce Kerley
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHP
Jeremy Kendall
 

Was ist angesagt? (20)

CSS Extenders
CSS ExtendersCSS Extenders
CSS Extenders
 
Taking Perl to Eleven with Higher-Order Functions
Taking Perl to Eleven with Higher-Order FunctionsTaking Perl to Eleven with Higher-Order Functions
Taking Perl to Eleven with Higher-Order Functions
 
Sass - Making CSS fun again.
Sass - Making CSS fun again.Sass - Making CSS fun again.
Sass - Making CSS fun again.
 
CSS: A Slippery Slope to the Backend
CSS: A Slippery Slope to the BackendCSS: A Slippery Slope to the Backend
CSS: A Slippery Slope to the Backend
 
HTML5 and CSS3 Refresher
HTML5 and CSS3 RefresherHTML5 and CSS3 Refresher
HTML5 and CSS3 Refresher
 
McrFRED 39 | CSS Processors
McrFRED 39 | CSS ProcessorsMcrFRED 39 | CSS Processors
McrFRED 39 | CSS Processors
 
Finding your way with Sass+Compass
Finding your way with Sass+CompassFinding your way with Sass+Compass
Finding your way with Sass+Compass
 
CSS3 Refresher
CSS3 RefresherCSS3 Refresher
CSS3 Refresher
 
Fields in Core: How to create a custom field
Fields in Core: How to create a custom fieldFields in Core: How to create a custom field
Fields in Core: How to create a custom field
 
Advanced Technology for Web Application Design
Advanced Technology for Web Application DesignAdvanced Technology for Web Application Design
Advanced Technology for Web Application Design
 
Web Application Development using PHP Chapter 4
Web Application Development using PHP Chapter 4Web Application Development using PHP Chapter 4
Web Application Development using PHP Chapter 4
 
WordCamp Bristol 2019 - WordPress custom theme building
WordCamp Bristol 2019 - WordPress custom theme buildingWordCamp Bristol 2019 - WordPress custom theme building
WordCamp Bristol 2019 - WordPress custom theme building
 
Confoo: You can use CSS for that!
Confoo: You can use CSS for that!Confoo: You can use CSS for that!
Confoo: You can use CSS for that!
 
Functional pe(a)rls: Huey's zipper
Functional pe(a)rls: Huey's zipperFunctional pe(a)rls: Huey's zipper
Functional pe(a)rls: Huey's zipper
 
Steven Kingston - OS open data – visualisation and gazetteer searching with q...
Steven Kingston - OS open data – visualisation and gazetteer searching with q...Steven Kingston - OS open data – visualisation and gazetteer searching with q...
Steven Kingston - OS open data – visualisation and gazetteer searching with q...
 
Jina Bolton
Jina BoltonJina Bolton
Jina Bolton
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHP
 
Ruby on Rails 3.1: Let's bring the fun back into web programing
Ruby on Rails 3.1: Let's bring the fun back into web programingRuby on Rails 3.1: Let's bring the fun back into web programing
Ruby on Rails 3.1: Let's bring the fun back into web programing
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHP
 
Php 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the GoodPhp 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the Good
 

Andere mochten auch

Sassive Aggressive: Level Up Your CSS with Sass
Sassive Aggressive: Level Up Your CSS with Sass Sassive Aggressive: Level Up Your CSS with Sass
Sassive Aggressive: Level Up Your CSS with Sass
Adam Darowski
 

Andere mochten auch (6)

Sassive Aggressive: Level Up Your CSS with Sass
Sassive Aggressive: Level Up Your CSS with Sass Sassive Aggressive: Level Up Your CSS with Sass
Sassive Aggressive: Level Up Your CSS with Sass
 
The Hall of Stats
The Hall of StatsThe Hall of Stats
The Hall of Stats
 
Liiikes: Using statistics to find the best content on Dribbble.
Liiikes: Using statistics to find the best content on Dribbble.Liiikes: Using statistics to find the best content on Dribbble.
Liiikes: Using statistics to find the best content on Dribbble.
 
Javascript status 2016
Javascript status 2016Javascript status 2016
Javascript status 2016
 
Sassive Aggressive: Level Up Your CSS with Sass
Sassive Aggressive: Level Up Your CSS with Sass Sassive Aggressive: Level Up Your CSS with Sass
Sassive Aggressive: Level Up Your CSS with Sass
 
Sassive Aggressive: Using Sass to Make Your Life Easier (NSWG Version)
Sassive Aggressive: Using Sass to Make Your Life Easier (NSWG Version)Sassive Aggressive: Using Sass to Make Your Life Easier (NSWG Version)
Sassive Aggressive: Using Sass to Make Your Life Easier (NSWG Version)
 

Ähnlich wie Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)

Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3
Wynn Netherland
 
Software programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS filesSoftware programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS files
Dinu Suman
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction Sass
Zeeshan Ahmed
 
Patrick Kettner - Creating magic with houdini
Patrick Kettner - Creating magic with houdiniPatrick Kettner - Creating magic with houdini
Patrick Kettner - Creating magic with houdini
OdessaJS Conf
 
Sass, Compass and the new tools - Open Web Camp IV
Sass, Compass and the new tools - Open Web Camp IVSass, Compass and the new tools - Open Web Camp IV
Sass, Compass and the new tools - Open Web Camp IV
Dirk Ginader
 
Sass and Compass - Getting Started
Sass and Compass - Getting StartedSass and Compass - Getting Started
Sass and Compass - Getting Started
edgincvg
 

Ähnlich wie Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version) (20)

Wrangling the CSS Beast with Sass
Wrangling the CSS Beast  with SassWrangling the CSS Beast  with Sass
Wrangling the CSS Beast with Sass
 
Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)
 
Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3
 
Preprocessor presentation
Preprocessor presentationPreprocessor presentation
Preprocessor presentation
 
Work and play with SASS & Compass
Work and play with SASS & CompassWork and play with SASS & Compass
Work and play with SASS & Compass
 
Getting Started with Sass & Compass
Getting Started with Sass & CompassGetting Started with Sass & Compass
Getting Started with Sass & Compass
 
Workshop 6: Designer tools
Workshop 6: Designer toolsWorkshop 6: Designer tools
Workshop 6: Designer tools
 
Using Sass - Building on CSS
Using Sass - Building on CSSUsing Sass - Building on CSS
Using Sass - Building on CSS
 
Sass&compass
Sass&compassSass&compass
Sass&compass
 
Sencha Touch
Sencha TouchSencha Touch
Sencha Touch
 
Software programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS filesSoftware programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS files
 
LESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageLESS : The dynamic stylesheet language
LESS : The dynamic stylesheet language
 
Learn to Love CSS3 [English]
Learn to Love CSS3 [English]Learn to Love CSS3 [English]
Learn to Love CSS3 [English]
 
Learn to love CSS3 | Joomla! Day Deutschland
Learn to love CSS3 | Joomla! Day DeutschlandLearn to love CSS3 | Joomla! Day Deutschland
Learn to love CSS3 | Joomla! Day Deutschland
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction Sass
 
Patrick Kettner - Creating magic with houdini
Patrick Kettner - Creating magic with houdiniPatrick Kettner - Creating magic with houdini
Patrick Kettner - Creating magic with houdini
 
Sass, Compass and the new tools - Open Web Camp IV
Sass, Compass and the new tools - Open Web Camp IVSass, Compass and the new tools - Open Web Camp IV
Sass, Compass and the new tools - Open Web Camp IV
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With Less
 
Sass and Compass - Getting Started
Sass and Compass - Getting StartedSass and Compass - Getting Started
Sass and Compass - Getting Started
 
LessCSS Presentation @ April 2015 GTALUG Meeting
LessCSS Presentation @ April 2015 GTALUG MeetingLessCSS Presentation @ April 2015 GTALUG Meeting
LessCSS Presentation @ April 2015 GTALUG Meeting
 

Kürzlich hochgeladen

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
giselly40
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
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
 
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
 
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
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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
 

Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)

  • 1. Sassive Aggressive Using Sass to make your life easier
  • 2. Who? Joel Oliveira Adam Darowski Developer, The47th Web Developer, PatientsLikeMe
  • 3. What is this “Sass”? • CSS on steroids. • Variables, Mixins, Nesting, Inheritance, and more… • Two “flavors” - SASS & SCSS
  • 4.
  • 5.
  • 6. Compiling? $ sass --watch ./sass/:./css/ # all .sass files compiled into ./css $ sass --update sass/style.sass:css/style.css # ... style.sass => style.css
  • 7. Compiling? ... on the what? blech...
  • 8. Compiling? ... on the what? blech...
  • 10.
  • 11.
  • 12.
  • 13.
  • 14. Why? • Vendor Prefixes • “DRY” - Don’t Repeat Yourself • Instant Compression / Minification • Organization - partials (“includes”) • It’s the future - Chrome team already exploring these concepts.
  • 15. Compress / Minify ~/sites/designsponge joel $ ls -hal style.css -rw-r--r-- 1 joel staff 32K Mar 18 11:26 style.css ~/sites/designsponge joel $ cp style.css style.scss ~/sites/designsponge joel $ sass -t compressed style.scss style_compressed.css ~/sites/designsponge joel $ ls -hal *.*css -rw-r--r-- 1 joel staff 32K Mar 18 11:26 style.css -rw-r--r-- 1 joel staff 32K Mar 18 11:33 style.scss -rw-r--r-- 1 joel staff 26K Mar 18 11:34 style_compressed.css
  • 17.
  • 19.
  • 20.
  • 21.
  • 22.
  • 25.   -moz-border-radius: 10px;   -webkit-border-radius: 10px;   border-radius: 10px; } .bar {   property: value;   -moz-border-radius: 10px;   -webkit-border-radius: 10px;   border-radius: 10px; } .dude {   property: value;   property: value;   -moz-border-radius: 10px;   -webkit-border-radius: 10px;   border-radius: 10px; } .guy {   property: value;   -moz-border-radius: 10px;
  • 26. When using Sass… .foo   +border_radius(10px) Will render as: .foo {   -moz-border-radius: 10px;   -webkit-border-radius: 10px;   border-radius: 10px; }
  • 27. The mixin: @mixin border_radius($radius)   -moz-border-radius: #{$radius}   -webkit-border-radius: #{$radius}   border-radius: #{$radius}
  • 28. Another example: .foo   +box_shadow(0, 0, 5, #AAA) Will render as: .foo {   -moz-box-shadow: 0 0 5px #AAA;   -webkit-box-shadow: 0 0 5px #AAA;   box-shadow: 0 0 5px #AAA; }
  • 29. Or, pre-populate the mixin: @mixin box_shadow($h_offset: 0, $v_offset: 0, -->$blur_radius: 5, $color: #AAA)   -moz-box-shadow: #{$h_offset}px #{$v_offset}px -->#{$blur_radius}px #{$color}   -webkit-box-shadow: #{$h_offset}px #{$v_offset}px -->#{$blur_radius}px #{$color}   box-shadow: #{$h_offset}px #{$v_offset}px -->#{$blur_radius}px #{$color} --> Denotes “not a real line break”
  • 30. Now, no argument is needed: .foo   +box_shadow Will render as: .foo {   -moz-box-shadow: 0 0 5px #AAA;   -webkit-box-shadow: 0 0 5px #AAA;   box-shadow: 0 0 5px #AAA; }
  • 31. Or, you can override: .foo   +box_shadow(2, 2, 10, #CCC) Will render as: .foo {   -moz-box-shadow: 2px 2px 10px #CCC;   -webkit-box-shadow: 2px 2px 10px #CCC;   box-shadow: 2px 2px 10px #CCC; }
  • 32. Gradients! .foo   +box_gradient(#FFFFFF, #000000) Will render as: .foo {   background-image: -moz-linear-gradient(top, #FFFFFF, -->#000000) background-image: -o-linear-gradient(top, #FFFFFF, -->#000000);   background-image: -webkit-gradient(linear,left top,left --> bottom,color-stop(0, #FFFFFF),color-stop(1, #000000))   background-image: -webkit-linear-gradient(#FFFFFF, -->#000000)   background-image: linear-gradient(top, #FFFFFF, #000000)   filter: progid:DXImageTransform.Microsoft.gradient -->(startColorStr='#FFFFFF', EndColorStr='#000000') } --> Denotes “not a real line break” http://css3please.com/
  • 33. The mixin: @mixin box_gradient($start,$end)   background-image: -moz-linear-gradient(top, #{!start}, -->#{!end}) background-image: -o-linear-gradient(top, #FFFFFF, -->#000000);   background-image: -webkit-gradient(linear,left top,left --> bottom,color-stop(0, #{!start}),color-stop(1, -->#{!end}))   background-image: -webkit-linear-gradient(#{!start}, -->#{!end})   background-image: linear-gradient(top, #{!start}, #{!end})   filter: progid:DXImageTransform.Microsoft.gradient -->(startColorStr='#{!start}', EndColorStr='#{!end}') --> Denotes “not a real line break”
  • 35. .dropdown-inner {   -moz-border-radius: 0 3px 3px 3px;   -webkit-border-radius: 0 3px 3px 3px;   border-radius: 0 3px 3px 3px;   -moz-box-shadow: 1px 1px 4px #CCC;   -webkit-box-shadow: 1px 1px 4px #CCC;   box-shadow: 1px 1px 4px #CCC;   background-image: -moz-linear-gradient(top, #FFFFFF, -->#FCF5DE) background-image: -o-linear-gradient(top, #FFFFFF, -->#000000);   background-image: -webkit-gradient(linear,left top,left --> bottom,color-stop(0, #FFFFFF),color-stop(1, #FCF5DE))   background-image: -webkit-linear-gradient(#FFFFFF, -->#FCF5DE)   background-image: linear-gradient(top, #FFFFFF, #FCF5DE)   filter: progid:DXImageTransform.Microsoft.gradient -->(startColorStr='#FFFFFF', EndColorStr='#FCF5DE') }
  • 36. .dropdown-inner {   +border_radius(0 3px 3px 3px   -moz-border-radius: 03px 3px) 3px;   +box_shadow(1, 1, 4, #CCC)   -webkit-border-radius: 0 3px 3px 3px;   border-radius: 0 3px 3px 3px; +box_gradient(#FFFFFF, #FCF5DE)   -moz-box-shadow: 1px 1px 4px #CCC;   -webkit-box-shadow: 1px 1px 4px #CCC;   box-shadow: 1px 1px 4px #CCC;   background-image: -moz-linear-gradient(top, #FFFFFF, -->#FCF5DE) background-image: -o-linear-gradient(top, #FFFFFF, -->#000000);   background-image: -webkit-gradient(linear,left top,left --> bottom,color-stop(0, #FFFFFF),color-stop(1, #FCF5DE))   background-image: -webkit-linear-gradient(#FFFFFF, -->#FCF5DE)   background-image: linear-gradient(top, #FFFFFF, #FCF5DE)   filter: progid:DXImageTransform.Microsoft.gradient -->(startColorStr='#FFFFFF', EndColorStr='#FCF5DE') }
  • 37. More with mixins: • Re-usable interface elements (buttons, headers—with or without arguments). • Reset styles (data tables, lists, etc.). • References to frequently-accessed sprites. • Frequently used IE hacks. • Etc.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 48.
  • 49.
  • 50.
  • 51. Math
  • 52. Color Manipulation: .gray   background-color: fade_out(#000, 0.4) Will render as: .gray {   background-color: rgba(0, 0, 0, 0.6); }
  • 53. lighten & darken: .lighter   background-color: lighten(#000064, 30%) Will render as: .lighter {   background-color: #4B4BFF; }
  • 54. With a variable: $default_color: #000064 .level1 background-color: $default_color .level2 background-color: lighten($default_color, 15%) .level3 background-color: lighten($default_color, 30%) .level4 background-color: lighten($default_color, 45%) .level5 background-color: lighten($default_color, 60%)
  • 55. With a variable: .level1 { background-color: #000064; } .level2 { background-color: #0000b1; } .level3 { background-color: #0000fd; } .level4 { background-color: #4b4bff; } .level5 { background-color: #9797ff; }
  • 56. Simple math: $container_width: 1000px $photo_width: 480px .caption width: $container_width - $photo_width Will render as: .caption { width: 520px; }
  • 58. <ul id="timeline-in"> <li id="dwhite" class="3b level5">White</li> <li id="canson" class="1b hof level2">Anson</li> <li id="jorourke" class="hof lf level4">O'Rourke</li> <li id="pgalvin" class="p hof level2">Galvin</li> <li id="mward" class="hof ss level5">Ward</li> <li id="jmccormick" class="p level3">McCormick</li> <li id="kkelly" class="hof rf level5">Kelly</li> <li id="ggore" class="cf level5">Gore</li> <li id="jglasscock" class="ss level4">Glasscock</li> ... <li id="jbagwell" class="1b level2"></li> </ul>
  • 59. ul list-style: none padding: 40px 0 0 margin: 0 li cursor: pointer margin: 0 0 5px padding: 0 display: block padding: 2px color: white position: relative
  • 61. The mixin: @mixin bar($start,$end) $start_value: $start - 1870 margin-left: ($start_value*8) + px $length: $end - $start width: ($length*8) - 4px
  • 62. The mixin: @mixin bar($start,$end) $start_value: $start - 1870 Pass in margin-left: ($start_value*8) + px arguments for start and end $length: $end - $start year. width: ($length*8) - 4px
  • 63. The mixin: @mixin bar($start,$end) $start_value is $start_value: $start - 1870 the difference margin-left: ($start_value*8) + px between the $length: $end - $start start year and width: ($length*8) - 4px 1870.
  • 64. The mixin: @mixin bar($start,$end) $start_value: $start - 1870 Multiply $start_value by margin-left: ($start_value*8) + px 8 to get the left- $length: $end - $start margin (8 pixels width: ($length*8) - 4px per year).
  • 65. The mixin: @mixin bar($start,$end) $start_value: $start - 1870 Career $length will be used to margin-left: ($start_value*8) + px determine the $length: $end - $start width of the width: ($length*8) - 4px box.
  • 66. The mixin: @mixin bar($start,$end) $start_value: $start - 1870 Again, multiply margin-left: ($start_value*8) + px by 8 to get the width, and also $length: $end - $start subtract 4 pixels width: ($length*8) - 4px (padding).
  • 67. The magic: #jbagwell +bar(1991, 2005) @mixin bar(1991,2005) $start_value: 1991 - 1870 = 121 margin-left: (121*8) + px = 968px $length: 2005 - 1991 = 14 width: (14*8) - 4px) = 108px
  • 68. The magic: #jbagwell +bar(1991, 2005) Will render as: #jbagwell { margin-left: 968px; width: 108px; }
  • 69. margin-left: 16px; width: 164px; } #pgalvin { Repeat: margin-left: 40px; width: 132px; } #kkelly { margin-left: 64px; width: 116px; } #mward { margin-left: 64px; width: 124px; } #dbrouthers { margin-left: 72px; width: 196px; } #mwelch { margin-left: 80px; width: 92px; } #tkeefe { margin-left: 80px; width: 100px; } #rconnor { margin-left: 80px; width: 132px; } #bewing { margin-left: 80px; width: 132px; } #cradbourn { margin-left: 88px; width: 76px; } #jclarkson { margin-left: 96px; width: 92px; } #bmcphee { margin-left: 96px; width: 132px; } #tmccarthy { margin-left: 112px; width: 92px; }
  • 72. Installation $ sudo gem install haml c:> ruby gem install haml
  • 73. Resources • sass-lang.com • beta.compass-style.org • @sasswatch • wiseheartdesign.com/weblog/ • rubyinstaller.org (windows) • github.com/adarowski • github.com/jayroh