forked from prabeshshakya/Sass-Starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
547 lines (499 loc) · 13.7 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Sass Starter</title>
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700" rel="stylesheet">
<!--build:css css/style.css-->
<link rel="stylesheet" href="css/style.css">
<!--endbuild-->
</head>
<body>
<div class="example-doc">
<header>
<div class="container">
<h1>Sass Starter</h1>
<p class="sub-header">SCSS for SMACSS</p>
<p>Starter code for SASS based on Scalar and Modular Architecture for CSS (SMACSS).
SMACSS (pronounced “smacks”) is more style guide than rigid framework. This allows for more customization to the structure as we see fit.
</p>
</div>
</header>
<main>
<div class="Block">
<div class="container">
<h2>SASS Folder Structure:</h2>
<ul class="tree">
<li>
sass
<ul>
<li>base
<ul>
<li>_base.scss</li>
<li>_manifest.scss</li>
</ul>
</li>
<li>libs
<ul>
<li>_manifest.scss</li>
</ul>
</li>
<li>modules
<ul>
<li>_example.scss</li>
<li>_extends.scss</li>
<li>_manifest.scss</li>
<li>_modules.scss</li>
</ul>
</li>
<li>states
<ul>
<li>_manifest.scss</li>
<li>_print.scss</li>
<li>_states.scss</li>
</ul>
</li>
<li>utilities
<ul>
<li>bootstrap</li>
<li>_bootstrap.scss</li>
<li>_config.scss</li>
<li>_helpers.scss</li>
<li>_manifest.scss</li>
<li>_normalize.scss</li>
<li>_utilities.scss</li>
</ul>
</li>
<li>_shame.scss</li>
<li>style.scss</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="Block">
<div class="container">
<h2>Using Mixins:</h2>
<div class="Block__segment">
<h3>Using Media query Mixins:</h3>
<p>Find the mixin for media query under
<span class="highlight">utilities/_utilities.scss</span>.
Responsive web design for Sass Starter is based on Mobile first design
and media query breakpoints are based on bootstrap breakpoints.
Breakpoints variables can be customized according to your
needs at
<span class="highlight">utilities/_config.scss</span>.
</p>
<div class="Block__code">
<span>HTML:</span>
<pre><div class="Box"></div></pre>
</div>
<div class="Block__code">
<span>SCSS:</span>
<pre>.Box{
// For mobile devices of size less than 768px put code here
width: 20px;
height: 20px;
background: red;
transition: width 0.3s ease-out, height 0.3s ease-out;
margin-right: 10px;
float: left;
@include mq(sm){// For devices of size greater than 768px(tablets) put code here
width: 50px;
height: 50px;
background: blue;
}
@include mq(md){// For devices of size greater than 992px(laptops) put code here
width: 70px;
height: 70px;
background: green;
}
@include mq(lg){// For devices of size greater than 1200px(desktops and high-res TVs) put code here
width: 100px;
height: 100px;
background: yellow;
}
}</pre>
</div>
<div class="Block__code">
<span>CSS Output:</span>
<pre>.Box{
width: 20px;
height: 20px;
background: red;
transition: width 0.3s ease-out, height 0.3s ease-out;
margin-right: 10px;
float: left;
}
@media(min-width: 768px){
.Box{
width: 50px;
height: 50px;
background: blue;
}
}
@media(min-width: 992px){
.Box{
width: 70px;
height: 70px;
background: green;
}
}
@media(min-width: 1200px){
.Box{
width: 100px;
height: 100px;
background: yellow;
}
}</pre>
</div>
<div class="Block__code">
<span>Example:</span>
<span>Resize browser window to see effect.</span>
<div>
<div class="Box"></div>
<div class="Box"></div>
<div class="Box"></div>
<div class="Box"></div>
</div>
</div>
</div>
<div class="Block__segment">
<h3>Using BEM Mixins:</h3>
<p>Find the mixin for BEM under
<span class="highlight">utilities/_utilities.scss</span>.
</p>
<div class="dotted">
<h3>Block</h3>
<p>
Block is a top-level abstraction of a new component. It is top in the hierarchy for this naming convention.
Blocks can be nested with other blocks but they are independent to each other with no precedence in hierarchy.
</p>
<p>We should use class name selector only; ids and tag names should not be used. CSS code should be
independent from all other
blocks and html elements.</p>
<div class="Block__code">
<span>HTML:</span>
<pre><ul class="Nav">...</ul></pre>
</div>
<div class="Block__code">
<span>SCSS:</span>
<pre>// Here ".nav" class selector is a Block
.Nav {
padding: 10px 0;
}</pre>
</div>
</div>
<div class="dotted">
<h3>Element</h3>
<p>
Element is child elements inside of Block element and gives specific meaning to its elements.
Elements have their
meaning always derived from its respective parent block.
</p>
<p>
CSS class is formed as block name plus two underscores plus element name.
Example:
<span class="highlight">.block__elem</span>
Element naming can also have a single dash.
Example: <span class="highlight">.Patient__info-detail</span>
</p>
<p>
We should use class name selector only, ids and tag names should not be used. CSS code should be independent from all other
blocks and html elements.
</p>
<div class="Block__code">
<span>HTML:</span>
<pre><ul class="Nav">
<li class="nav__item">...</nav>
<li class="nav__item">...</nav>
<li class="nav__item">...</nav>
</ul>
</pre>
</div>
<div class="Block__code">
<span>SCSS:</span>
<pre>// Here ".Nav" class selector is a Block and ".Nav__item" is an Element
.Nav{
padding: 10px 0;
@include e(item){ //'e' is small for element
float: left;
margin-right: 10px;
}
}</pre>
</div>
<div class="Block__code">
<span>CSS Output:</span>
<p>Output is completely independent from the parent block class selectors.</p>
<pre>
.Nav {
padding: 10px 0;
}
.Nav__item{
float: left;
margin-right: 10px;
}</pre>
</div>
</div>
<div class="dotted">
<h3>Modifier</h3>
<p>
Modifier is used to modify blocks or elements.
CSS class will be formed by added two dashes to block’s or element’s class name.
Example: <span class="highlight">.block--mod</span> or <span class="highlight">.block__elem--mod</span>
Modifier naming can also have a single dash. Example: <span class="highlight">.Box__row--gray-bg</span>
</p>
<p>
We should use class name selector only, ids and tag names should not be used. CSS code
should be independent from all other
blocks and html elements.
</p>
<div class="Block__code">
<span>HTML:</span>
<pre><ul class="Nav">
<li class="nav__item nav__item--active">...</nav>
<li class="nav__item">...</nav>
<li class="nav__item">...</nav>
</ul></pre>
</div>
<div class="Block__code">
<span>SCSS:</span>
<pre>// Here ".Nav" class selector is a Block and ".Nav__item" is an Element
.Nav{
padding: 10px 0;
@include e(item){
float: left;
margin-right: 10px;
@include m(active){//'m' is small for element. Nest this under element mixin
color: blue;
font-weight: bold;
}
}
}</pre>
</div>
<div class="Block__code">
<span>CSS Output:</span>
<p>Output is completely independent from the parent block and element class selectors.</p>
<pre>
.Nav {
padding: 10px 0;
}
.Nav__item{
float: left;
margin-right: 10px;
}
.Nav__item--active{
color: blue;
font-weight: bold;
}</pre>
</div>
</div>
</div>
</div>
</div>
<div class="Block">
<div class="container">
<h2>Using Functions:</h2>
<p>Find the functions defined under <span class="highlight">utilities/_utilities.scss</span>.</p>
<div class="Block__segment">
<h3>rem function</h3>
<p>Convert pixel unit into rem.</p>
<div class="Block__code">
<span>Usage(SCSS):</span>
<pre>header{
padding: rem(20px) rem(30px);
}</pre>
</div>
<div class="Block__code">
<span>Alternative(SCSS):</span>
<pre>header{
padding: rem(20) rem(30);
}</pre>
</div>
<div class="Block__code">
<span>CSS Output:</span>
<pre>header{
padding: 1.25rem 1.875rem; //base font size of 16px
}</pre>
</div>
</div>
<div class="Block__segment">
<h3>pntg function</h3>
<p>Convert pixel unit to percentage.</p>
<div class="Block__code">
<span>Usage(SCSS):</span>
<pre>.box{
width: pntg(300,768); //First parameter is target width and second parameter is context width
}</pre>
</div>
<div class="Block__code">
<span>CSS Output:</span>
<pre>.box{
width: 39.0625%;
}</pre>
</div>
</div>
</div>
</div>
<div class="Block">
<div class="container">
<h2>Using Maps:</h2>
<p>Define maps at <span class="highlight">_config.scss partial</span>.</p>
<div class="Block__segment">
<h3>Mapping background colors to elements:</h3>
<div class="Block__code">
<span>HTML:</span>
<pre><div>
<button class="btn btn--default">Default</button>
<button class="btn btn--success">Succes</button>
<button class="btn btn--error">Error</button>
<button class="btn btn--warning">Warning</button>
</div></pre>
</div>
<div class="Block__code">
<span>SCSS:</span>
<pre>// Declare map for UI colors
$ui-colors: (
default: $blue,
success: $success,
error: $error,
warning: $edit
);
//Using a mixin to iterate through the map:
@mixin bg-colors($map){
@each $theme, $color in $map{
&--#{$theme}{ //Interpolating parent class name with map key
background: $color;
}
}
}
//Using the mixin to create different types of button with different background colors:
.btn{
padding: 10px 15px;
border: 0;
border-radius: 2px;
color: #fff;
cursor: pointer;
font-weight: bold;
@include bg-colors($ui-colors);
}
</pre>
</div>
<div class="Block__code">
<span>CSS Output:</span>
<pre>.btn{
padding: 10px 15px;
border: 0;
border-radius: 2px;
color: #fff;
cursor: pointer;
font-weight: bold;
}
.btn--default{
background: blue;
}
.btn--success{
background: green;
}
.btn--error{
background: red;
}
.btn--warning{
background: yellow;
}</pre>
</div>
<div class="Block__code">
<span>Example:</span>
<div>
<button class="btn btn--default">Default</button>
<button class="btn btn--success">Success</button>
<button class="btn btn--error">Error</button>
<button class="btn btn--warning">Warning</button>
</div>
</div>
</div>
<div class="Block__segment">
<h3>Using nested maps:</h3>
<div class="Block__code">
<span>HTML:</span>
<pre><div class="Palette__wrap">
<div class="gray--dark">Dark</div>
<div class="gray--base">Base</div>
<div class="gray--light">Light</div></div>
<div class="Palette__wrap">
<div class="blue--dark">Dark</div>
<div class="blue--base">Base</div>
<div class="blue--light">Light</div>
</div></pre>
</div>
<div class="Block__code">
<span>SCSS:</span>
<pre>// Nested Map:
$palettes: (
gray-shades: (
base: $gray,
dark: darken($gray,20%),
light: lighten($gray,20%)
),
blue-shades: (
base: $blue,
dark: darken($blue,20%),
light: lighten($blue,20%)
)
);
// Use palette function
// $palette - Map required under $palettes map($palettes map is defined under _config.scss partial)
// $shade - Key of provide $palette map
// base - Default key of $shade under $palette map
// @returns - map
@function palette($palette, $shade: base){
@return map-get(map-get($palettes, $palette), $shade);
}
//Using function in SCSS code:
.blue{
@include m(base){
@extend %palette-props;
background: palette(blue-shades);
}
@include m(dark){
@extend %palette-props;
background: palette(blue-shades, dark);
}
@include m(light){
@extend %palette-props;
background: palette(blue-shades, light);
}
}</pre>
</div>
<div class="Block__code">
<span>Example of generated palette:</span>
<div class="Palette__wrap">
<div class="gray--dark">Dark</div>
<div class="gray--base">Base</div>
<div class="gray--light">Light</div>
</div>
<div class="Palette__wrap">
<div class="blue--dark">Dark</div>
<div class="blue--base">Base</div>
<div class="blue--light">Light</div>
</div>
</div>
</div>
</div>
</div>
</main>
<footer>
<div class="container">
<div class="pull-left">
<a href="https://github.com/sshikhrakar/Sass-Starter">Github</a>
</div>
<div class="pull-right">
<span>By Shirish Shikhrakar | Sass Starter</span>
</div>
</div>
</footer>
</div>
</body>
</html>