why should you use sass in your project?

20
Why use SASS? Time for a CSS compiler has come! 1

Upload: vo-tho

Post on 26-Dec-2014

351 views

Category:

Technology


2 download

DESCRIPTION

My research about SASS and Compass. In this presentation I will tell you why you should use it. You can download my demo file here: http://goo.gl/r3WoCF I like the feedback, so please tell me what you think about this presentation. Every idea is welcome. If you encounter any issues with the demo, tell me too, I will try to help you on the way to love SASS ^^

TRANSCRIPT

Page 1: Why should you use SASS in your project?

1

Why use SASS?

Time for a CSS compiler has come!

Page 2: Why should you use SASS in your project?

2

Table of contents• CSS cons and pros• SASS brings the powers to CSS• Demos• FAQs• References• Q/A

Page 3: Why should you use SASS in your project?

3

CSS cons and pros• The advantages of using CSS include:

1. More precise formatting2. Separation of HTML content from appearance3. Saves time, easier site maintenance4. Web accessibility

• Some disadvantages to using CSS:1. Inconsistent browser support2. Not for long term use3. Hard expandability4. Making changes is not easy

Page 4: Why should you use SASS in your project?

4

THE DRY PRINCIPLEEvery piece of knowledge must have a single, unambiguous,

authoritative representation within a system.

Repeat code is everywhere(color, font family, padding…)

What happen if client want to change to a new font family or a

new color?

Page 5: Why should you use SASS in your project?

5

Powers of SASSCSS on its own can be fun, but stylesheets are getting larger, more complex, and harder to maintain. This is where a preprocessor can

help. 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.

Variables

Nesting

Mixins

Partials/Import

Inheritance

Operators

Functions

Controls

Page 6: Why should you use SASS in your project?

6

VariablesThink of variables as a way to store information that you

want to reuse throughout your stylesheet

Client wants to change font across

the site

Change the value only in one place and the other

updates accordingly

Page 7: Why should you use SASS in your project?

7

NestingSass will let you nest your CSS selectors in a way that follows the same

visual hierarchy of your HTML

HTML SCSS CSS

You don’t need to repeat the parent element each time you code style for a child element. Nesting brings to you a visual view of your

stylesheet, it means more control…

Page 8: Why should you use SASS in your project?

8

Partials/ImportPartial Sass file(file named with a leading underscore) that contain little snippets of CSS modularize your CSS and help keep things

easier to maintain.Sass partials are used with the @import directive

_variables.scss

_mixin.scss

main.scss

Page 9: Why should you use SASS in your project?

9

Mixins 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. 

Mixin Call mixin with a varibale

CSS output

They do look a lot like functions of course. But

since Sass actually has real functions in the language it’s probably best to dispel

this notion. 

Page 10: Why should you use SASS in your project?

10

Extend/InheritanceUsing @extend lets you share a set of CSS properties from one

selector to another. It helps keep your Sass very DRY.

.btn works as core button

.btn—blue and .btn-shadow inherits from .btn and adds

its own properties

Page 11: Why should you use SASS in your project?

11

OperatorsSassScript supports the standard arithmetic operations on numbers

(addition +, subtraction -, multiplication *, division /, and modulo %), and will automatically convert between units if it can

Numeric operations

compile to

Page 12: Why should you use SASS in your project?

12

Operators(cont)All arithmetic operations are supported for color values, where they

work piecewise

Color operations

Page 13: Why should you use SASS in your project?

13

Operators(cont)The + operation can be used to concatenate strings

String operations

use with variable

Page 14: Why should you use SASS in your project?

14

ControlsSassScript supports basic control directives for including styles only under some conditions or including the same style several times with

variations

@if ,@else if and @else

@while @for @each

Demo

Page 15: Why should you use SASS in your project?

15

FunctionA function is very similar to a mixin, however function always return a

value

MixinFunctio

n

Functions help you write more readable and DRY Sass by letting you move your reusable logic out of specific declarations and

even out of your mixins

Page 16: Why should you use SASS in your project?

16

CompassAs if SASS isn't awesome enough on it's own, Compass comes

with an extra set of awesomeness. 

Page 17: Why should you use SASS in your project?

17

FAQs? Do I need to know Ruby or advanced command-

line?? Will I need to completely change the way I’ve

been writing stylesheets? ? Will the CSS it outputs be bloated and

unreadable?

The answer is nope

Page 18: Why should you use SASS in your project?

18

Demos

Page 20: Why should you use SASS in your project?

20

Thank you for your attention!