forked from wearescytale/css
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpresentation.html
503 lines (364 loc) · 8.67 KB
/
presentation.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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
<meta charset="utf-8">
<style>
@import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:200italic,400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,400italic,600italic,600);
html {
-webkit-font-smoothing: antialiased;
}
body, h1, h2, h3 {
font-family: 'Open Sans', sans-serif;
font-weight: 300;
}
.remark-container {
background: #263238;
}
.remark-slide-scaler {
box-shadow: none;
}
h1 {
color: #ECEFF1;
}
h2 {
color: #B0BEC5;
font-weight: 400;
}
h3 {
color: #9E9E9E;
}
a {
color: #2196F3;
text-decoration: none;
}
.colored {
background: #607D8B;
}
.colored h2 {
font-weight: 300;
}
strong {
color: #607D8B;
}
.remark-code, .remark-inline-code { font-family: 'Ubuntu Mono'; }
.remark-inline-code {
background: #ECEFF1;
color: #37474F;
font-style: italic;
padding: 0 5px;
}
</style>
</head>
<body>
<textarea id="source">
class: center, middle, colored
## Scytale's
# CSS/SCSS Guidelines
---
class: center, middle
## CSS
---
### Formatting
- [2.1.1](#2.1.1) <a name='2.1.1'></a> Use soft tabs (4 spaces) for indentation. This improves readability and keeps the space uniform
```css
// bad
.avatar{
border-radius: 50%;
}
// good
.avatar{
border-radius: 50%;
}
```
---
### Formatting
- [2.1.2](#2.1.2) <a name='2.1.2'></a> Use classes for all selectors. Ids are reserved for E2E testing and data arguments are for JS libraries
```css
// bad
#panel {
/* ... */
}
[data-panel] {
/* ... */
}
// good
.panel {
/* ... */
}
```
---
### Formatting
- [2.1.3](#2.1.3) <a name='2.1.3'></a> Avoid using tag selectors. Tag selectors come at a small performance penalty
```css
// bad
h3 {
/* ... */
}
// good
.subtitle {
/* ... */
}
```
---
### Formatting
- [2.1.4](#2.1.4) <a name='2.1.4'></a> When using multiple selectors in a rule declaration, give each selector its own line. This way its much easier to find selectors when scanning the document
```css
// bad
.panel, .box {
/* ... */
}
// good
.panel,
.box {
/* ... */
}
```
---
### Formatting
- [2.1.5](#2.1.5) <a name='2.1.5'></a> Put a space before the opening brace `{` in rule declarations. In properties, put a space after, but not before, the `:` character. Put closing braces `}` of rule declarations on a new line. Put blank lines between rule declarations
```css
// bad
.panel{
font-size:2px;color:white}
// good
.panel {
font-size: 2px;
color: white;
}
```
---
class: center, middle
## SCSS
---
### Syntax
- [3.1.1](#3.1.1) <a name='3.1.1'></a> Use the `.scss` syntax, never the original `.sass` syntax
- [3.1.2](#3.1.2) <a name='3.1.2'></a> Order your `@extend`, `@include` declarations and regular CSS lastly with a newline between the last two.
```css
.btn-green {
@extend %btn;
@include transition(background 0.5s ease);
background: green;
font-weight: bold;
}
```
---
### Syntax
- [3.1.3](#3.1.3) <a name='3.1.3'></a> Nested selectors, _if necessary_, go last, and nothing goes after them. Add whitespace between your rule declarations and nested selectors, as well as between adjacent nested selectors. Apply [3.1.2](#3.1.2) as above to your nested selectors.
```css
.btn {
@extend %btn;
background: green;
font-weight: bold;
@include transition(background 0.5s ease);
.icon {
margin-right: 10px;
}
}
```
---
### Mixins
Mixins, defined via `@mixin` and called with `@include`, should be used sparingly and only when function arguments are necessary. A mixin without function arguments (i.e. `@mixin hide { display: none; }`) is better accomplished using a placeholder selector (see below) in order to prevent code duplication.
---
### Placeholders
Placeholders in Sass, defined via `%selector` and used with `@extend`, are a way of defining rule declarations that aren't automatically output in your compiled stylesheet. Instead, other selectors “inherit” from the placeholder, and the relevant selectors are copied to the point in the stylesheet where the placeholder is defined. This is best illustrated with the example below.
---
**Sass**
```css
// Unless we call `@extend %icon` these properties won't be compiled!
%icon {
font-family: "Airglyphs";
}
.icon-error {
@extend %icon;
color: red;
}
.icon-success {
@extend %icon;
color: green;
}
```
**Compiled CSS**
```css
.icon-error,
.icon-success {
font-family: "Airglyphs";
}
.icon-error {
color: red;
}
.icon-success {
color: green;
}
```
---
### Nested selectors
**Do not nest selectors more than three levels deep!**
```css
.page-container {
.content {
.profile {
// STOP!
}
}
}
```
When selectors become this long, you're likely writing CSS that is:
* Strongly coupled to the HTML (fragile) *—OR—*
* Overly specific (powerful) *—OR—*
* Not reusable
---
class: center, middle
### Conventions
---
- [5.1](#5.1) <a name='5.1'></a> Every colors need to be on the `colors.scss` file. The color name should have a `brand-` prefix for the brand primary colors and a tone as a suffix.
```sass
// bad
$green: green;
$green-2: green;
//good
$brand-green: green;
$brand-green-light: green;
```
---
- [5.2](#5.2) <a name='5.2'></a> For colors where the opacity changes a suffix must be added from the available list:
* `-xs`
* `-s`
* `-m`
* `-l`
* `-xl`
* `-xxl`
* `-xxxl`
---
class: center, middle
## RSCSS
---
### Components

- [4.1.1](#4.1.1) <a name='4.1.1'></a> Name components will be named with at least two workds, seperated by a dash.
```css
.like-button {
/* ... */
}
.search-form {
/* ... */
}
```
---
### Elements

- [4.2.1](#4.2.1) <a name='4.2.1'></a> Each component may have elements. They should have classes that are only one word.
```css
.search-form {
> .field {
/* ... */
}
> .action {
/* ... */
}
}
```
---
### Elements

- [4.2.2](#4.2.2) <a name='4.2.2'></a> Always prefer to use the `>` child selector whenever possible.
```css
.article-card {
.title {
/* okay */
}
> .author {
/* better */
}
}
```
---
### Elements

- [4.2.3](#4.2.3) <a name='4.2.3'></a> For elements that need two or more words, concatenate them without dashes or underscores.
```css
.profile-box {
> .firstname {
/* ... */
}
> .lastname {
/* ... */
}
}
```
---
### Variants

- [4.3.1](#4.3.1) <a name='4.3.1'></a> Variants customize a component or an element. Variants are prefixed by a dash `-`.
---
### Variants

```css
.search-form {
&.-prefixed {
/* ... */
}
&.-compact {
/* ... */
}
}
```
---
### Nested components

- [4.4.1](#4.4.1) <a name='4.4.1'></a> When a component may need to appear a certain way when nested in another component. Avoid modifying the nested component by reaching into it from the containing component. Instead, prefer to add a variant to the nested component and apply it from the containing component.
---
### Nested components

```css
// bad
.article-header {
> .vote-box > .up {
/* ... */
}
}
// good
.vote-box {
&.-highlight > .up {
/* ... */
}
}
```
---
### Layouts
- [4.5.1](#4.5.1) <a name='4.5.1'></a> Components should be made in a way that they're reusable in different contexts. Avoid putting these properties in components:
* Positioning (`position`, `top`, `left`, `right`, `bottom`)
* Floats (`float`, `clear`)
* Margins (`margin`)
* Dimensions (`width`, `height`)
---
### Layouts
If you need to define these, try to define them in whatever context they will be in.
```css
.article-list {
& {
@include clearfix;
}
> .article-card {
width: 33.3%;
float: left;
}
}
.article-card {
/* ... */
}
```
---
class: center, middle
## Thank you
</textarea>
<script src="https://gnab.github.io/remark/downloads/remark-latest.min.js">
</script>
<script>
var slideshow = remark.create({
highlightStyle: 'zenburn'
});
</script>
</body>
</html>