-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·1292 lines (1077 loc) · 39.5 KB
/
index.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
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>HTML5 CSS3 BEST PRACTICES</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/solarized.css" id="theme">
<!-- Code syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h1>CSS AND HTML</h1>
<h2>Best practices</h2>
<p>
A brief explanation on what to do and what not to,<br>
when writing HTML and CSS.
</p>
<p>
<small>
Created by <a href="mailto:[email protected]">Alessandro Vioni</a> for <a href="http://www.objectway.com">Objectway.com</a><br>
BEM slides by <a href="mailto:[email protected]">Giacomo Zinetti</a><br>
Made with <a href="https://github.com/hakimel/reveal.js" target="_blank">Reveal.js</a>
</small>
</p>
</section>
<!-- SCOPE OF THE COURSE -->
<section>
<section>
<h1>WHERE ARE WE FROM</h1>
</section>
<section>
<p>We are from a place where every coder has been sometime in its life:</p>
<p class="fragment">The house of unmaintainable and badly written code.</p>
</section>
<section>
<h1>WHERE ARE WE GOING</h1>
</section>
<section>
<h2>We are going in the land of</h2>
<ul>
<li class="fragment">Better knowledge of OW actual technology stack</li>
<li class="fragment">FED (front end development) best practices</li>
<li class="fragment">Explain the meaning of BEM, ITCSS, SASS, preprocessors and task runners</li>
</ul>
</section>
<section>
<h2>At the end of this course</h2>
<ul>
<li class="fragment">You'll understand how to save thousand of kittens</li>
<li class="fragment">You will be able to optimize your code and your projects</li>
<li class="fragment">You will be able to improve the maintainability of your projects</li>
</ul>
<p>
<small class="fragment">hopefully :)</small>
</p>
</section>
</section>
<!-- FIRST SECTION HTML/CSS IS EASY -->
<section>
<section>
<h2>HTML and CSS are EASY</h2>
<ul>
<li>Accessible languages</li>
<li>Permissive rules</li>
</ul>
</section>
<section>
<h3>It's easy to screw up a project</h3>
<p>
Modern web development is complicated, projects
are huge, complexity is increasing day by day.
</p>
<p>
<small>Just think at the number of languages, libraries and technologies for the front-end development:</small>
<small>Nodejs, Angular, React, Jade ...</small>
</p>
</section>
<section>
<h2>Maintenance is the key</h2>
<ul>
<li><b>ALWAYS</b> use external style sheets</li>
<li><b>ALWAYS</b> use external js files</li>
<li class="fragment">Do <b>NOT</b> use tables of tables of tables ...</li>
<li class="fragment">Use semantic class names</li>
<li class="fragment">Write maintainable code
<ul class="fragment">
<li>Use preprocessors
<ul>
<li class="fragment">mixins</li>
<li class="fragment">placeholders</li>
<li class="fragment">variables</li>
</ul>
</li>
</ul>
</li>
</ul>
</section>
<section>
<h6>Maintenance is the key</h6>
<ul>
<li>Limit the use of JavaScript to the strict necessary
<ul>
<li class="fragment">Use CSS whenever is possible</li>
<li class="fragment">Do not use js to replace CSS functionalities</li>
</ul>
</li>
</ul>
</section>
<section>
<h6>Maintenance is the key</h6>
<ul>
<li>Adopt methodologies like BEM and ITCSS
<ul>
<li class="fragment">To produce maintainable code</li>
<li class="fragment">Important to follow a methodology</li>
</ul>
</li>
<li>Use linters
<ul>
<li class="fragment">To check code</li>
<li class="fragment">To standardize the code written by team members</li>
</ul>
</li>
</ul>
</section>
<section>
<h1>Maintenance is the key</h1>
</section>
</section>
<!-- EXAMPLES -->
<section>
<section>
<h1>SOME EXAMPLES</h1>
</section>
<section data-markdown>
<script type="text/template">
## What's wrong with this?
```html
<div class="headerOne" style="background: blue;">
<div class="headerContent" style="position: absolute; top: 0; right: 0;">
<input type="text" style="border: 1px solid red;">
</div>
</div>
```
</script>
</section>
<section>
<ul>
<li>Inline CSS is <b>NOT</b> maintainable</li>
<li class="fragment">CSS classes with inline CSS?!</li>
<li class="fragment"><b>Inline CSS!</b></li>
</ul>
<p>
<small class="fragment">On a side note, 4 kittens died while I was writing that code</small>
</p>
</section>
<section>
<h1>TABLES</h1>
<small class="fragment">what's wrong with them ?</small>
</section>
<section>
<ul>
<li>They're slow</li>
<li>Hard to maintain</li>
<li>They should be used for content not for layout !</li>
</ul>
</section>
<section>
<h3>Every time you are nesting a table a kitten dies...</h3>
</section>
<section>
<h2>What we should use?</h2>
<ul>
<li>Easily maintainable code
<ul>
<li>Atomization of the elements
<ul>
<li>Break into small pieces of repeatable code</li>
<li class="fragment">Buttons, tables, form fields ...</li>
</ul>
</li>
</ul>
</li>
</ul>
</section>
<!-- SASS -->
<section>
<h2>SASS helps</h2>
<p>Use of placeholders and variables can help to keep the front-end structure clean</p>
<pre><code class="SCSS" data-trim data-noescape>
// -----------
// DATE PICKER
// -----------
%DatePicker {
background: $white;
border-radius: 0.187em;
width: em-calc(280);
}
</code></pre>
</section>
<section>
<h2>EXTEND!</h2>
<pre><code class="SCSS" data-trim data-noescape>
.HeaderDateSelector {
@extend %DatePicker;
// overrides
...
}
</code></pre>
</section>
<section>
<h2>Wrong!</h2>
<h3>Two identical elements made with different piece of code !</h3>
<p>For example, two similar input field, two buttons...</p>
</section>
<section>
<h2>Correct!</h2>
<img src="./images/illumas-ks.png">
</section>
<section>
<h3>From the Illumas refactoring project</h3>
<ul>
<li>Create a KitchenSink</li>
<li>Create basic reusable elements</li>
<li class="fragment">Use them on your project :)</li>
</ul>
</section>
<section>
<h3>Input field example</h3>
<img src="./images/ks-2-form.png">
</section>
<section>
<h1>WHICH MEANS</h1>
<p class="fragment">An input field usable everywhere, same structure for every similar elements on the page</p>
<p class="fragment"><b>Keyword</b>: <u>simplification</u></p>
</section>
<section>
<small>FROM OUR EXPERIENCE</small>
<h2>KitchenSink is the key</h2>
<h3 class="fragment">Write reusable elements made with reusable code</h3>
<h3 class="fragment">Simplify, do not overcomplicate your code</h3>
<h3 class="fragment">Avoid at all cost duplication</h3>
</section>
<section>
<h3>Every time you're duplicating a line of code or an element a kitten dies!</h3>
</section>
<section>
<h1>KEEP IT SIMPLE</h1>
</section>
</section>
<!-- TASK RUNNERS -->
<section>
<section>
<h1>TASK RUNNERS</h1>
<p>The bread and butter of modern web development</p>
</section>
<section>
<h2>What are they?</h2>
<ul class="fragment">
<li>They compile, lint, merge, clean, minify code</li>
<li>They integrate with modern FED workflows because...</li>
<li class="fragment">...they are CLI's (command line interface)</li>
</ul>
</section>
<section>
<h2>CLI</h2>
<img class="is-borderless" src="./images/cli.png">
</section>
<section>
<p>
Most of the Front-end development nowadays is made with the use of CLI's,
and most of our work involves, at some degree, the use of at least one compilator (SASS).
</p>
</section>
<section>
<h2>EMBRACE THE POWER OF THE CLI</h2>
</section>
<section>
<h2>GULP GRUNT BROCCOLI AND THE LIKES...</h2>
</section>
<section>
<p>
There are more than a few task runners, some used more than others, the choice we made is based on speed, scripting language and reliability.
</p>
</section>
<section>
<img src="./images/gulp-white-text.svg" alt="Gulp" class="is-borderless">
<br>
<img src="./images/node.png" alt="Gulp" class="is-borderless" style="max-width: 15%; max-height: 15%; background: #333; padding: 30px 40px;">
<p>
<b>Gulp</b> is written in <b>Nodejs</b>, it's probably the fastest of the group, it is extremely solid and widely used.
</p>
</section>
<section>
<h2>Hot to use Gulp</h2>
<p>From <a href="https://raw.githubusercontent.com/gulpjs/gulp/master/docs/getting-started.md">Gulp getting started documentation</a></p>
</section>
<section data-markdown>
<script type="text/template">
### 1. Install gulp globally:
__If you have previously installed a version of gulp globally, please run `npm rm --global gulp`
to make sure your old version doesn't collide with gulp-cli.__
```sh
$ npm install --global gulp-cli
```
</script>
</section>
<section data-markdown>
<script type="text/template">
### 2. Install gulp in your project devDependencies:
```sh
$ npm install --save-dev gulp
```
</script>
</section>
<section data-markdown>
<script type="text/template">
### 3. Create a gulpfile.js at the root of your project:
```js
var gulp = require('gulp');
gulp.task('default', function() {
// place code for your default task here
});
```
</script>
</section>
<section data-markdown>
<script type="text/template">
### 4. Run gulp:
```sh
$ gulp
```
</script>
</section>
<section data-markdown>
<script type="text/template">
The default task will run and do nothing.
To run individual tasks, use `gulp <task> <othertask>`.
</script>
</section>
<section data-markdown>
<script type="text/template">
## Where do I go now?
You have an empty gulpfile and everything is installed. How do you REALLY get started? Check out the [recipes](recipes) and the [list of articles](README.md#articles) for more information.
</script>
</section>
<section data-markdown>
<script type="text/template">
## .src, .watch, .dest, CLI args - How do I use these things?
For API specific documentation you can check out the [documentation for that](API.md).
</script>
</section>
<section data-markdown>
<script type="text/template">
## Available Plugins
The gulp community is growing, with new plugins being added daily. See the [main website](http://gulpjs.com/plugins/) for a complete list.
</script>
</section>
<section>
<h2>A simple task to compile SASS</h2>
<pre><code data-noescape data-trim>
npm install gulp-sass --save-dev
</code></pre>
<pre><code class="js" data-trim data-noescape>
var gulp = require('gulp');
var sass = require('gulp-sass');
gulp.task('sass', function () {
return gulp.src('./sass/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./css'));
});
gulp.task('sass:watch', function () {
gulp.watch('./sass/**/*.scss', ['sass']);
});
</code></pre>
</section>
<section>
<h2>Our Gulp structure</h2>
<pre><code class="txt" data-trim data-noescape>
.
├── gulpfile.babel.js
└── tasks
├── gulp.autoreload.js
├── gulp.browsersync.js
├── gulp.clean.js
├── gulp.copy.js
├── gulp.jade.js
├── gulp.minify.js
├── gulp.sass-lint.js
├── gulp.sass.js
├── gulp.script.js
├── gulp.stylestats.js
├── gulp.svgsprite.js
├── gulp.vendor.js
└── gulp.watch.js
</pre></code>
</section>
<section>
<ul>
<li>Modular</li>
<li class="fragment">ECMAScript 6 <span class="fragment">with the aid of <a href="https://babeljs.io/">Babeljs</a></span></li>
<li class="fragment">Easier to maintain</li>
<li class="fragment">Some complexity could result in a steeper learning curve</li>
</ul>
</section>
<section>
<h2>But...</h2>
<ul>
<li class="fragment">We don't need this level of complexity</li>
<li class="fragment">We can run a SASS compiler and a linter...</li>
<li class="fragment">...or we can customize what we have to reach the level of complexity required</li>
</ul>
</section>
<section>
<h2>Keep in mind</h2>
<p class="fragment">
We can modify what we already have, we can build a custom Gulp structure
we can keep it simple and we can enforce the linting of SASS files and therefore our
style guides.
</p>
<p class="fragment">
Most importantly: <span class="fragment"><b>we can and we have to write better code.</b></span>
</p>
</section>
</section>
<!-- SASS -->
<section>
<section>
<img src="./images/sass.svg" alt="SASS" class="is-borderless">
</section>
<section>
<h2>Syntactically Awesome Style Sheets</h2>
<p class="fragment"><a href="http://sass-lang.com/">Sass website</a></p>
</section>
<section>
<h2>What is SASS</h2>
<p>Sass is the most mature, stable, and powerful professional grade CSS extension language in the world.</p>
</section>
<section>
<h2>CSS COMPATIBLE</h2>
<p>Sass is completely compatible with all versions of CSS. They take this compatibility seriously, so that we can seamlessly use any available CSS libraries.</p>
</section>
<section>
<h2>FEATURE RICH</h2>
<p>Sass boasts more features and abilities than any other CSS extension language out there. The Sass Core Team has worked endlessly to not only keep up, but stay ahead.</p>
</section>
<section>
<h2>MATURE</h2>
<p>Sass has been actively supported for over 9 years by its loving Core Team.</p>
</section>
<section>
<h2>INDUSTRY APPROVED</h2>
<p>Over and over again, the industry is choosing Sass as the premier CSS extension language.</p>
</section>
<section>
<h2>LARGE COMMUNITY</h2>
<p>Sass is actively supported and developed by a consortium of several tech companies and hundreds of developers.</p>
</section>
<section>
<h2>FRAMEWORKS</h2>
<p>There are endless number of frameworks built with Sass. Compass, Bourbon, and Susy just to name a few.</p>
</section>
<section>
<h2>Some more...</h2>
<ul>
<li>Sass definitions cannot be used directly within a browser.</li>
<li>They are compiled using a “pre-processor” into standard css.</li>
<li>Sass allows you to use things like variables, nested rules, inline imports and more.</li>
<li>It also helps to keep things organized and allows you to create stylesheets faster.</li>
</ul>
</section>
<section>
<h2>Partials and Imports</h2>
<p>You can create partial Sass files that contain little snippets of CSS that you can include in other Sass files. This is a great way to modularize your CSS and help keep things easier to maintain.</p>
<pre><code class="scss" data-trim data-noescape>
// _reset.scss
html,
body {
margin: 0;
padding: 0;
}
</code></pre>
<pre><code class="scss" data-trim data-noescape>
// main.scss
@import 'reset';
</code></pre>
</section>
<section>
<h2>Nesting</h2>
<pre><code class="SCSS" data-trim data-noescape>
.class {
.class {
...
}
}
</code></pre>
</section>
<section>
<h2>variables</h2>
<pre><code class="scss" data-trim data-noescape>
$variable = red;
</code></pre>
</section>
<section>
<h2>Placeholders</h2>
<pre><code class="scss" data-trim data-noescape>
%GenericButton {
...
}
.MyButton {
@extend %GenericButton;
}
</code></pre>
</section>
<section>
<h2>Mixins</h2>
<pre><code class="scss" data-trim data-noescape>
@mixin border-radius($radius) {
border-radius: $radius;
}
.box { @include border-radius(10px); }
</code></pre>
</section>
<section>
<h2>Extend/Inheritance</h2>
<pre><code class="scss" data-trim data-noescape>
.message {
border: 1px solid #ccc;
padding: 10px;
color: #333;
}
.success {
@extend .message;
border-color: green;
}
.error {
@extend .message;
border-color: red;
}
</code></pre>
</section>
<section>
<h2>@if</h2>
<pre><code class="scss" data-trim data-noescape>
$type: monster;
p {
@if $type == ocean {
color: blue;
} @else if $type == matador {
color: red;
} @else if $type == monster {
color: green;
} @else {
color: black;
}
}
</code></pre>
<pre><code class="css" data-trim data-noescape>
p {
color: green; }
</code></pre>
</section>
<section>
<h2>@for</h2>
<pre><code class="scss" data-trim data-noescape>
@for $i from 1 through 3 {
.item-#{$i} { width: 2em * $i; }
}
</code></pre>
<pre><code class="css" data-trim data-noescape>
.item-1 {
width: 2em; }
.item-2 {
width: 4em; }
.item-3 {
width: 6em; }
</code></pre>
</section>
<section>
<h2>@each</h2>
<pre><code class="scss" data-trim data-noescape>
@each $animal in puma, sea-slug, egret, salamander {
.#{$animal}-icon {
background-image: url('/images/#{$animal}.png');
}
}
</code></pre>
<pre><code class="css" data-trim data-noescape>
.puma-icon {
background-image: url('/images/puma.png'); }
.sea-slug-icon {
background-image: url('/images/sea-slug.png'); }
.egret-icon {
background-image: url('/images/egret.png'); }
.salamander-icon {
background-image: url('/images/salamander.png'); }
</code></pre>
</section>
<section>
<h2>@while</h2>
<pre><code class="scss" data-trim data-noescape>
$i: 6;
@while $i > 0 {
.item-#{$i} { width: 2em * $i; }
$i: $i - 2;
}
</code></pre>
<pre><code class="css" data-trim data-noescape>
.item-6 {
width: 12em; }
.item-4 {
width: 8em; }
.item-2 {
width: 4em; }
</code></pre>
</section>
</section>
<!-- LINTER -->
<section>
<section>
<h1>Lint (software)</h1>
</section>
<section>
<p>
In computer programming, lint is a Unix utility that flags some suspicious and non-portable constructs (likely to be bugs) in C language source code;<br>
</p>
<p class="fragment">
generically, lint or a linter is any tool that flags suspicious usage in software written in any computer language.
</p>
<p class="fragment">
The term lint-like behavior is sometimes applied to the process of flagging suspicious language usage.
</p>
<p class="fragment">
Lint-like tools generally perform static analysis of source code.
</p>
</section>
<section>
<h2>What we lint ?</h2>
<ul>
<li class="fragment">SCSS</li>
<li class="fragment">JavaScript
<ul>
<li class="fragment"><a href="http://eslint.org/">ESlint</a></li>
<li class="fragment"><a href="http://jshint.com/">JSHint</a></li>
</ul>
</li>
<li class="fragment">Typescript</li>
<li class="fragment">Jade</li>
<li class="fragment">HTML</li>
</ul>
</section>
<section>
<h2>How do we lint ?</h2>
<ul>
<li class="fragment">Editors</li>
<li class="fragment">Task runners (GULP)</li>
</ul>
<p class="fragment">
Every linter has a configuration file that can be used to personalize many aspect of the syntax.
</p>
<p class="fragment">
<a href="https://github.com/brigade/scss-lint/blob/master/config/default.yml" target="_blank">SCSS-LINT default configuration file</a>
it is more than 250 lines settings to help you obtain styling uniformity between team members and to prevent errors.
</p>
</section>
<section>
<h1><a href="https://github.com/brigade/scss-lint">SCSS LINT</a></h1>
</section>
<section>
<p>
You can lint your SCSS files using scss-lint which can be configured to bring
same code consistence and cleanness across the board.
</p>
<p class="fragment">
It can be configured on <b>Gulp</b> or on many major editors (Vim, Emacs, Atom, Sublime).
</p>
</section>
</section>
<!-- BEM -->
<section>
<section>
<h1><a href="https://en.bem.info/" target="_blank">BEM</a></h1>
<h3>BLOCK ELEMENT MODIFIER</h3>
<p>
At <a href="https://github.com/Objectway/styleguides/blob/master/frontend-styleguides.md">this link</a>
there is a short description on how we are using <strong>BEM</strong> at Objectway.
</p>
</section>
<section>
The main idea of BEM methodology is to speed development process up and ease the teamwork of developers.
</section>
<section data-markdown>
<script type="text/template">
## Block
- the Block is the top level wrapper
- name in `PascalCase`
- one single file for each Block
- font size in `rem`
```
.SearchBox {
padding: 20px;
font-size: 2rem;
...
}
```
</script>
</section>
<section data-markdown>
<script type="text/template">
## Element
- an Element is a single part of a Block
- name in `camelCase`
- prefixed by double underscores `__`
- font-size in `em` so the Block can scale easily and consistently
```
.SearchBox__inputField {
...
}
.SearchBox__mainButton {
font-size: 2em;
...
}
```
</script>
</section>
<section data-markdown>
<script type="text/template">
## Modifier
- a variation of the block or of the element
- name in `camelCase`
- prefixed by double dash `--`
- font-size in `em`
```
/* Block modifier */
.SearchBox--compact {
padding: 0;
}
/* Element modifier */
.SearchBox__mainButton--small {
font-size: 1.4em;
}
```
</script>
</section>
<section data-markdown>
<script type="text/template">
## State classes
- a class that can change during the life of the application
- name in `camelCase`
- prefixed by `is-`
- **MUST** always been combined to a Block or to an Element
- font-size in `em`
```
.SearchBox__mainButton.is-focused {
transform: scale(1.2);
}
```
</script>
</section>
<section data-markdown>
<script type="text/template">
## Utility classes
- a class to provide common functionalities
- prefixed by a `u-`
- name in `camelCase`
- can use `!important` [Use only proactively, not reactively!]
```
.u-alignRight {
text-align: right !important;
}
.u-hidden {
display: none !important;
}
```
</script>
</section>
<section data-markdown>
<script type="text/template">
## JS hooks
Never use styling classes for js functionalities, use ad-hoc classes prefixed by `js-`
</script>
</section>
<section data-markdown>
<script type="text/template">
## Semantic Class Names
Using a class name to describe content is redundant because content describes itself.
We need a class name that describes the style that we want to apply to that element with a good abstraction
```
/* Runs the risk of becoming out of date; not very maintainable. */
.blue {
color: blue;
}
/* Too specific; limits our ability to reuse. */
.header-color {
color: blue;
}
/* Nicely abstracted, very portable, doesn’t risk becoming out of date. */
.highlight-color {
color: blue;
}
```
</script>
</section>
</section>
<!-- ITCSS -->
<section>
<section>
<h1><a href="https://speakerdeck.com/dafed/managing-css-projects-with-itcss" target="_blank">ITCSS</a></h1>
<h2>Inverted Triangle architecture for CSS</h2>
<p>By <a href="https://twitter.com/csswizardry" target="_blank">Harry Roberts</a></p>
</section>
<section>
<p>
<b>ITCSS</b> is a set of conventions for creating your css architecture.
CSS definitions are grouped together in categories (layers) that reflect the different levels of specificity.
</p>
</section>
<section>
<img src="./images/itcss/page-1.jpg">
</section>
<section>