psd to theme: the smacss way

47
PSD to Theme: The SMACSS Way Emma Jane Westby // @emmajanehw www.drupalize.me lb.cm/smacss-badcamp

Upload: emma-jane-hogbin

Post on 27-Jan-2015

109 views

Category:

Technology


0 download

DESCRIPTION

You've just been handed a gorgeous, static Photoshop file. By tomorrow it needs to be a flexible, extensible, and compatible Drupal theme for some Web site you've never seen. Oh and they said something about it needing to be responsive to 508 or something like that? *gulp* The problem with creating a Drupal theme is —once you know how—it becomes intuitive. Themers spontaneously transform design files into complete Drupal themes without realizing all of the little steps their brain takes to achieve the final solution. It's sort of like those “learn to draw a cat” books where it takes you from a basic circle to a cat with beautiful fur in four simple steps. It's never four complete simple steps though. It's two steps of making circles and then some kind of crazy artist voodoo that makes a complete cat by the last step. In this session Emma Jane Westby (of Front End Drupal fame) will walk you through the steps ... all the steps ... of converting a design into a theme. Without missing any steps, Emma will walk you through: the benefits of theming by component what you need to have in place before you start what's worth keeping from SMACSS (and what's just overhead) how to refine her simple procedure so it works for your team, and with any version of Drupal

TRANSCRIPT

Page 1: PSD to Theme: The SMACSS Way

PSD to Theme:The SMACSS Way

Emma Jane Westby // @emmajanehwwww.drupalize.me

lb.cm/smacss-badcamp

Page 2: PSD to Theme: The SMACSS Way

Emma JaneDrupalize.Me

IRC: emmajane@emmajanehw

Page 3: PSD to Theme: The SMACSS Way

photo credit: mortendk

Page 4: PSD to Theme: The SMACSS Way
Page 5: PSD to Theme: The SMACSS Way

The Old Way toPSD to Theme

1. Sketch out the design components.

2. Choose an appropriate base theme.

3. Apply relevant static images to the main tpl.php files.

4. Launch the theme.

5. Look for bugs and create high specificity selectors to target and fix problems.

Page 6: PSD to Theme: The SMACSS Way

The New Way toPSD to Theme

1. Sketch out the design components.

2. Create a library of basic styles according to SMACSS convention.

3. Adjust Drupal class names to match style component names.

4. Look for bugs and refactor the component styles to match the design.

Page 7: PSD to Theme: The SMACSS Way

Pro Tip

Let your base theme take care of your requirements:

• grid framework

• accessibility compliance

• responsive defaults

Page 8: PSD to Theme: The SMACSS Way

Intro to SMACSS

Page 9: PSD to Theme: The SMACSS Way

SMACSS

• Semantic and Scalable Architecture for CSS

• Jonathan Snook

• http://smacss.com/

Page 10: PSD to Theme: The SMACSS Way

SMACSS Rules

• Base rules (HTML element overrides)

• Layout rules (wire frames)

• Component rules (anything that can be placed, or reused on your site)

• State rules (augments and overrides)

• Theme rules (variations)

Page 11: PSD to Theme: The SMACSS Way

Folder Structure• base:

HTML element

• components:almost everything

• global:extension of HTML element

• layout:region definitions

Page 12: PSD to Theme: The SMACSS Way

styles.scss

Page 13: PSD to Theme: The SMACSS Way

components

Page 14: PSD to Theme: The SMACSS Way

Pro Tips

• Separate your components into their own files from the beginning.

• Name your files according to the container selector found in the DOM.

• A component isn’t accepted until it’s documented with a screenshot referenced from the SCSS file.

Page 15: PSD to Theme: The SMACSS Way

yeahbuthow?

Page 16: PSD to Theme: The SMACSS Way

You new here?

“Are you new to front-end web development? Here's a secret: no one else really knows what they're doing either.”~ Nicolas Gallagher

Page 17: PSD to Theme: The SMACSS Way

Ask YourselfThree Questions

1. What’s the shape?

2. What’s consistent throughout the site?

3. What can be moved like furniture?

Page 18: PSD to Theme: The SMACSS Way

big to little

Page 19: PSD to Theme: The SMACSS Way

Design

Page 20: PSD to Theme: The SMACSS Way

What’s the shape?these are your layout rules

Page 21: PSD to Theme: The SMACSS Way

Layout Rules

Page 22: PSD to Theme: The SMACSS Way

Identify the Grid

Page 23: PSD to Theme: The SMACSS Way

Sketch the Essence

Page 24: PSD to Theme: The SMACSS Way

layout/_default.scss

(depends on your base theme and/or grid framework)

Page 25: PSD to Theme: The SMACSS Way

What’s consistent throughout the site?

these are (typically) your base rules

Page 26: PSD to Theme: The SMACSS Way

Base Rules

Page 27: PSD to Theme: The SMACSS Way

base/_base.scss

html {

width: 100%;

height: 100%;

-webkit-overflow-scrolling: touch;

display: block;

@include border-box-sizing;

Page 28: PSD to Theme: The SMACSS Way

What can be moved like furniture?

these are your components

Page 29: PSD to Theme: The SMACSS Way

Identify Visual Anchors

Page 30: PSD to Theme: The SMACSS Way

Extract the Anchors(aka images)

Page 31: PSD to Theme: The SMACSS Way

Recognize Components

Page 32: PSD to Theme: The SMACSS Way

Recognize Components

Page 33: PSD to Theme: The SMACSS Way

Recognize Components

Page 34: PSD to Theme: The SMACSS Way

Recognize Components

Page 35: PSD to Theme: The SMACSS Way

Recognize Components

Page 36: PSD to Theme: The SMACSS Way

Recognize Components

Page 37: PSD to Theme: The SMACSS Way

components/_news-teaser.scss

How is it different than your base rules?

.news-teaser {

h2 { text-transform: uppercase; }

p:first-child { color: $highlight; }

p { color: $base; }

}

Page 38: PSD to Theme: The SMACSS Way

Apply it to Drupal.

Page 39: PSD to Theme: The SMACSS Way

With your components in mind, build your site.

You cannot apply a style to an elementwhich isn’t rendering on the page.

Page 40: PSD to Theme: The SMACSS Way

Establish Your Theme- .info file- regions (from layout rules)- add the SCSS files and crunched CSS files- add your page.tpl.php file from your base theme of choice with regions defined + printed

Page 41: PSD to Theme: The SMACSS Way

Adjust page.tpl.php

Page 42: PSD to Theme: The SMACSS Way

Launch an MVP Theme

Page 43: PSD to Theme: The SMACSS Way

Apply Your Styles

• Alter your SCSS with extend.

.drupal-weird-class {

@extend .my-awesome-class;

}

• Alter Drupal’s classes.

template.php

Page 44: PSD to Theme: The SMACSS Way

Refactor:Remove what’s not working.

Repeat.

Page 45: PSD to Theme: The SMACSS Way

Summary

• the benefits of theming by component

• what you need to have in place before you start

• what's worth keeping from SMACSS (and what's just overhead)

• how to refine her simple procedure so it works for your team, and with any version of Drupal

Page 47: PSD to Theme: The SMACSS Way

PSD to Theme:The SMACSS Way

Emma Jane Westby // @emmajanehwwww.drupalize.me

video lessons for this presentation coming soon!

slides: lb.cm/smacss-badcamp