Local styling with CSS Modules
by
Kitty Giraudel
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
berlin amsterdam los angeles san francisco singapore edenspiekermann_ Local styling with CSS Modules @HugoGiraudel 20 May 2016
Slide 2
Slide 2 text
@HugoGiraudel Front-end developer Edenspiekermann Berlin, Germany
Slide 3
Slide 3 text
Another CSS in JS thing?
Slide 4
Slide 4 text
Not about making CSS dependant on JS in the browser
Slide 5
Slide 5 text
About crafting a CSS pipeline (in JavaScript)
Slide 6
Slide 6 text
“CSS in JS” could as well be “CSS in Ruby”
Slide 7
Slide 7 text
We had CSS in Ruby for years with Sass
Slide 8
Slide 8 text
“CSS in JS” is reasonable
Slide 9
Slide 9 text
CSS from JS in the browser would suck
Slide 10
Slide 10 text
CSS Modules
Slide 11
Slide 11 text
Glen Maddern Mark Dalgleish Tobias Koppers
Slide 12
Slide 12 text
JS-powered CSS pipeline
Slide 13
Slide 13 text
Webpack Browserify JSPM & moar…!
Slide 14
Slide 14 text
Fixing (most) CSS flaws
Slide 15
Slide 15 text
No content
Slide 16
Slide 16 text
“CSS isn’t broken”
Slide 17
Slide 17 text
Hahaha. Haha. Ha.
Slide 18
Slide 18 text
Global namespace
Slide 19
Slide 19 text
Dependency management
Slide 20
Slide 20 text
Dead code elimination
Slide 21
Slide 21 text
Configuration sharing
Slide 22
Slide 22 text
Well specified but incomplete
Slide 23
Slide 23 text
Fine! What is it?
Slide 24
Slide 24 text
A system where everything is local
Slide 25
Slide 25 text
No more global namespace
Slide 26
Slide 26 text
Not about syntax
Slide 27
Slide 27 text
Consider a title
Slide 28
Slide 28 text
No content
Slide 29
Slide 29 text
No content
Slide 30
Slide 30 text
No filename repetition
Slide 31
Slide 31 text
No content
Slide 32
Slide 32 text
No content
Slide 33
Slide 33 text
No content
Slide 34
Slide 34 text
No content
Slide 35
Slide 35 text
No content
Slide 36
Slide 36 text
Not inline styles
Slide 37
Slide 37 text
Still classes
Slide 38
Slide 38 text
Configurable output
Slide 39
Slide 39 text
css-loader ?modules &localIdentName= [name]__[local]
Slide 40
Slide 40 text
No content
Slide 41
Slide 41 text
Composition
Slide 42
Slide 42 text
Good ol’ button
Slide 43
Slide 43 text
No content
Slide 44
Slide 44 text
Okay, Sass first
Slide 45
Slide 45 text
No content
Slide 46
Slide 46 text
No content
Slide 47
Slide 47 text
No content
Slide 48
Slide 48 text
Now, CSS Modules
Slide 49
Slide 49 text
No content
Slide 50
Slide 50 text
No content
Slide 51
Slide 51 text
No content
Slide 52
Slide 52 text
No content
Slide 53
Slide 53 text
No content
Slide 54
Slide 54 text
Not like @extend
Slide 55
Slide 55 text
No selector merge
Slide 56
Slide 56 text
Not like @mixin
Slide 57
Slide 57 text
No style duplication
Slide 58
Slide 58 text
Just class composition
Slide 59
Slide 59 text
Dependency management
Slide 60
Slide 60 text
Again, composes
Slide 61
Slide 61 text
No content
Slide 62
Slide 62 text
No content
Slide 63
Slide 63 text
No content
Slide 64
Slide 64 text
No content
Slide 65
Slide 65 text
No content
Slide 66
Slide 66 text
Explicit dependencies
Slide 67
Slide 67 text
Sharing styles
Slide 68
Slide 68 text
COMPOSE ALL THE THINGS!
Slide 69
Slide 69 text
No content
Slide 70
Slide 70 text
No content
Slide 71
Slide 71 text
Global classes?
Slide 72
Slide 72 text
:global
Slide 73
Slide 73 text
No content
Slide 74
Slide 74 text
No content
Slide 75
Slide 75 text
Shared values?
Slide 76
Slide 76 text
@value
Slide 77
Slide 77 text
No content
Slide 78
Slide 78 text
No content
Slide 79
Slide 79 text
Basically (local) variables
Slide 80
Slide 80 text
Explicit dependencies
Slide 81
Slide 81 text
Can be renamed
Slide 82
Slide 82 text
No content
Slide 83
Slide 83 text
But, but, but… BEM?
Slide 84
Slide 84 text
Helps with global namespace
Slide 85
Slide 85 text
Brain power, consistency, strictness…
Slide 86
Slide 86 text
No content
Slide 87
Slide 87 text
Not needed anymore!
Slide 88
Slide 88 text
But, but, but… Webpack?
Slide 89
Slide 89 text
postcss- modules
Slide 90
Slide 90 text
Statically compiled
Slide 91
Slide 91 text
No content
Slide 92
Slide 92 text
But, but, but… atomic CSS?
Slide 93
Slide 93 text
Perfect candidate
Slide 94
Slide 94 text
No content
Slide 95
Slide 95 text
Compose from the stylesheet
Slide 96
Slide 96 text
No content
Slide 97
Slide 97 text
Have markup updated
Slide 98
Slide 98 text
No content
Slide 99
Slide 99 text
But, but, but… Sass?
Slide 100
Slide 100 text
Not mutually exclusive
Slide 101
Slide 101 text
No content
Slide 102
Slide 102 text
Sass makes CSS easier to write
Slide 103
Slide 103 text
CSS Modules make CSS easier to maintain
Slide 104
Slide 104 text
Why not both?
Slide 105
Slide 105 text
Let’s sum up
Slide 106
Slide 106 text
JS-powered CSS pipeline
Slide 107
Slide 107 text
Everything is local
Slide 108
Slide 108 text
Global namespace no more
Slide 109
Slide 109 text
Pluggable in any pipeline
Slide 110
Slide 110 text
Pretty rad
Slide 111
Slide 111 text
berlin amsterdam los angeles san francisco singapore edenspiekermann_ Thank you! @HugoGiraudel 20 May 2016