Slide 1

Slide 1 text

SASS INTRODUCTION Irfan Maulana | Front End Developer

Slide 2

Slide 2 text

About Me • Name : Irfan Maulana • Position : Software Development Engineer • Role : Front End Developer

Slide 3

Slide 3 text

About CSS Pre-Processor • Pre-processors extend CSS with variables, operators, interpolations, functions, mixins and many more other usable assets.

Slide 4

Slide 4 text

Why We Need CSS Pre-Processor • CSS is primitive and incomplete. • Building a function, reusing a definition or inheritance are hard to achieve. • For bigger projects, or complex systems, maintenance is a very big problem.

Slide 5

Slide 5 text

Getting to know SASS • Sass is one of CSS Pre-processor vendor, other popular vendor is LESS and Stylus. • Sass is the most mature, stable, and powerful professional grade CSS extension language in the world. source : http://sass-lang.com/ • Sass lets you use features that don't exist in CSS yet like variables, nesting, mixins, inheritance and other nifty goodies that make writing CSS fun again.

Slide 6

Slide 6 text

SASS Goodness CSS COMPATIBLE Sass is completely compatible with all versions of CSS. We take this compatibility seriously, so that you can seamlessly use any available CSS libraries. FEATURE RICH Sass boasts more features and abilities than any other CSS extension language out there. The Sass Core Team has worked endlessly to not only keep up, but stay ahead. MATURE Sass has been actively supported for over 9 years by its loving Core Team INDUSTRY APPROVED Over and over again, the industry is choosing Sass as the premier CSS extension language. LARGE COMMUNITY Sass is actively supported and developed by a consortium of several tech companies and hundreds of developers. FRAMEWORKS There are endless number of frameworks built with Sass. Compass, Bourbon, and Susy just to name a few.

Slide 7

Slide 7 text

SASS Instalation WITH RUBY Download Ruby : http://rubyinstaller.org/ type : gem install sass http://sass-lang.com/install Or WITH NODEJS Download nodejs https://nodejs.org/en/download/ type : npm install node-sass or you can use built in plugin from build tool like grunt, gulp

Slide 8

Slide 8 text

SASS Syntax SASS have two different syntax, called SASS and SCSS syntax. SASS syntax is the original one that influence by HAML, SASS syntax is very different with native CSS in case of tab sensitive as their approach. SCSS is the rescue for CSS Developer that want to migrate to SASS Way. SCSS has very same syntax with native CSS, so we will use this syntax in our session here. http://thesassway.com/editorial/sass-vs-scss-which-syntax-is-better

Slide 9

Slide 9 text

Lets Deep Dive The SASS Way http://sass-lang.com/guide

Slide 10

Slide 10 text

Variables Think of variables as a way to store information that you want to reuse throughout your stylesheet. You can store things like colors, font stacks, or any CSS value you think you'll want to reuse. Sass uses the $ symbol to make something a variable. Here's an example: Output:

Slide 11

Slide 11 text

Nesting Sass will let you nest your CSS selectors in a way that follows the same visual hierarchy of your HTML. Be aware that overly nested rules will result in over-qualified CSS that could prove hard to maintain and is generally considered bad practice. Here's an example:

Slide 12

Slide 12 text

Nesting – continues… Outpout:

Slide 13

Slide 13 text

Nesting – continues… We can add prefix of parent with & Here an example : Output :

Slide 14

Slide 14 text

Partial and Import SASS support partial file that will merge to one file. For partial file you can add _ (underscore) in front of file. Ex : _reset.scss And for using that partial file you can use @import Example : @import “reset”;

Slide 15

Slide 15 text

Mixins Some things in CSS are a bit tedious to write, especially with CSS3 and the many vendor prefixes that exist. A mixin lets you make groups of CSS declarations that you want to reuse throughout your site. You can even pass in values to make your mixin more flexible. A good use of a mixin is for vendor prefixes. Here an example :

Slide 16

Slide 16 text

Extends/Inheritance This is one of the most useful features of Sass. Using @extend lets you share a set of CSS properties from one selector to another. It helps keep your Sass very DRY. Here an example :

Slide 17

Slide 17 text

Extends/Inheritance – continues Output :

Slide 18

Slide 18 text

Extends/Inheritance – continues We can use placeholder selector that will not produce class to be extended. Here an example : Output :

Slide 19

Slide 19 text

Operators Doing math in your CSS is very helpful. Sass has a handful of standard math operators like +, -, *, /, and %. Here an example :

Slide 20

Slide 20 text

Operators – continues Output :

Slide 21

Slide 21 text

Expressions – @if @else Example : Output :

Slide 22

Slide 22 text

Expressions – @for Example : Output :

Slide 23

Slide 23 text

Expressions – @each Example : Output :

Slide 24

Slide 24 text

Expressions – @while Example : Output :

Slide 25

Slide 25 text

See the code https://github.com/mazipan/awesome-bemcss

Slide 26

Slide 26 text

Contact Me • Facebook : /mazipanneh • Twitter : @mazipan • Linkedin : /in/irfanmaulanamazipan • Slideshare : /IrfanMaulana21 • Github : mazipan • Email : [email protected] • Blog : mazipanneh , mazipan.github.io

Slide 27

Slide 27 text

Reference http://sass-lang.com/documentation/file.SASS_REFERENCE.html

Slide 28

Slide 28 text

THANK YOU