sass. - o'reilly mediaassets.en.oreilly.com/1/event/59/sass_ the future of stylesheets... ·...

92
Sass. The Future of Stylesheets.

Upload: others

Post on 18-Oct-2019

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Sass.The Future of Stylesheets.

Page 2: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Chris EppsteinFollow me @chriseppsteinArchitect - Caring.comCreator - Compass Stylesheet FrameworkCore Contributor - Sass

Page 3: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

A website for caregivers of the sick and elderly.

The right information at just the right time

We’re HIRING!

Page 4: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Book:Sass & Compass In ActionBuy the pre-release now and save 40%

http://www.manning.com/netherland/DISCOUNT CODE: sass40 (Good through Friday)

Page 5: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Today

Page 6: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

RationaleWhy does Sass exist?What problems does it solve?

Page 7: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

SyntaxWhat does Sass provide?

Page 8: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Best PracticesTips, tricks & pitfalls

Page 9: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Questions?Please ask them.

Page 10: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

What is “Sass”?Syntactically Awesome StyleSheets

Yes, it’s an acronym.But, it’s *not* all caps.Why? I don’t know. Alternate SyntaxCompiles to CSSTo understand Sass, you must know CSS

Page 11: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

What is CSS?• Originated in Academia• 14 Years Old• Three Primitives:‣Selectors‣Properties‣Values

Page 12: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

CSS is Pretty.Pretty dumb.

CSS Selectors are great -- that’s why we use them in jQuery & HamlProperties are simple key/value pairs.CSS is elegantly simple.

Page 13: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Never in the history of software have developers been asked to do so much with so little.

Maybe my memory doesn’t go back very far.

I’m sure punch cards and assembler sucked.

Page 14: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Browsers & Versions

9 Browsers25 VersionsPace of development is increasing

Page 15: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Multiple Form FactorsDesktop, Mobile, Print...

Page 16: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Dozens of Templates

Page 17: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Experiment & Test

Page 18: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Maintain Consistency

Page 19: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Performant

Page 20: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Due Yesterday

Page 21: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

New Hotness:CSS333 New Selectors120+ New Properties3 New @-rulesEnhanced Media Queries

Page 22: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

CSS3No new syntax*

* Yet.

•CSS is a major front for the Browser War v2.0•Casualty of War: Front-End Developers•What do all of these new features have in common?•Theyʼre all about the browser -- None of them address how we author stylesheets.

Page 23: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet
Page 24: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

CSS was designed for theMythical Designer who is too stupid to understand High School Algebra.

Page 25: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

If you want to make something simple for beginners...

Page 26: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

...make it powerful enough for the experts to create that simplicity.

I think rails is a great example of this. Ruby is incredibly powerful, that power makes the best practices of web programming accessible and scaffolds the n00bs during the learning process as they peel the layers of abstraction back.

Page 27: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

But...

Page 28: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

There is an alternative.

What if we gave stylesheets some brains?

Page 29: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

What is Sass?• Born from Real World Experience• Brings Software Development

Methodologies to Stylesheets:‣Reusable, distributable libraries‣DRY‣Define abstractions‣Adhere to architectural boundaries

Page 30: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

What is Sass?New Primitives:• Variables• Mixins• Selector

Inheritance

• Calculations• Functions• Conditionals• Loops

Alternate SyntaxCompiles to CSSWe’ll get to these primitives in a second

Page 31: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

What is Sass?It’s what CSS would have been if we had known then what we know now:

Most stylesheets are written by programmers.

But: Sass in the hands in of a technical designer is a BEAUTIFUL THING

Page 32: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Problem:CSS StylesheetsAre hard to maintain

Page 33: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Don’tRepeatYourself(I don’t have to tell you this -- It’s not like you want to)

Page 34: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

A single change.A single edit.A single compile.

Page 35: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

We have machines.Let them do the busy work.

Page 36: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Problem:Same ColorMany Representations

Page 37: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Problem:Same ColorDifferent Reasons

Page 38: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Accidentally the same?

Page 39: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

redrgb(255, 0, 0)

rgba(255, 0, 0, 1.0)

#f00

rgba(#f00, 1.0)

RED

hsl(0deg, 100%, 100%)

hsla(0deg, 100%, 100%, 1)

You cannot safely Search and Replace a color.

Page 40: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Solution:VariablesThe most requested CSS enhancement

Page 41: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Use variables anywhere a value is allowed.

Page 42: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet
Page 43: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Problem:Magic ValuesLost knowledge

Page 44: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Deceptively Complex

where do these colors come from? Clearly they’re related -- must be designer voodoo.

Page 45: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Solution:TransformationsDerive values during compilation

Page 46: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

As complex as it actually is.

Page 47: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Sass Color Functions

mix(red, blue, 40%) => #660099lighten(red, 10%) => #ff3333darken(red, 10%) => #cc0000desaturate(red, 10%) => #f20d0dsaturate(#511, 10%) => #5a0c0ctransparentize(red, 0.25) => rgba(255, 0, 0, 0.75)opacify(red, 0.25) => rgba(255, 0, 0, 0.75)grayscale(red) => #808080complement(red) => #00ffff

There’s more on the Sass website.

Page 48: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Solution:Make Reusable CalculationsWe call these things “functions”

Page 49: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet
Page 50: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Deceptively Complex

Why is it 366px? If I want to change the border width, how should I adjust these values?

Page 51: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Solution:Abstractions & CalculationsDerive values during compilation

Page 52: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Create a simple abstraction

Now our changes are obvious and the implementation details elided.

Page 53: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

As complex as it actually is.

Currently most of these calculations are done on a scratch pad.

seriously.

Page 54: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Best Practice:Minimize HTTP Round Trips

Page 55: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Problem:Long StylesheetsHard to find your styles.

Don’t use CSS @import.Serve a few, longer stylesheets.

Page 56: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

And I mean long...

Seriously, this keeps going...

Page 57: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Solution:Concatenation & Partials

Page 58: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Convention: Each folder has a file of the same name that imports the files contained within it in the correct order.

Partials: Just like with html templates, underscores denote a partial and can only be imported by other stylesheets.

Page 59: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Problem:Shared StylesheetsStyles leak into places you didn’t intend

Page 60: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Sitewide Styles

Forum Blog Articles Directory

Index

Thread

Form

List

Post

Form

Index

Article

Comment

Search

Listing

Review

Page 61: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Solution:Scoped Selectors

Page 62: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

CSS gives you carpal tunnel from typing your scopes OVER & OVER AGAIN

Notice that comma selectors are permuted

Page 63: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Sass ProvidesDRY Selectorsvia nesting

Page 64: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Nested Selectors

Compiles to

• Default: descendant• & - context reference• Works with combinators

Page 65: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Problem:Dozens of ImagesSpriting is annoying

Page 66: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Solution:Compass Sprites

Page 67: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

gem “compass”

Simple Sprites(Compass makes classes for you)

Or you can define your own selectors.

Page 68: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet
Page 69: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Problem:Dozens More Images

Page 70: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Solution:Use CSS3 InsteadAbstract vendor prefixes away

Page 71: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet
Page 72: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

gem “compass”

Compass CSS3 mixin arguments mimic the real css3 property values.

Page 73: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet
Page 74: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Best Practice:Use a CDN / Asset HostsLoad assets faster

Page 75: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Problem:Image URLs Change

relative pathsroot relative pathsroot changesasset hostscdns

Page 76: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Solution:Use URL HelpersJust like in Rails

Page 77: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Compiles to

Page 78: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Separate Content & PresentationBest Practice:

Page 79: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Problem:Classitis

Do you have markup that looks like this?

Page 80: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

You’re officially doing it wrong.

But I get it. You need re-use.

Page 81: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Solution:Move Presentation ConcernsThey belong in your stylesheets

Page 82: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

This is all you should need.

Page 83: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Compiles to

+

Mixins

Page 84: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

MixinsCreate a design vocabularyof common patterns independent from your markup's selector domain

Page 85: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

More Mixins

+

Compiles to

Page 86: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

More Mixins

+

Compiles to

Page 87: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

More Mixins

+

Compiles to

Page 88: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

This is all you should need.

Page 89: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Compiles to

Selector Inheritance

Page 90: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

We’ve OnlyScratched the Surfacehttp://sass-lang.comhttp://compass-style.org

Page 91: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

My Teammates

Lead Developer of SassNathan Wiezenbaum (@nex3)

The Compass Core TeamEric Meyer (@eriiicam)Brandon Mathis (@imathis)Scott Davis (@jetviper21)Nico Hagenburger (@hagenburger)

Page 92: Sass. - O'Reilly Mediaassets.en.oreilly.com/1/event/59/Sass_ The Future of Stylesheets... · Chris Eppstein Follow me @chriseppstein Architect - Caring.com Creator - Compass Stylesheet

Compass is Charityware

If you use Compass and it makes your life better, please help make someone else’s life better by making a tax-deductible donation to the United Mitochondrial Disease Foundation.

http://umdf.org/compass