Sass

52
SASS Super awesome stylesheets

description

This is a brief presentation about SASS and Compass, and their basic functionality.

Transcript of Sass

Page 1: Sass

SASS Super awesome stylesheets

Page 2: Sass

Who am I?

Page 3: Sass

Who am I?

#me {

name: ‘Bram Verdyck’;

&:active {

job: ‘Web ninja @ These Days’;

interests: ‘HTML5, CSS3, JS, Fast cars’;

social: ‘@TroTi13’;

}

&:before {

school:’MCT @ KDG’;

}

}

Page 4: Sass

What’s this about? Image source: http://thekingofthevikings.deviantart.com/art/8-Bit-

Question-Box-170241434

Page 5: Sass

What’s this about?

S.A.S.S Syntactically awesome style sheets Super awesome style sheets

Image source: http://sass-lang.com/

Page 6: Sass

What’s wrong with normal style sheets?

Image source: http://webwox.wordpress.com/2011/08/31/history-of-cascading-style-sheetscss/

Page 7: Sass

Nothing really…

Page 8: Sass

CSS is awesome!

Image source: http://www.zazzle.com/css_is_awesome_with_scroll_mug-168224268218561554

Page 9: Sass

CSS let’s you make pretty things

Image source: http://www.onlymotivational.com/pictures/i_feel_pretty.htm

Page 10: Sass

Without it, all websites would look the same

Image source: http://kill.devc.at/node/284

Page 11: Sass

But…

Page 12: Sass

Developing CSS is slow Image source: http://www.tensionnot.com/pictures/Car/Horse-Cart-Car

Page 13: Sass

CSS is

repetitive

Image source: http://www.123rf.com/photo_5880238_windows-shaped-like-space-invaders-on-building-canada-tower-london-exterior.html

Page 14: Sass

CSS is messy

Image source: http://vickybeeching.com/blog/why-are-we-musicians-often-so-messy/messy-office-03/

Page 15: Sass

CSS needs external tools for optimization

Page 16: Sass

CSS isn’t really reusable

Page 17: Sass

WHAT CAN SASS DO FOR US? Most important stuff

Page 18: Sass

Nesting

Page 19: Sass

Be gone repetition Overview Better readability

#nav { float:left; width:100px; a { text-decoration:none; } }

#nav { float:left; width:100px; } #nav a { text-decoration:none; }

Page 20: Sass

Variables - $

Page 21: Sass

Wh00t? Variables in CSS? That’s just awesome!

$link-color:#000; #nav { float:left; width:100px; a { color:$link-color; text-decoration:none; } }

#nav { float:left; width:100px; } #nav a { color:#000; text-decoration:none; }

Page 22: Sass

Maths, calculations

Page 23: Sass

A + B A – B A * B A / B

$width:100px; #nav { height:100px – 2*15; padding:10px 15px; width:$width – 2*10; }

#nav { height:70px; padding:10px 15px; width:80px; }

Page 24: Sass

Lighten($color, amount) darken($color, amount) $color1 + $color2 $color1 - $color2

$color:#000; a { color:$color; &:hover { color:lighten($color, 10); } }

a { color:#000; &:hover { color:#1a1a1a; } }

Page 25: Sass

Mixins - @mixin

Page 26: Sass

Reusable ++ Readability ++ @mixin hover-link($color) { & { color:$color; } &:hover { color:$lighten($color,10); } } a { @include hover-link(#000); }

Page 27: Sass

Import - @import

Page 28: Sass

Multiple files Compiled into 1 Only uses what you want @import ‘path/to/file.scss’;

Page 29: Sass

WHAT CAN SASS DO MORE? There’s more?!

Page 30: Sass

Loops

@for $i from 1 through 3 {} @each $el in h1, h2, h3, h4 {} $i:0; @while $i < 6 { $i: $i + 1 }

Page 31: Sass

Extend - @extend

.link { color:$link-color; &:hover { color:$lighten($color,10); } } a { @extend .link; }

Page 32: Sass

No more double code Less writing

Page 33: Sass

SASS also auto minifies & checks for errors :nested – default :expanded - normal :compact - every selector on 1 line :compressed - no more whitespaces

Page 34: Sass

Awesome right?

Page 35: Sass

HOW TO INSTALL / USE

Page 36: Sass

Easy as pie!

All you need is ruby

Image source: http://www.sw.it.aoyama.ac.jp/2009/pub/IUC33-ruby1.9/

Page 37: Sass

Mmm pie…. Image source: http://www.motivationals.org/demotivational-posters-1/

demotivational-poster-44122.jpg

Page 38: Sass

And 2 lines in terminal…

$ gem install sass $ cd path/to/css $ sass watch style.scss:style.css Or $ cd path/to/css $ sass watch css:css

Page 39: Sass

STOP, HAMMER RECAP TIME!

Page 40: Sass

Recap

•  Nesting •  Variables - $ •  Maths & color functions •  Mixins - @mixin •  Import - @import

Page 41: Sass

AND STILL… THERE’S MORE

Page 42: Sass

COMPASS

Page 43: Sass

Compass <3 CSS 3

Image source: http://desandro.com/work/zui-site-riot/html5css3.png

Page 44: Sass

Loads of predefined & tested mixins

Image source: http://compass-style.org

Page 45: Sass

Blueprint grid system built in & ready to use

Image source: http://www.blueprintcss.org/

Page 46: Sass

Extended maths

pi() sin($number) cos($number) tan($number)

Page 47: Sass

Advanced sprite control

Page 48: Sass

STILL NOT CONVINCED?

Page 49: Sass

Check these links!

•  http://sass-lang.com/ •  http://compass-style.org/ •  http://rubyinstaller.org/ (windows needs ruby installer)

•  https://github.com/thesedays/scss-mixins

Page 50: Sass

And these links!

•  http://www.thesedays.com •  http://labs.thesedays.com

Page 51: Sass

THAT’S ABOUT IT…

Page 52: Sass

DEMO PLZ?!