forked from marcysutton/gdi-sass
-
Notifications
You must be signed in to change notification settings - Fork 1
/
class2.html
562 lines (500 loc) · 21.7 KB
/
class2.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Class 2 - Intro to Sass, Girl Develop It</title>
<meta name="description" content="This is the official Girl Develop It Intro to Sass course.
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 rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/simple.css" id="theme">
<!-- For syntax highlighting -->
<!-- light editor<link rel="stylesheet" href="lib/css/light.css">-->
<!-- dark editor--><link rel="stylesheet" href="lib/css/dark.css">
<link rel="stylesheet" href="lib/css/zenburn.css">
<link rel="stylesheet" href="plugin/accessibility-helper/css/accessibility-helper.css">
<!-- If the query includes 'print-pdf', include the PDF print sheet -->
<script>
if( window.location.search.match( /print-pdf/gi ) ) {
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'css/print/pdf.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
}
</script>
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<!--[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="img/gdi_logo_badge.png" alt="Girl Develop It" style="max-height:300px;">
<h1>Intro to Sass</h2>
<h2>Class 2</h2>
</section>
<!-- Opening slide -->
<section>
<h2>Download Class 2 Files:</h2>
<p><a href="http://gdiseattle.github.io/gdi-sass/class2-exercises.zip">http://gdiseattle.github.io/gdi-sass/class2-exercises.zip</a></p>
</section>
<section>
<h3>Review: Watching for Changes</h3>
<div class="left-align">
<p>First, navigate via the command line to your /class2-exercises/practice/stylesheets directory.</p>
<p>Then type:</p>
<pre><code contenteditable class ="sass css">$ sass --watch scss:css</code></pre>
</div>
</section>
<section>
<h3>Review: Extends</h3>
<div class="left-align">
<p>Create an extend in _utilities:</p>
<ul>
<li>clearfix</li>
</ul>
<pre><code class ="php">%yourExtendName {
property: value;
}
// example usage
p {
@extend %yourExtendName;
}
</code></pre>
</div>
</section>
<!-- Review/Exercise 1 -->
<section>
<h3>Review: Mixins</h3>
<div class="left-align">
<p>Create these mixins in _utilities:</p>
<ul>
<li><a href="http://css-tricks.com/snippets/css/css-text-shadow/" target="_blank" title="Link opens in a new window">dropshadow</a></li>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Using_CSS_gradients" target="_blank" title="Link opens in a new window">gradient</a></li>
</ul>
<pre><code class ="php">@mixin yourMixinName($optionalArgument) {
// hard-code values
property: value;
// or use arguments
property: $optionalArgument;
}
p {
// example usage
@include yourMixinName($optionalArgument);
}
</code></pre>
</div>
</section>
<!-- Advanced mixins: Multiple arguments -->
<section>
<h3>Multiple Arguments</h3>
<div class="left-align">
Mixins can take multiple arguments, as we saw with the gradient mixin:
<pre><code contenteditable class="sass css">@mixin gradient($color1, $color2) {
background-image: -webkit-linear-gradient($color1, $color2, $color1);
background-image: -moz-linear-gradient($color1, $color2, $color1);
background-image: linear-gradient($color1, $color2, $color1);
}</code></pre>
</div>
</section>
<!-- Advanced mixins: Default values -->
<section>
<h3>Default Arguments</h3>
<div class="left-align">
You can also specify *default* values for arguments, for next-level laziness (a good thing):
<pre><code contenteditable class="sass css">@mixin gradient($color1: #fff, $color2: #666) {
background-image: -webkit-linear-gradient($color1, $color2, $color1);
background-image: -moz-linear-gradient($color1, $color2, $color1);
background-image: linear-gradient($color1, $color2, $color1);
}</code></pre>
</div>
</section>
<!-- Advanced mixins -->
<section>
<h3>Interpolation</h3>
<div class="left-align">
With some styles, we may want to use variables right next to text, like with our image rotate style - try it in _utilities:
<pre><code contenteditable class="sass css">@mixin rotate($degree, $position) {
-webkit-transform: rotate(-5deg);
-moz-transform: rotate(-5deg);
transform: rotate(-5deg);
-webkit-transform-origin: $position;
-moz-transform-origin: $position;
transform-origin: $position;
}</code></pre>
</div>
</section>
<!-- Advanced mixins: Interpolation -->
<section>
<h3>Interpolation</h3>
<div class="left-align">
We do this by using <a target="_blank" href="http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#interpolation_">interpolations</a>, which is a special syntax for variables that appear inside regular CSS text:
<pre><code contenteditable class="sass css">@mixin rotate(<span class="variable">$degree</span>, $position) {
-webkit-transform: rotate(<span class="variable">#{$degree}</span>deg);
-moz-transform: rotate(<span class="variable">#{$degree}</span>deg);
transform: rotate(<span class="variable">#{$degree}</span>deg);
-webkit-transform-origin: $position;
-moz-transform-origin: $position;
transform-origin: $position;
}</code></pre>
</div>
</section>
<!-- @extend -->
<section>
<h3>@extend classes</h3>
<div class="left-align">
Sometimes we have styles that duplicate another class, then add to it. We can use the extend prefix (%) for these, or extend a class:
<pre><code contenteditable class="sass css">.headline {
font-size: 2em;
font-weight: bold;
}
.lead-story-headline {
@extend .headline;
text-decoration: underline;
text-transform: uppercase;
}</code></pre>
</div>
</section>
<!-- Exercise 2: Advanced Mixins -->
<section>
<h3>Let's Develop It</h3>
<ul>
<li>Create new mixins using the following:
<ul>
<li>Multiple arguments</li>
<li>Default arguments</li>
<li>Interpolation</li>
<li>@extend to include common styles</li>
</ul>
</li>
<li>Use these mix-ins in your styles.scss file</li>
<li>Compile to CSS and refresh your index page to see your changes</li>
</ul>
</section>
<!-- Advanced mixins: CSS3 and UI mixins -->
<section>
<h3>CSS3: Browser Prefixes</h3>
<div class="left-align">
Lots of CSS3 features require browser prefixes or have complex syntaxes. These are perfectly suited to mixins, so we can include them in our styles without having to copy and paste from sites like <a target="_blank" href="http://css3please.com/">CSS3 Please</a>.
<pre><code contenteditable class="sass css">@mixin rotate(<span class="variable">$degree</span>, $position) {
-webkit-transform: rotate(<span class="variable">#{$degree}</span>deg);
-moz-transform: rotate(<span class="variable">#{$degree}</span>deg);
transform: rotate(<span class="variable">#{$degree}</span>deg);
-webkit-transform-origin: $position;
-moz-transform-origin: $position;
transform-origin: $position;
}</code></pre>
</div>
</section>
<!-- Advanced mixins: CSS3 and UI mixins -->
<section>
<h3>CSS3: Browser Prefixes</h3>
<div class="left-align">
Gradients are CSS3 and require browser prefixes to work in Firefox, Chrome, Safari, & Internet Explorer.
<pre><code contenteditable class="sass css">@mixin gradient($color1: $bodyBackground, $color2: $accentBackground) {
background-image: -webkit-linear-gradient($color1, $color2, $color1);
background-image: -moz-linear-gradient($color1, $color2, $color1);
background-image: linear-gradient($color1, $color2, $color1);
}
@include gradient(#fff, #000);</code></pre>
</div>
</section>
<!-- Advanced mixins: CSS3 and UI mixins -->
<section>
<h3>CSS3 Mixins</h3>
<div class="left-align">
<p>Other CSS3 features that require browser prefixes to work in most popular browsers include:</p>
<ul>
<li><a target="_blank" href="http://codepen.io/cfarm/pen/arBLb">@font-face</a></li>
<li><a target="_blank" href="http://codepen.io/cfarm/pen/BrckG"> transitions</a></li>
<li><a target="_blank" href="http://codepen.io/cfarm/pen/rkEIo">box-shadow</a></li>
<li><a target="_blank" href="http://codepen.io/cfarm/pen/kcfwH">opacity</a></li>
</ul>
</div>
</section>
<!-- Advanced mixins: UI development mixins -->
<section>
<h3>Mixins for UI Elements</h3>
<div class="left-align">
<p>Mixins are very useful for common design patterns. A great example is the <a target="_blank" href="http://coding.smashingmagazine.com/2012/04/11/css-sprites-revisited/">CSS sprite</a> design pattern.</p>
<p>Here's YouTube's icon sprite:</p>
<table class="code-compare">
<tr><td>
<p>Sprite image:</p>
<a target="_blank" href="img/youtube_sprite.png"><img src="img/youtube_sprite.png"></a>
</td>
<td>
<p>CSS for icon:</p>
<pre style="width: 650px"><code contenteditable class ="sass css">.icon {
display: block;
background: no-repeat url(img/youtube_sprite.png) -395px -114px;
background-size: auto;
width: 18px;
height: 18px; }</code></pre>
</tr></td></table>
</div>
</section>
<!-- Advanced mixins: UI development mixins -->
<section>
<h3>Sprite Mixins</h3>
<div class="left-align">
<p>If you <a target="_blank" href="http://coding.smashingmagazine.com/2012/04/11/css-sprites-revisited/">set up your Photoshop sprite to use grid lines</a>, you can use Sass to easily position your <a target="_blank" href="img/sprite.png">sprite image</a> without lots of trial and error.</p>
<pre style="width: 850px"><code contenteditable class ="sass css">@mixin sprite-position($x:0, $y:0) {
$gridSize: -32px;
$offsetX: $x * $gridSize;
$offsetY: $y * $gridSize;
background-position: $offsetX $offsetY;
}
@mixin sprite-image($file, $x:0, $y:0) {
background-image: url("../../img/icons/#{$file}");
@include sprite-position($x, $y);
}</code></pre>
</div>
</section>
<!-- Advanced mixins: CSS3 and UI mixins -->
<section>
<h3>CSS3 Mixins</h3>
<div class="left-align">
<p>Other common UI elements that Sass mixins make easy:</p>
<ul>
<li><a target="_blank" href="http://codepen.io/seansean11/pen/CKIyf">buttons</a></li>
<li><a target="_blank" href="http://codepen.io/cfarm/pen/FAgsp">image replacement</a></li>
<li><a target="_blank" href="http://codepen.io/cfarm/pen/opCjq">error messages</a></li>
<li><a target="_blank" href="http://codepen.io/cfarm/pen/qkDAe">CSS shapes (triangles, arrows)</a></li>
</ul>
</div>
</section>
<!-- Exercise 3: CSS3 and UI mixins -->
<section>
<h3>Let's Develop It</h3>
<ul>
<li>Create new mixins for the following use cases, combining as many as possible:
<ul>
<li>Sprite images</li>
<li>Opacity for all browsers, including IE</li>
<li>CSS3 box-shadow</li>
<li>@font-face</li>
<li>transitions</li>
<li>CSS shapes</li>
</ul>
</li>
<li>Use these mix-ins in your styles.scss file</li>
<li>Compile to CSS and refresh your index page to see your changes</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="img/stretchbreak.jpg">
</div>
</section>
<!-- Exercise 4: Grid layout -->
<!---<section>
<h3>Let's Develop It</h3>
<ul>
<li>Create mixins for your page layout:
<ul>
<li>Make grid mixins that take numbers as arguments: width, padding, margins, etc</li>
<li>Remember the box model!</li>
<li>Try using <a target="_blank" href="http://css-tricks.com/box-sizing/">CSS3 box-sizing</a> to change the box model - include it as another mixin</li>
<li><a target="_blank" href="http://www.slideshare.net/stevehickeydsgn/forget-frameworks-create-your-own-flexible-grid-system">More info on making a grid system</a></li>
</ul>
</li>
<li>Use these mix-ins in your styles.scss file</li>
<li>Compile to CSS and refresh your index page to see your changes</li>
<li><span class="blue">Bonus:</span>Write a mixin for responsive styles to be used in the media queries in styles.scss</li>
</ul>
</section>--->
<!-- Advanced: If/Else logic -->
<section>
<h3>If/Else If</h3>
<div class="left-align">
<p>Sass has <a href="http://sass-lang.com/documentation/file.SASS_REFERENCE.html#_7" target="_blank" title="Link opens in a new window">logic statements</a> that you can use to create conditionals. They are @if, @else if, and @else</p>
<pre style="width: 850px"><code contenteditable class ="sass css">@mixin opacity($value: 0.5) {
@if $value == transparent {
opacity: 0;
} @else if $value == opaque {
opacity: 1;
} @else {
opacity: $value;
}
}
@include opacity(transparent);
</code></pre>
</div>
</section>
<!-- Exercise 5: Logic -->
<section>
<h3>If/Else If</h3>
<div class="left-align">
<p>Rewrite your existing mixins to use if/else if statements, so that they output different CSS depending on different arguments.</p>
<pre><code class ="php">@mixin arrow($direction: right) {
@if $direction == right {
//right arrow styles
}
@else if $direction == left {
// left arrow styles
}
}
</code></pre>
</div>
</section>
<!-- Exercise 6: Loops -->
<section>
<h3>For Loops</h3>
<div class="left-align">
<p>With <a href="http://sass-lang.com/documentation/file.SASS_REFERENCE.html#_9" target="_blank" title="Link opens in a new window">@for</a> loops, you can make Sass write your classes and styles for you.</p>
<table class="code-compare">
<tr><td>
<p>Sass code:</p>
<pre style="width: 400px"><code class ="php">@for $i from 1 through 3 {
.column-#{$i} { width: 2em * $i; }
}
</code></pre>
</td>
<td>
<p>CSS output:</p>
<pre style="width: 320px"><code contenteditable class ="sass css">.column-1 {
width: 2em;
}
.column-2 {
width: 4em;
}
.column-3 {
width: 6em;
}</code></pre>
</tr></td></table>
</div>
</section>
<!-- Exercise 6: Loops -->
<section>
<h3>For Loops</h3>
<div class="left-align">
<ul>
<li>Use loops to write classes and styles for you! Use them to make columns that fit within in our layout, and add links to our footer nav in these columns.</li>
<li>Experiment with math in your loop's styles - change the width, padding, even font-size</li>
</ul>
<pre><code class ="php">@for $i from 1 through 3 {
.column-#{$i} { width: 2em * $i; }
}
</code></pre>
</div>
</section>
<!-- Looping with @Each -->
<section>
<h3>@each</h3>
<div class="left-align">
<p>With <a href="http://sass-lang.com/documentation/file.SASS_REFERENCE.html#each-directive" target="_blank" title="Link opens in a new window">@each</a>, you can loop through a list of items and create styles for each item in the list.</p>
<table class="code-compare">
<tr><td>
<p>Sass code:</p>
<pre style="width: 450px"><code class ="php">@each $icon in youtube, twitter, facebook {
.icon-$icon {
background-image: url('#{$icon}.png');
}
}
</code></pre>
</td>
<td>
<p>CSS output:</p>
<pre style="width: 380px"><code contenteditable class ="sass css">.icon-youtube {
background: url('youtube.png');
}
.icon-twitter {
background: url('twitter.png');
}
.icon-facebook {
background: url('facebook.png');
}</code></pre>
</tr></td></table>
</div>
</section>
<!-- Exercise 7: Loops -->
<section>
<h3>@each</h3>
<div class="left-align">
<ul>
<li>Create background image styles for each Famous Woman article</li>
<li>Try <a href="http://SubtlePatterns.com" target="_blank" title="Link opens in a new window">SubtlePatterns.com</a> for images to use</li>
<li>Write these background styles with @each and a list</li>
<li>Bonus: style your social media icons using @each and @if logic</li>
</ul>
<pre style="width: 1100px; position: relative; left: -100px;"><code class ="php">@each $woman in ada, grace, frances, barbara, anita, maria {
.#{$woman}-bg {
background-image: url('img/#{$woman}.png');
}
}</code></pre>
</div>
</section>
<!-- Extend SASS -->
<section>
<h3>Extend Sass</h3>
<div class="left-align">
<p>The following tools can help you write Sass even faster:</p>
<ul>
<li><a target="_blank" href="http://incident57.com/codekit/">CodeKit</a>: Compile Sass & more without command line</li>
<li><a target="_blank" href="http://www.mobify.com/dev/sass-sleuth-debugging-sass-in-webkit-browsers/">Sass Sleuth</a>: See Sass line numbers in your browser</li>
<li><a target="_blank" href="http://livereload.com/">Live Reload</a>: Compile Sass without refreshing your browser</li>
<li><a target="_blank" href="http://compass-style.org">Compass</a></li>
</ul>
</div>
</section>
<!-- More to Explore -->
<section>
<h3>More to Explore</h3>
<div class="left-align">
<ul>
<li><a target="_blank" href="http://haml.info/">Haml</a>: like Sass for HTML</li>
<li><a target="_blank" href="http://guides.railsgirls.com/">Rails</a>: Rails is a software development framework written in Ruby. Sass & Haml are used in Rails apps. Try the Rails Girls tutorials to build your own app!</li>
<li><a target="_blank" href="http://lesscss.org/">LESS</a>: a CSS preprocessor like Sass with different syntax</li>
</ul>
</div>
</section>
<!-- -->
<section>
<h2>Questions?</h2>
<div style="font-size:1200%; height:100%; margin-top:30%" class ="blue">?
<div class ="clear"></div></div>
</section>
</div>
<footer>
<div class="copyright">
Intro to Sass ~ GDI Seattle
<a rel="license" href="http://creativecommons.org/licenses/by-nc/3.0/deed.en_US"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc/3.0/80x15.png" /></a>
</div>
</footer>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.min.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,
center: true,
transition: 'slide', // none/fade/slide/convex/concave/zoom
// Optional reveal.js plugins
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, condition: function() { return !!document.querySelector( 'pre code' ); }, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true },
{ src: 'plugin/notes/notes.js', async: true },
{ src: 'plugin/accessibility-helper/js/accessibility-helper.js', async: true, condition: function() { return !!document.body.classList; } }
]
});
</script>
</body>
</html>