-
Notifications
You must be signed in to change notification settings - Fork 1
/
slide.html
263 lines (234 loc) · 7.4 KB
/
slide.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
slidez
</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="slide.css" rel="stylesheet" />
<script src="slide.js" ></script>
</head>
<body>
<div class="content" id="content">
<div class="slide visible-slide">
<h1 class="yellow-text">
How to CSS...
</h1>
<h1 class="yellow-text">
...and Why
</h1>
</div>
<div class="slide">
<h3>
Who's talking?
</h3>
<h2>
Sarah Saltrick Meyer
</h2>
<h3 class="yellow-text">
Twitter: @meyerini
<span style="font-size: 36px;">
💁
</span>
</h3>
</div>
<div class="slide">
<h2>What is a front-end developer's job?</h2>
</div>
<div class="slide">
<h2>Often, it's to change the styling of a page.</h2>
</div>
<div class="slide">
<h2>What's so hard about that?</h2>
</div>
<div class="slide">
<h2>What's so hard about that?</h2>
<ol>
<li>
Finding where to make the change.
</li>
</ol>
</div>
<div class="slide">
<h2>What's so hard about that?</h2>
<ol>
<li>
Finding where to make the change.
</li>
<li>
Ensuring the change only affects what you want it to.
</li>
</ol>
</div>
<div class="slide">
<h2>What's so hard about that?</h2>
<ol>
<li>
Finding where to make the change.
</li>
<li>
Ensuring the change only affects what you want it to.
</li>
<li>
Actually changing the style attribute.
</li>
</ol>
</div>
<div class="slide">
<h2>Why is the following dangerous?</h2>
<pre>
.header .nav .nav-right .item-group .nav-item .button {
color: blue;
margin-right: 1rem;
}
</pre>
</div>
<div class="slide">
<h2>If you wouldn't write this:</h2>
<pre>
.header .nav .nav-right .item-group .nav-item .button {
color: blue;
margin-right: 1rem;
}
</pre>
</div>
<div class="slide">
<h2>Then don't write this!</h2>
<pre>
.header {
.nav {
.nav-right {
.item-group {
.nav-item {
.button {
color: blue;
margin-right: 15px;
}
}
}
}
}
}
</pre>
</div>
<div class="slide">
<h2>CSS Specificity in 1 Slide</h2>
</div>
<div class="slide">
<h2>CSS Specificity in 1 Slide</h2>
<ol>
<li>
Type selectors (e.g., <code>h1</code>) and pseudo-elements (e.g., <code>:before</code>).
</li>
<li>
Class selectors (e.g., <code>.example</code>), attributes selectors (e.g., <code>[type="radio"]</code>) and pseudo-classes (e.g., <code>:hover</code>).
</li>
<li>
ID selectors (e.g., <code>#example</code>).
</li>
</ol>
<p><em>Source: MDN</em></p>
</div>
<div class="slide">
<h2>I lied, it totally takes 2 slides.</h2>
<div class="white-area">
<p>Universal selector (<code>*</code>), combinators (<code>+</code>, <code>></code>, <code>~</code>, <code>' '</code>) and negation pseudo-class (<code>:not()</code>) have no effect on specificity. (The selectors declared inside <code>:not()</code> do, however.)</p>
<p>Inline styles added to an element (e.g., <code>style="font-weight:bold"</code>) always overwrite any styles in external stylesheets, and thus can be thought of as having the highest specificity.</p>
<p>When an <code>!important</code> rule is used on a style declaration, this declaration overrides any other declarations.</p>
<p><em>Source: MDN</em></p>
</div>
</div>
<div class="slide">
<h2>DRY</h2>
<p>"Don't Repeat Yourself" is a programming maxim we've probably all learned.</p>
</div>
<div class="slide">
<h2>DRY</h2>
<p>"Don't Repeat Yourself" is a programming maxim we've probably all learned.</p>
<h3>Forget it while you're writing CSS.</h3>
</div>
<div class="slide">
<h2>Let's talk about BEM.</h2>
</div>
<div class="slide">
<h2>BEM Syntax</h2>
<ol>
<li>
Block: <code>navigation</code>
</li>
<li>
Element: <code>navigation__list-item</code>
</li>
<li>
Modifier: <code>navigation__list-item--disabled</code>
</li>
</ol>
</div>
<div class="slide">
<h2>The problem with BEM:</h2>
<h3>Which one is the block and which is the element?</h3>
</div>
<div class="slide">
<h2>CEM Syntax</h2>
</div>
<div class="slide">
<h2>CEM Syntax</h2>
<ol>
<li>
Component: <code>navigation</code>
</li>
<li>
Element: <code>navigation__list-item</code>
</li>
<li>
Modifier: <code>navigation__list-item--disabled</code>
</li>
</ol>
</div>
<div class="slide">
<h2>Flat stylesheets are the goal.</h2>
</div>
<div class="slide">
<h2><code>!important</code> is not your friend.</h2>
</div>
<div class="slide">
<h2><code>!important</code> is not your friend.</h2>
<h3>We should avoid using it, even (especially) in Solid.</h3>
</div>
<div class="slide">
<h2>Sidebar: Learnings from React</h2>
<h3>Inline styles are cool again</h3>
<p>Truly component-based styles might make future migrations to or from React apps easier.</p>
</div>
<div class="slide">
<h2>No CSS packaging solution is going to work if our CSS has no organizing principle.</h2>
</div>
<div class="slide">
<h2>No CSS packaging solution is going to work if our CSS has no organizing principle.</h2>
<p>Modern front-end build tools muddy the waters of the global CSS namespace. Developer discipline can help.</p>
</div>
<div class="slide">
<h2>Separation of concerns, unity of structure</h2>
<p>Every dev in the front end should be able to figure out the answer to the question "Where do I make this CSS change?" without even thinking about it.</p>
</div>
<div class="slide">
<h2>Recommendations</h2>
<ol>
<li>
BEM (CEM) syntax
</li>
<li>
<code>!important</code> is a code smell
</li>
<li>
Pay attention to the depth of SCSS nesting
</li>
<li>
One SCSS file per template. <code>side-bar/side-bar.html</code> should have a corresponding SCSS file in <code>side-bar/side-bar.scss</code>.
</li>
</ol>
</div>
</div>
</body>
</html>