compass

64
Patrick Crowley http://github.com/mokolabs

Upload: patrick-crowley

Post on 13-May-2015

1.343 views

Category:

Technology


4 download

DESCRIPTION

Patrick Crowley shows how to turbo-charge your layouts with Compass, a lightweight stylesheet framework built on top of Haml and Sass.

TRANSCRIPT

Page 1: Compass

Patrick Crowleyhttp://github.com/mokolabs

Page 2: Compass

Getting oriented with Compass

Page 3: Compass

What is Compass?

Page 4: Compass
Page 5: Compass

• Framework for stylesheets

Page 6: Compass

• Framework for stylesheets

• Uses Haml & Sass

Page 7: Compass

• Framework for stylesheets

• Uses Haml & Sass

• Well, really just Sass

Page 8: Compass

• Framework for stylesheets

• Uses Haml & Sass

• Well, really just Sass

• Lightweight

Page 9: Compass

Why do we need to use Compass?

Page 10: Compass
Page 11: Compass

• Stylesheets are too long

Page 12: Compass

• Stylesheets are too long

• Stylesheets are too complex

Page 13: Compass

• Stylesheets are too long

• Stylesheets are too complex

• Stylesheets are a fucking mess!

Page 14: Compass

• Stylesheets are too long

• Stylesheets are too complex

• Stylesheets are a fucking mess!

• Yeah, I’m talking to you.

Page 15: Compass

But what if...

Page 16: Compass
Page 17: Compass

• I wanna use ERB

Page 18: Compass

• I wanna use ERB

• I think Sass has a weird syntax

Page 19: Compass

• I wanna use ERB

• I think Sass has a weird syntax

• My styles are hand-crafted

Page 20: Compass

• I wanna use ERB

• I think Sass has a weird syntax

• My styles are hand-crafted

• I don’t have many styles yet

Page 21: Compass
Page 22: Compass

How do I get started?

Page 23: Compass
Page 24: Compass

• gem ‘compass’

Page 25: Compass

• gem ‘compass’

• bundle install compass

Page 26: Compass

• gem ‘compass’

• bundle install compass

• compass version

Page 27: Compass

• gem ‘compass’

• bundle install compass

• compass version

• compass init rails /path/to/app

Page 28: Compass

• gem ‘compass’

• bundle install compass

• compass version

• compass init rails /path/to/app

• tweak config/compass.rb

Page 29: Compass

• gem ‘compass’

• bundle install compass

• compass version

• compass init rails /path/to/app

• tweak config/compass.rb

• add app/stylesheets

Page 30: Compass

What are the basics?

Page 31: Compass

.SCSS files

Page 32: Compass

SCSS = Sassy CSS

Page 33: Compass

.scss .css

Page 34: Compass

body { font-family: Helvetica, Arial, sans-serif;}

h1 { font-size: 28px; a { text-decoration: none; }}

a { color: #FF1E00; &:hover { color: #336699; }}

app/stylesheets/app.scss

Page 35: Compass

body { font-family: Helvetica, Arial, sans-serif;}

h1 { font-size: 28px;}

h1 a { text-decoration: none;}

a { color: #FF1E00;}

a:hover { color: #336699;}

public/stylesheets/app.css

Page 36: Compass

Variables

Page 37: Compass

$blue: #3bbfce;$margin: 16px;

.content-navigation { border-color: $blue; color: darken($blue, 9%);}

.border { padding: $margin / 2; margin: $margin / 2; border-color: $blue;}

Page 38: Compass

.content-navigation { border-color: #3bbfce; color: #2b9eab;}

.border { padding: 8px; margin: 8px; border-color: #3bbfce;}

Page 39: Compass

Partials

Page 40: Compass

body { font-family: Helvetica, Arial, sans-serif;}

@import "core/type";

app/stylesheets/app.scss

Page 41: Compass

h1, h2, h3, h4, h5 { color: #444; margin: 12px 0;}

h1 { font-size: 28px; margin: 24px 0;}

h2 { clear: left; font-size: 24px; margin: 18px 0;}

app/stylesheets/core/type.scss

Page 42: Compass

body { font-family: Helvetica, Arial, sans-serif;}

h1, h2, h3, h4, h5 { color: #444; margin: 12px 0;}

h1 { font-size: 28px; margin: 24px 0;}

h2 { clear: left; font-size: 24px; margin: 18px 0;}

public/stylesheets/app.css

Page 43: Compass

Mixins

Page 44: Compass

@mixin large-text { font: { family: Arial; size: 20px; weight: bold; } color: #ff0000;}

Page 45: Compass

.page-title { @include large-text; padding: 4px; margin-top: 10px;}

Page 46: Compass

.page-title { font-family: Arial; font-size: 20px; font-weight: bold; color: #ff0000; padding: 4px; margin-top: 10px;}

Page 47: Compass

Compass =Mixins on Charlie Sheen

Page 48: Compass

WINNING!

Page 49: Compass
Page 50: Compass

• New CSS 3 hotness

Page 51: Compass

• New CSS 3 hotness

• Blueprint

Page 52: Compass

• New CSS 3 hotness

• Blueprint

• Yahoo UI layouts

Page 53: Compass

• New CSS 3 hotness

• Blueprint

• Yahoo UI layouts

• Grid systems

Page 54: Compass

• New CSS 3 hotness

• Blueprint

• Yahoo UI layouts

• Grid systems

• Fancy buttons

Page 55: Compass

input[type=text],input[type=password],textarea { @include border-radius(6px); border: 1px solid #ccc; color: #333; font-size: 16px; padding: 3px; outline: none;}

Page 56: Compass

How do I organizemy stylesheets?

Page 57: Compass
Page 58: Compass

// Compass@import "compass/reset";@import "compass/utilities";@import "compass/css3";

// Libraries@import "lib/jquery-ui";

// Core@import "core/mixin";@import "core/colors";@import "core/tag";@import "core/layout";@import "core/message";@import "core/form";@import "core/widget";

// Features@import "features/product";@import "features/user";

app/stylesheets/app.scss

Page 59: Compass

Resources

Page 60: Compass
Page 61: Compass

• http://compass-style.org

Page 64: Compass

The End