66
Rakesh Menon Level Up with Post CSS

Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

Rakesh Menon

Level Up with Post CSS

Page 2: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

Level up with

Page 3: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

Rakesh Menon @rakeshmenon13

Page 4: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

I’ve seen before! ツ

The PostCSS logo looks like something

Page 5: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *
Page 6: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

Key Takeaways

from this session

Page 7: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *
Page 8: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *
Page 9: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

Evolution

Page 10: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

Evolution cycle

Page 11: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

CSS (Cascading Style Sheets)

Page 12: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

.section > .inner-section >

.inner-section-header > .inner-

section-headers-heading > .the-

text-inside-it > .which-also-

has-words {

/* I did a bad job */

}

CSS (Cascading Style Sheets)

Page 13: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *
Page 14: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

Preprocessor

s

Page 15: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *
Page 16: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

The Dark Side

Page 17: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *
Page 18: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

What is PostCSS?

Page 19: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

What is PostCSS - not??

Page 20: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

PostCSS is not!

Page 21: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

PostCSS is not!

Page 22: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

PostCSS is not!

Page 23: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

PostCSS is not!

Page 24: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

So what exactly is PostCSS?

Page 25: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *
Page 26: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

Andrey Sitnik

Page 27: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

Steps involved in building a CSS tool

Page 28: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

PostCSS handles the tedious

stuff!

Page 29: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

PostCSS consists of…

Page 30: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

Abstract Syntax Tree (AST)

Page 32: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

let postcss = require('postcss');

Usage

let css = /* read css file with FS */;

postcss([ plugin1, plugin2(options), ..])

.process(css)

.then( result => console.log(result.css) /* or write the css to disk */ );

Page 33: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

postcss.plugin(['myplugin'], options => {

PostCSS Plugin

/* Use options */

return css => {

/* process css */

};

});

Page 34: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

Overview of how PostCSS works

Page 35: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

/* Root */ .foo { /* Rule */ color: pink; /* Declaration */ } /* AtRule */ @media (min-width: 20rem) { .foo { color: orange; } }

Page 36: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

/* Root */ .foo { /* Rule */ color: pink; /* Declaration */ } /* AtRule */ @media (min-width: 20rem) { .foo { color: orange; } }

Page 37: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

Page 38: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

root.walkRules(); rule.walkDecls(); decl.cloneBefore(); comment.remove(); // ...

Page 39: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

Page 40: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

PostCSS is also….

Page 41: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

Let’s create a plugin!

Page 42: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

Fallback plugins

Page 43: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

:

Fallback plugins

Page 45: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

.element:container(width >=

100px <= 300px) {}

:

Fallback plugins

Page 46: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

Non-standard keywords….

Confusion?

Page 48: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

Non-standard keywords….

Confusion?

Page 49: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

Utilities

Page 51: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *
Page 52: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

CSS Next?

Page 53: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

CSS Next?

Page 54: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

CSS Next?

Page 57: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *
Page 58: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

Evolution cycle

Page 59: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

Evolution cycle

Page 60: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

Choosing the Stack

Page 61: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

Choosing the Stack

Page 63: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

Summing it up!

Page 64: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *
Page 65: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

Questions

Page 66: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *

www.modsummit.com

www.developersummit.com