forked from gdi-curriculum-review/gdi-sass-intro
-
Notifications
You must be signed in to change notification settings - Fork 6
/
class1.html
644 lines (570 loc) · 22.6 KB
/
class1.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Class 1 (Sass, Girl Develop It)</title>
<meta name="description" content="This is the official Girl Develop It Intro to Sass course. Materials by Catherine Farman.
The course is meant to be taught in 2 two-hour sections. Each of the slides and practice files are customizable according to the needs of a given class or audience.">
<meta name="author" content="Girl Develop It">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<link href='http://fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>
<link rel="icon" type="image/png" href="reveal.js/favicon.ico">
<link rel="stylesheet" href="reveal.js/css/reveal.css">
<link rel="stylesheet" href="assets/reveal/theme/gdilight.css" id="theme">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="reveal.js/lib/css/zenburn.css">
<link rel="stylesheet" href="assets/reveal/light.css">
<link rel="stylesheet" href="assets/reveal/fixes.css">
<!-- If use the PDF print sheet so students can print slides-->
<link rel="stylesheet" href="reveal.js/css/print/pdf.css" type="text/css" media="print">
<!--[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">
<!-- Opening slide -->
<section>
<img src = "images/gdi_logo_badge.png" class="badge">
<h3>Intro to Sass</h3>
<h4>Class 1</h4>
</section>
<!-- Opening slide -->
<section>
<h3>Fork Class 1 Example on CodePen:</h3>
<p class="blue" style="font-size: 3em; text-decoration: underline;"><a href="http://bit.ly/gdi-chi-sass">http://bit.ly/gdi-chi-sass</a></p><br><br>
<p><small>Create an account so you can save your work</small></p>
</section>
<!-- Welcome-->
<section>
<h3>Welcome!</h3>
<div>
<p>Girl Develop It is here to provide affordable and accessible programs to learn software through mentorship and hands-on instruction.</p>
<p class ="green">Some "rules"</p>
<ul>
<li>We are here for you!</li>
<li>Every question is important</li>
<li>Help each other</li>
<li>Have fun</li>
</ul>
</div>
</section>
<section>
<h3>Welcome!</h3>
<div class = "left-align">
<p>I'm Arelia Jones</p>
<ul>
<li>Front End Developer at Sprout Social</li>
<li>CoderSpace Co-Founder and Instructor</li>
<li>GDI Chicago co-Chapter Leader</li>
<li>I write HTML, CSS/Sass and JavaScript/React for the Sprout Social web app</li>
</ul>
</div>
</section>
<section>
<h3>Welcome!</h3>
<div class = "left-align">
<p class = "blue">Tell us about yourself.</p>
<ul>
<li>Who are you?</li>
<li>What do you hope to get out of the class?</li>
<li>What's the last song or podcast you listened to?</li>
</ul>
</div>
</section>
<section>
<h3>Note about using CodePen</h3>
</section>
<!--What does Sass do? -->
<section>
<h3>What does Sass do?</h3>
<div class="left-align">
Variables:
<pre><code contenteditable class="sass">
$brandColor: #f90000;
$accentColor: #fff;
header {
background-color: $brandColor;
color: $accentColor;
}
header a { color: $accentColor; }
</code></pre>
</div>
</section>
<!--What does Sass do 2? -->
<section>
<h3>What does Sass do?</h3>
<div class="left-align">
Nesting:
<pre><code contenteditable class="sass css">header {
background-color: $brandColor;
color: $accentColor;
a {
color: $accentColor;
}
}</code></pre>
</div>
</section>
<!--What does Sass do 3? -->
<section>
<h3>What does Sass do?</h3>
<div class="left-align">
Mix-ins:
<pre><code contenteditable class="sass css">@mixin visually-hidden {
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
}
.image-replace {
@include visually-hidden;
background: url(logo.png) no-repeat;
}
</code></pre>
</div>
</section>
<!--What does Sass do 4? -->
<section>
<h3>What does Sass do?</h3>
<div class="left-align">
More examples:
<ul>
<li><a target="_blank" href="http://codepen.io/cfarm/pen/jteAG">Cross-Browser CSS3 Gradients</a></li>
<li><a target="_blank" href="http://codepen.io/cfarm/pen/rkEIo">Cross-Browser Box-shadow (drop shadow) effects</a></li>
<li><a target="_blank" href="http://codepen.io/andrewboyd/pen/LmIxi">Inner Text Shadow effect</a></li>
</ul>
</div>
</section>
<!-- TODO Edit starting here -->
<!-- Tools -->
<section>
<h3>Tools</h3>
<ul>
<li>
<div><span class = "green">Browser:</span> Chrome or Firefox</div>
</li>
<li>
<span class = "green">Dev Tools:</span> In your browser</li>
<li><span class="green">Command Line</span>
<!-- <ul>
<li>Terminal for Mac (Find in Applications> Utilities)</li>
<li>Git for Windows (<a target="_blank" href="https://openhatch.org/missions/windows-setup/install-git-bash">see how to install</a>)
</li>
</ul> -->
</li>
<li>
<div class = "green">Text Editor:</div>
<ul>
<li><a target="_blank" href="http://www.sublimetext.com">Sublime Text</a></li>
<li><a target="_blank" href="https://atom.io/">Atom</a></li>
<li><a target="_blank" href="https://code.visualstudio.com/">VS Code</a></li>
</ul>
</li>
</ul>
</section>
<!-- Terms-->
<section>
<h3>Terms</h3>
<ul>
<li>
<div><span class="green">Ruby:</span> A programming language</div><br>
</li>
<li>
<div><span class="green">Preprocessor:</span> A computer program that modifies data to conform with the input requirements of another program.
<span class ="blue">(Sass is a preprocessor)</span></div><br>
</li>
<li>
<div><span class="green">Compile:</span> The act of converting one computer program into another programming language.</div><br>
</li>
<li>
<div><span class="green">CSS3:</span> The output of Sass. Sass compiles into CSS!</div>
</li>
</ul>
</section>
<!-- Process: Sass to CSS -->
<section>
<h3>Sass and CSS</h3>
<p>How Sass compiles into CSS</p>
<img src = "images/sass-compile.png"/>
<div class="left-align">1. You write Sass (.scss files)<br>
2 .You run a command (sass --watch) on the command line <br>
3. .scss files compile into .css files</div>
</section>
<!-- Nesting -->
<section class="present">
<h3>Nesting</h3>
<div>
<p>Sass input:</p>
<pre><code contenteditable class ="sass css">header {
color: black;
nav {
background: red;
a { color: white; }
}
</code></pre>
<p>CSS output:</p>
<pre><code contenteditable class ="css sass">header { color: black; }
header nav { background: red; }
header nav a { color: white; }</code></pre>
</div>
</section>
<!-- Comparison-->
<section>
<h3>Referencing Parent Selectors: &</h3>
<div>
<p>Sass input:</p>
<pre><code contenteditable class ="sass css">nav {
background: red;
a {
color: white;
&:hover { text-decoration: underline; }
}
}
</code></pre>
<p>CSS output:</p>
<pre><code contenteditable class ="css sass">nav { background: red; }
nav a { color: white; }
nav a:hover { text-decoration: underline; }</code></pre>
</div>
</section>
<!-- TODO End edit here -->
<!-- Exercise - #2? 3? -->
<section>
<h3>Let's Develop It!</h3>
<ul>
<li>Open your fork of the CodePen example #1: <a href='http://bit.ly/gdi-chi-sass'>http://bit.ly/gdi-chi-sass</a></li>
<li>Rewrite some styles to use nesting and referencing the parent</li>
<li>Look for selectors that share a common parent HTML element, like header, nav, footer, #main</li>
<li>Look for hover styles, or add some, to practice referencing the parent with &</li>
<li>There are lots of possible solutions! Be creative!</li>
<li>Toggle the CSS view to see what the 'compiled' code looks like</li>
<!-- <li>Run the <a href="#/17" target="_blank">sass --watch command</a> to see your changes in the browser</li> -->
</ul>
</section>
<!-- BREAK before Part 2 -->
<section>
<h3>Break Time!</h3>
<div>
<p>Stand up and stretch - we'll resume in 5 minutes</p>
<img src="images/stretchbreak.jpg">
</div>
</section>
<!-- Scripting! -->
<section>
<h3>Variables</h3>
<p>Sometimes you want to reuse a value for a style - you use them frequently, they're hard to type or remember, such as</p>
<ul>
<li class = "fragment">Colors
<pre><code contenteditable class = "sass css">#2a79af</code></pre>
</li>
<li class = "fragment"><a target="_blank" href="http://cssfontstack.com/">Font stack styles</a>
<pre><code contenteditable class = "sass css">Georgia, Times, "Times New Roman", serif;</code></pre>
</li>
<li class = "fragment">Font sizes
<pre><code contenteditable class = "sass css">1.667em</code></pre>
</li>
</ul>
</section>
<section>
<h3>Defining Variables</h3>
<p>Variables with Sass let us reuse values more than once, while only defining them in one place</p>
<pre><code contenteditable class = "sass css">//define using dollar sign
$brandColor: #f90000;
$mainTextcolor: #fff;
$accentColor: #ccc;</code></pre>
<p>To create a variable you need a dollar sign before the name of your variable, and a colon: to give it a <em>value</em></p>
<p class="fragment">Note that in Sass files, you can comment out a line with <span class="green">// two slashes</span></p>
</section>
<section>
<pre><code contenteditable class = "sass css">$brandColor: #f90000; // red
$mainTextcolor: #fff; // white
$accentColor: #ccc; // grey</code></pre>
<pre><code contenteditable class = "sass css">header {
color: $mainTextColor;
background-color: $brandColor;
}
.content {
color: $mainTextColor;
background-color: $accentColor;
}
footer {
color: $accentColor;
background-color: $brandColor;
}</code></pre>
</section>
<section>
<h3>Keep em together</h3>
<p>Variables are easy to change if you keep them all in one stylesheet, and update or add to the styles as needed</p>
<pre><code contenteditable class = "php">// Let's define some variables
// Colors
$favoriteColor: #2a79af;
$anotherColor: #f05b62;
// Fonts
$favoriteFont: Papyrus, fantasy;
$aPracticalFont: "Trebuchet MS", "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Tahoma, sans-serif;
// Font sizes
$aNiceBigFontSize: 16px;
$finePrint: 10px;
$giantLogo: 36px;
// Margins and Padding
$defaultMargin: 15px;
$defaultPadding: $defaultMargin;
</code></pre>
</section>
<!-- Exercise -->
<section>
<h3>Let's Develop It</h3>
<ul>
<!-- <li>Create a new Sass stylesheet called _utilities.scss</li> -->
<li>Create a section at the top of your CodePen styles for "Utilities"</li>
<!-- <li>Don't forget to put it in the right folder</li> -->
<!-- <li>Import your new stylesheet into styles.scss by putting the following code at the top of styles.scss:
<pre><code contenteditable class = "sass css">@import "_utilities";
</code></pre>
</li> -->
<li>Under Utilities, make some new variables, and base some variables on your existing styles - look for colors, fonts, and size values</li>
<!-- <li>Run the <a href="#/17" target="_blank">sass --watch command</a> to see your changes in the browser</li> -->
</ul>
</section>
<!-- TODO move to end -->
<!-- Syntax highlighting -->
<!-- <section>
<h3>Syntax highlighting</h3>
<div class="left-align">
<p>You can download tools to highlight your Sass properly in Sublime Text:</p>
<ul>
<li><a target="_blank" href="http://wbond.net/sublime_packages/package_control/installation">Install Package Manager for Sublime Text 2</a></li>
<li>Go to Tools > Command Palette. Type "Package Control".</li>
<li>Click "Install Package"</li>
<li>Type "Sass" and click the first result</li>
<li>Click: View > Syntax > Sass</li>
</div>
</section> -->
<!-- Math -->
<section class="present">
<h3>Math Operations</h3>
<div>
<p>With CSS you have to be explicit about everything, including numbers. With Sass, you can write math to calculate numbers for you:</p>
<table style="display: block;margin: 0 auto; width: 300px;">
<!--tr><th>Symbol</th><th>Meaning</th></tr-->
<tr><td>+</td><td><a target="_blank" href="http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#number_operations">Addition</a></td></tr>
<tr><td>-</td><td><a target="_blank" href="http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#number_operations">Subtraction</a></td></tr>
<tr><td>*</td><td><a target="_blank" href="http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#number_operations">Multiplication</a></td></tr>
<tr><td>/</td><td><a target="_blank" href="http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#division-and-slash">Division</a>*</td></tr>
</table>
<p style="margin-top: 25px;font-size: .6em">*division is special, check the documentation link for why and how</p>
</div>
</section>
<section class="present">
<h3>Math Operations</h3>
<div>
<p>Sass input:</p>
<pre><code contenteditable class ="sass css">$layoutWidth</span>: 960px;
#sidebar {
width: $layoutWidth</span>/3;
}
</code></pre>
<p>CSS output:</p>
<pre><code contenteditable class ="sass css">#sidebar {
width: 320px;
}</code></pre>
</div>
</section>
<section class="present">
<h3>Math Operations</h3>
<div>
<p>Sass input:</p>
<pre><code contenteditable class ="sass css">$layoutWidth</span>: 960px;
$defaultPadding: 16px;
#main {
padding: $defaultPadding;
width: $layoutWidth</span> - $defaultPadding*2;
}
</code></pre>
<p>CSS output:</p>
<pre><code contenteditable class ="sass css">#main {
padding: 16px;
width: 928px;
}</code></pre>
</div>
</section>
<!-- Exercise-->
<section>
<h3>Let's Develop It</h3>
<ul>
<li>Write a math expression in Sass to calculate the width of elements in your page layout instead of declaring a number</li>
<li>Use a variable to represent the result of your calcuation</li>
<li>Take a look at your page to see your changes, and toggle to CSS to see the output</li>
</ul>
<pre><code class ="sass css">$layoutWidth: 960px;
$navWidth: $layoutWidth/3;
footer {
width: ($layoutWidth - 20px);
}</code></pre>
</section>
<section class="present">
<h3>Color Functions</h3>
<p class="left-align">Color functions are built-in to Sass. They let you alter existing color values. This is the <span class="blue">lighten</span> function:</p>
<p>Sass input:</p>
<pre><code contenteditable class ="sass css">
$linkColor: #000;
$linkShadow: lighten(#000, 40%);
a {
color: $linkColor;
text-shadow: $linkShadow;
}
</code></pre>
<p>CSS output:</p>
<pre><code contenteditable class ="sass css">
a {
color: #000;
text-shadow: #666;
}</code></pre>
<p class="output-example" style="color: #000; text-shadow: 3px 2px #666;">Example of output style</p>
</section>
<section class="present">
<h3>Color Functions</h3>
<p class="left-align">This is the <span class="blue">darken</span> function:</p>
<p>Sass input:</p>
<pre><code contenteditable class ="sass css">
$background: #ff0000; // red
$text: darken($background,50%);
body {
color: $text;
background: $background;
}
</code></pre>
<p>CSS output:</p>
<pre><code contenteditable class ="sass css">body {
color: #990000;
background: #ff0000;
}</code></pre>
<p class="output-example" style="background-color: #f00; color: #900">Example of output style</p>
</section>
<section class="present">
<h3>Color Functions</h3>
<p class="left-align">This is the <span class="blue">grayscale</span> function:</p>
<p>Sass input:</p>
<pre><code contenteditable class ="sass css">
$background: #ff0000; // red
$text: darken($background,50%);
body {
background: grayscale(#f00);
color: grayscale(darken(#f00, 50%));
}
</code></pre>
<p>CSS output:</p>
<pre><code contenteditable class ="sass css">
body {
background: #000;
color: #808080;
}</code></pre>
<p class="output-example grayscale" style="background: #000; color: #808080;">Example of output style</p>
</section>
<!-- Exercise-->
<section>
<h3>Let's Develop It</h3>
<ul>
<li>Edit your variables under Utilities to use color functions</li>
<li>Refer to the <a target="_blank" href="http://sass-lang.com/docs/yardoc/Sass/Script/Functions.html">sass-lang.com docs</a></li>
<li>Toggle to CSS to see your changes</li>
<li class="blue">Bonus - change the color scheme of your website while only editing the color variables!</li>
</ul>
<pre><code class ="sass css">lighten(#000, 20%)
darken(#eee, 30%)
grayscale(#2a79af)
saturate(#2a79af, 40%)
invert(#2a79af)</code></pre>
</section>
<section class="present">
<h3>Comments</h3>
<p class="left-align">Traditional CSS comments are downloaded by the user. With Sass, we can specify whether comments are left in the final CSS code or are only visible to the developer:</p>
<p>Sass input:</p>
<pre><code contenteditable class ="sass css">
/* Multiline comments will appear
in the final CSS file */
//This single-line comment won't
a { color: blue; }
</code></pre>
<p>CSS output:</p>
<pre><code contenteditable class ="sass css">
/* Multiline comments will appear
in the final CSS file */
a { color: blue; }</code></pre>
</section>
<section class="present">
<h3>Mixins</h3>
<p class="left-align">Mixins are really just a collection of one or more styles that are reusable, like variables are reusable values</p>
<p>Sass input:</p>
<pre><code contenteditable class ="sass css">
@mixin dropshadow($text) {
color: $text;
text-shadow: 2px 4px lighten($text, 50%);
}
p {
@include dropshadow(black);
}
</code></pre>
<p>CSS output:</p>
<pre><code contenteditable class ="sass css">
p {
color: black;
text-shadow: 2px 4px #808080;
}</code></pre>
<p class="output-example" style="color: black; text-shadow: 2px 4px #808080; background: transparent;">Example of output style</p>
</section>
<section class="present">
<h3>Mixins</h3>
<p class="left-align">These are especially useful for CSS3 rules that need browser prefixes, like gradients.</p>
<p><a target="_blank" href="http://codepen.io/cfarm/pen/jteAG">http://codepen.io/cfarm/pen/jteAG</a></p>
</section>
<!-- Exercise-->
<section>
<h3>Let's Develop It</h3>
<ul>
<li>Add some mixins under Utilities - a good candidate is any style that needs a browser prefix</li>
<li>Try replacing the footer gradient with a mixin</li>
<li>Use these mixins in your footer styles</li>
<li>Add different types of comments that describe what your mixins do, and check the final CSS in the browser inspector to see if they appear</li>
</ul>
<pre><code class ="sass css">@mixin name {
property: value;
}
@mixin example($argument) {
property: value;
property: $argument;
}
</code></pre>
</section>
<!-- -->
<section>
<h2>Questions?</h2>
</section>
</div>
</div>
<script src="reveal.js/lib/js/head.min.js"></script>
<script src="reveal.js/js/reveal.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'none', // default/cube/page/concave/zoom/linear/none
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: 'reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'reveal.js/plugin/markdown/showdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'reveal.js/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'reveal.js/plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
{ src: 'reveal.js/plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }
]
});
</script>
</body>
</html>