using sass in your wordpress projects

51
Using Sass in Your WordPress Projects Kansas City WordCamp - July 12, 2014

Upload: jeremy-green

Post on 12-Nov-2014

454 views

Category:

Software


0 download

DESCRIPTION

A presentation given at WordCamp Kansas City 2014 to help developers start using Sass in their WordPress themes and plugins.

TRANSCRIPT

Page 1: Using Sass in Your WordPress Projects

Using Sass in Your WordPress Projects

Kansas City WordCamp - July 12, 2014 !

Page 2: Using Sass in Your WordPress Projects

Jeremy Green WordPress Developer at Endo Creative Organizer of the Fort Collins WordPress Meetup !@greenhornet79 !endocreative.com !

Page 3: Using Sass in Your WordPress Projects

CSS Today !

Page 4: Using Sass in Your WordPress Projects

Bert Bos, CSS co-inventor: !

“CSS stops short of even more powerful features that programmers use in their

programming languages: macros, variables, symbolic constants, conditionals,

expressions over variables, etc. That is because these things give power-users a lot

of rope, but less experienced users will unwittingly hang themselves.”

Page 5: Using Sass in Your WordPress Projects

Vanilla CSS

Page 6: Using Sass in Your WordPress Projects

Putting the Power into CSS

Page 7: Using Sass in Your WordPress Projects

CSS Preprocessors

Page 8: Using Sass in Your WordPress Projects

Sass Syntactically Awesome Style Sheets

Page 9: Using Sass in Your WordPress Projects

A CSS preprocessor that lets you write CSS:

!

• faster

• more efficient

• more maintainable

CSS with superpowers

Page 10: Using Sass in Your WordPress Projects

A few of my favorite things

Page 11: Using Sass in Your WordPress Projects

Nesting

Page 12: Using Sass in Your WordPress Projects

CSS SCSS

Page 13: Using Sass in Your WordPress Projects

Variables

Page 14: Using Sass in Your WordPress Projects

!

• similar to php variables • turn repetitive values into variables • define it once, use it throughout your projects

Page 15: Using Sass in Your WordPress Projects

Partials

Page 16: Using Sass in Your WordPress Projects

!

• prepend partials with an underscore • split CSS into maintainable blocks of code • only one HTTP request!

Page 17: Using Sass in Your WordPress Projects

! Folders!

Page 18: Using Sass in Your WordPress Projects

Extends

Page 19: Using Sass in Your WordPress Projects

!

• reuse a snippet of CSS • does not accept any parameters • same styles as another class, except for a few rules

Page 20: Using Sass in Your WordPress Projects

Silent Placeholder

Page 21: Using Sass in Your WordPress Projects

Mixins

Page 22: Using Sass in Your WordPress Projects

!

• accepts parameters like a function • use for tedious tasks like vendor prefixes • reusable block of CSS, but with parameters

Page 23: Using Sass in Your WordPress Projects

Inline Media Queries

Page 24: Using Sass in Your WordPress Projects

!

• create a media query mix-in • set breakpoints for your design • use logic and return content in a mixin

Page 25: Using Sass in Your WordPress Projects

!

• use @include to call the mixin • stack media queries for different breakpoints • any rules inside media query will be added to CSS

SCSS Compiled

Page 26: Using Sass in Your WordPress Projects

Small Investment

Big Reward

Page 27: Using Sass in Your WordPress Projects

Installing Sass http://sass-lang.com/install

Page 28: Using Sass in Your WordPress Projects

Command Line

gem install sass

Page 29: Using Sass in Your WordPress Projects

Watch the files

sass --watch global.scss:global.css

Page 30: Using Sass in Your WordPress Projects

Applications

Page 31: Using Sass in Your WordPress Projects

The App Way

Open app, make changes, save file

Page 32: Using Sass in Your WordPress Projects

Your First Project

Page 33: Using Sass in Your WordPress Projects

Watch your files

Page 34: Using Sass in Your WordPress Projects

Configure options

Page 35: Using Sass in Your WordPress Projects

Compressed = Fastest

Page 36: Using Sass in Your WordPress Projects

Let’s Precompile

Page 37: Using Sass in Your WordPress Projects

Don’t touch that file

Live is .scss land now

Page 38: Using Sass in Your WordPress Projects

One bite at a time !

!

you don’t have to use everything at once

Page 39: Using Sass in Your WordPress Projects

WordPress Integration !

!

Page 40: Using Sass in Your WordPress Projects

Update functions.php !

! Use style.css (old way)

Use css/global.css (new way)

Page 41: Using Sass in Your WordPress Projects

Stripped down style.css !

!

!

• comments for theme details • alert future developers about the theme using Sass

Page 42: Using Sass in Your WordPress Projects

Use in a plugin !

!

!

• good even for small projects • use wp_enqueue_style to enqueue css file • split front and back end styles

Page 43: Using Sass in Your WordPress Projects

Gravity Forms !

!

Page 44: Using Sass in Your WordPress Projects

Tips for Integration !

!!

• make sure to update css and scss files on server • give option to edit css if needed • create a partial for overriding plugin styles • app is nice when you work on 10 projects a day

Page 45: Using Sass in Your WordPress Projects

Additional Tools !

!

Page 46: Using Sass in Your WordPress Projects

!

• CSS3 mixins • helper functions (colors, math, and much more) • generate sprites dynamically

Page 47: Using Sass in Your WordPress Projects

Susy !

!

!

• Sass grid system (or not) • creates layouts using mixins • calculate column and gutter widths

Page 48: Using Sass in Your WordPress Projects

Breakpoint !

!

!

• media queries with Sass • includes lots of helpful tools

Page 49: Using Sass in Your WordPress Projects

Final Thoughts !

!

!

• Sass won’t make you write better CSS • Sass won’t build an awesome WP theme • Don’t be afraid to try something new

!

Page 51: Using Sass in Your WordPress Projects

Thank You!

@greenhornet79