css preprocessing - sass vs less by brady sammons

17
{ CSS Preprocessing } With LESS & Sass By: Brady Sammons bradysammons.com | [email protected] | @soulrider911

Upload: sunbash-sun-basorun

Post on 24-May-2015

472 views

Category:

Technology


1 download

DESCRIPTION

A great presentation by Brady Sammons. Presented at the Tech-in-motion SF july meetup. This presentation was not created or compiled by me. I am just sharing it on behalf of the community.

TRANSCRIPT

Page 1: CSS preprocessing - Sass vs Less by Brady Sammons

{ CSS Preprocessing }With LESS & Sass

By: Brady Sammonsbradysammons.com | [email protected] | @soulrider911

Page 2: CSS preprocessing - Sass vs Less by Brady Sammons

{ Terms }

Page 3: CSS preprocessing - Sass vs Less by Brady Sammons

{Preprocessing}Preprocessing is a method of extending the feature set of CSS by first writing the style sheets in a preprocessed language, then compiling the code to pure CSS syntax that we are all use to.

Page 4: CSS preprocessing - Sass vs Less by Brady Sammons

{ Compile }A compiler is a computer program(s) that transforms source code written in a programming language (the source language) into another computer language (the target language).

Page 5: CSS preprocessing - Sass vs Less by Brady Sammons

{ Sass }Syntactically Awesome Stylesheets - Sass is an extension of CSS, adding nested rules, variables, mixins, operators, selector inheritance, and more. It’s translated to well-formatted, standard CSS using the command line tool or a web-framework plugin. Sass is based in Ruby

Designed by Hampton Catlin developed by Nathan Weizenbaum – 2007

Page 6: CSS preprocessing - Sass vs Less by Brady Sammons

{ LESS }Write less do more - Less language provides the following mechanisms: variables, nesting, mixins, operators and functions; then converted into standard css via javascript or an application. Less is based in javascript.

Designed by Alexis Sellier 2009, was influenced by SASS.

Page 7: CSS preprocessing - Sass vs Less by Brady Sammons

{ How Does it Work? }

Page 8: CSS preprocessing - Sass vs Less by Brady Sammons

{ The Machine }

LESS / SASS Metalanguage Document Ruby / JS Output CSS

MR. COMPILER

Page 9: CSS preprocessing - Sass vs Less by Brady Sammons

{ Who Cares? }

Page 10: CSS preprocessing - Sass vs Less by Brady Sammons

{ A Few Reasons Why }• It Saves time

• This is what CSS should have been to begin with

• Makes your CSS less repetitive (DRY)

• Easier to maintain

• Easier to read

• Make your websites look better

• More fun to code

• Extendable - Compass, LessHat

Page 11: CSS preprocessing - Sass vs Less by Brady Sammons

{ Possible Deterrents }• Change of workflow

• Another syntax to learn

• Rely’s upon a compiler software

• Harder to debug

• Less documentation that CSS alone

• Don’t know how to set it up

Page 12: CSS preprocessing - Sass vs Less by Brady Sammons

{ Differences }@ LESS VS $ Sass

Page 13: CSS preprocessing - Sass vs Less by Brady Sammons

{ Example } Sass $

$ltgreen: #79c777;

#header { Font-Size: 1.1em; h2 { color: $ltgreen; }}

LESS @

@ltgreen: #79c777;

#header { Font-Size: 1.1em; h2 { color: @ltgreen; }}

#header { Font-Size: 1.1em;}#header h2 { color: #79c777;}

CSS (compiled)

Page 14: CSS preprocessing - Sass vs Less by Brady Sammons

{ Comparison }

SASS ($)LESS (@)

Operators#header{ width: (@headerW - 50) * 2;}

#header{ width: ($headerW - 50) * 2;}

Frameworks

Language Base

LESSHat, LESS ELEMENTS

Javascript (originally Ruby)

COMPASS

Ruby

Functions lighten(#ff0000, 10%);Saturate(#ff0000, 20%);

lighten(#ff0000, 10%);Saturate(#ff0000, 20%);

Mixins@mixin ÁXLG%R[{ width: 50%; ER[�VL]LQJ: ERUGHU�ER[;}

�ÁXLG%R[{ width: 50%; ER[�VL]LQJ: ERUGHU�ER[;}

Parametric Mixins

�URXQGHG(#UDGLXV���px){ �ZHENLW�ERUGHU�UDGLXV: #UDGLXV; �PR]�ERUGHU�UDGLXV: #UDGLXV; ERUGHU�UDGLXV: #UDGLXV;}

#PL[LQ�URXQGHG(�UDGLXV���px){ �ZHENLW�ERUGHU�UDGLXV: �UDGLXV; �PR]�ERUGHU�UDGLXV: �UDGLXV; ERUGHU�UDGLXV: �UDGLXV;}

Variables @plainRed: #ff0000;#VRIW%OXH: #bce7f3;

$plainRed: #ff0000;�VRIW%OXH: #bce7f3;

Page 15: CSS preprocessing - Sass vs Less by Brady Sammons

{ Compiling Apps }

LESS SASSBOTH

Less.app Codekit

Fire.app

Scout

Livereload

Page 16: CSS preprocessing - Sass vs Less by Brady Sammons

{ Some Live Code }

Page 17: CSS preprocessing - Sass vs Less by Brady Sammons

{ Game On }