drupalsouth 2014: managing complex projects with design components

38
John Albin Wilkins @JohnAlbin Senior Front-end Developer at Lullabot Managing Complex Projects with Design Components

Upload: john-albin-wilkins

Post on 15-Jun-2015

2.219 views

Category:

Technology


3 download

DESCRIPTION

Introduces Web Components as the future of front-end development and describes how to start using some of the concepts today using Design Components.

TRANSCRIPT

Page 1: DrupalSouth 2014: Managing Complex Projects with Design Components

John Albin Wilkins!@JohnAlbin!

!

Senior Front-end Developer at Lullabot

Managing Complex Projects with Design Components!

Page 2: DrupalSouth 2014: Managing Complex Projects with Design Components

John Albin Wilkins!@JohnAlbin!

!

Senior Front-end Developer at Lullabot

Managing Complex Projects with Design Components!

Page 3: DrupalSouth 2014: Managing Complex Projects with Design Components

★ Zen Gridszengrids.com!

★ Normalize.css for Sass/Compass github.com/JohnAlbin/normalize-scss!

★ Succinct theme for Colloquy (IRC for Mac) github.com/JohnAlbin/succinct-for-colloquy!

★ git-svn-migrate john.albin.net/git/git-svn-migrate!

★ Zen theme for Drupal drupal.org/project/zen

Free Gifts From Me

Page 4: DrupalSouth 2014: Managing Complex Projects with Design Components

What is the WIFI password again?

★ Network: DrupalSouth 2014!

★ Password: anzacDrupal

Page 5: DrupalSouth 2014: Managing Complex Projects with Design Components

“Are you new to front-end web development? !

 Here’s a secret:  no one else really knows  what they’re doing either.”

— Nicolas Gallagher

Where are we headed?

Page 6: DrupalSouth 2014: Managing Complex Projects with Design Components

Where are we headed?

www.w3.org/TR/components-intro/!css-tricks.com/modular-future-web-components/

Web Components!

Page 7: DrupalSouth 2014: Managing Complex Projects with Design Components

Where are we headed?

www.w3.org/TR/components-intro/!css-tricks.com/modular-future-web-components/

Web Components!

“Hey… Web developers really like templating systems.

We should implement that natively in HTML.”

Page 8: DrupalSouth 2014: Managing Complex Projects with Design Components

Where are we headed?

www.w3.org/TR/components-intro/!css-tricks.com/modular-future-web-components/

Web Components!

<carousel><ohgod-ohgod-why-wont-my-client-listen-to-me-about-carousels>

Page 9: DrupalSouth 2014: Managing Complex Projects with Design Components

★ Reusable and repeatable components!

★ Self-contained design(included CSS only applies to its component)

What can we learn from the future?

Page 10: DrupalSouth 2014: Managing Complex Projects with Design Components

CSS Specificity Wars

Page 11: DrupalSouth 2014: Managing Complex Projects with Design Components

.menu .item a:link {}!

.sidebar .menu .item a:link {}!

.page-37 .sidebar .menu .item a:link {}

CSS Specificity Wars

Page 12: DrupalSouth 2014: Managing Complex Projects with Design Components

.menu .item a:link {! .sidebar & {! .page-37 & {}! }!}

CSS Specificity Wars

Page 13: DrupalSouth 2014: Managing Complex Projects with Design Components

Overly generic class names

.title { }

.block .title { }

.node .title { }

.views .title { }

.content { }!

.block .content { }!

.node .content { }!

.views .content { }

Page 14: DrupalSouth 2014: Managing Complex Projects with Design Components

Seemed like a good idea at the time.

Page 15: DrupalSouth 2014: Managing Complex Projects with Design Components

What are!Design Components?

★ “Component” is the same as…!

★ “Object” in OOCSS!

★ “Module” in SMACSS !

★ “Block” in BEM’s Block-Element-Modifier!

★ “UI Pattern”

Page 16: DrupalSouth 2014: Managing Complex Projects with Design Components

Design ComponentOne class == one consistent style

.button.navbar

.side-nav.bio

.watermark

.tabs

.more-link

Page 17: DrupalSouth 2014: Managing Complex Projects with Design Components

Goals of!Design Components

★ Reduce specificity!

★ Reduce applicability / control the cascade!

★ Improve maintainability

Page 18: DrupalSouth 2014: Managing Complex Projects with Design Components

On the meaning of semantics

Page 19: DrupalSouth 2014: Managing Complex Projects with Design Components

.omnomnomnom !

is more semantic then!!

.blaaagh

On the meaning of semantics

Page 20: DrupalSouth 2014: Managing Complex Projects with Design Components

On the meaning of semantics

Don’t name your class .blubadu-blubadu-blubadu-pphhffft

Page 21: DrupalSouth 2014: Managing Complex Projects with Design Components

On the meaning of semantics

★ Content semanticsis handled by HTML5 elements

★ Let’s make our class names use Design semantics

★ Make the class names meaningful to the developers and designers

Page 22: DrupalSouth 2014: Managing Complex Projects with Design Components

File organization = first 3 SMACSS Categories

Page 23: DrupalSouth 2014: Managing Complex Projects with Design Components

Simple Folder Structure

Page 24: DrupalSouth 2014: Managing Complex Projects with Design Components

Easy to find your components.

★ Inspect the DOM.!

★ Find the class on the design component.!

★ Look for a file with that name in the components folder.

Page 25: DrupalSouth 2014: Managing Complex Projects with Design Components

styles.scss

Page 26: DrupalSouth 2014: Managing Complex Projects with Design Components

Deconstructing!a design component

★ The component

★ Sub-parts

★ Variants

★ States

Page 27: DrupalSouth 2014: Managing Complex Projects with Design Components

A simple component

Page 28: DrupalSouth 2014: Managing Complex Projects with Design Components

A component with sub-parts

Page 29: DrupalSouth 2014: Managing Complex Projects with Design Components

A component with sub-parts

Page 30: DrupalSouth 2014: Managing Complex Projects with Design Components

.menu .item a:link {}

.sidebar .menu .item a:link {}

.page-37 .sidebar .menu .item a:link {}

Component Variants

Page 31: DrupalSouth 2014: Managing Complex Projects with Design Components

.menu__link {}

.menu--sidebar__link {}

.viking-ponycorn__link {}

Component Variants

Page 32: DrupalSouth 2014: Managing Complex Projects with Design Components

A simple component

and a variant

(all in one file)

Page 33: DrupalSouth 2014: Managing Complex Projects with Design Components

A SMACSS “state”

Page 34: DrupalSouth 2014: Managing Complex Projects with Design Components

A SMACSS “state”

Page 35: DrupalSouth 2014: Managing Complex Projects with Design Components

Deconstructing!a design component

.the%component+

.the%component%%variant+

.the%component__sub%part+

.the%component.is%state+

+ .the%component:hover+

+ @media+all+{+.the%component+{}+}

Page 36: DrupalSouth 2014: Managing Complex Projects with Design Components

The “fugly” selector hack

Page 37: DrupalSouth 2014: Managing Complex Projects with Design Components

The “fugly” selector hack

Selector in DOMI couldn’t change

Class name I wish I could use in DOM

Page 38: DrupalSouth 2014: Managing Complex Projects with Design Components

Thank you!

Follow me on the Twitterz.!@JohnAlbin