-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
413 lines (370 loc) · 20.2 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Web icon pain killer</title>
<meta name="description" content="Utilizing pixel-based icons in the era of responsive web design and retina displays is pointless. But the often used icon fonts approach has several disadvantages, too. To make them look the same on different devices and operating systems can be a pain. This talk introduces you to a more modern web icon approach. ">
<meta name="author" content="Mario Volke & Christian Ranz">
<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">
<link rel="stylesheet" href="css/reveal.min.css">
<link rel="stylesheet" href="css/theme/default.css" id="theme">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="lib/css/github.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>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
<style>
.colored-icons svg {
display: inline-block;
width: 100px;
height: 100px;
fill: #66cc33;
}
.colored-icons svg:first-child {
fill: #CC5C33;
}
.colored-icons svg:last-child {
fill: #3375CC;
}
</style>
</head>
<body>
<!-- inline icons have to come first, hide immediately with inline styles -->
<div style="width: 0; height: 0; visibility: hidden;">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
<symbol id="some-icon" viewBox="0 0 100 100" enable-background="new 0 0 100 100">
<path d="M50,97.137c-1.402,0-2.786-0.371-4-1.072L12.106,76.497c-2.467-1.424-4-4.079-4-6.928V30.432c0-2.849,1.533-5.504,4-6.928 L46,3.935c2.429-1.402,5.571-1.402,8,0l33.894,19.568c2.467,1.424,4,4.079,4,6.928v39.137c0,2.849-1.533,5.504-4,6.928L54,96.065 C52.786,96.766,51.402,97.137,50,97.137z M50,6.863c-0.701,0-1.393,0.185-2,0.536L14.106,26.967c-1.234,0.712-2,2.04-2,3.464v39.137 c0,1.425,0.766,2.752,2,3.464L48,92.601c1.215,0.701,2.785,0.701,4,0l33.894-19.568c1.234-0.712,2-2.04,2-3.464V30.432 c0-1.425-0.766-2.752-2-3.464L52,7.399C51.393,7.048,50.701,6.863,50,6.863z"/>
<rect x="40.115" y="48.379" transform="matrix(-0.7071 0.7071 -0.7071 -0.7071 135.5746 44.8431)" width="36.77" height="4.243"/>
<rect x="29.808" y="51.879" transform="matrix(-0.7071 -0.7071 0.7071 -0.7071 28.3934 119.7609)" width="18.385" height="4.243"/>
</symbol>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
<symbol id="multicolor-icon" viewBox="0 0 100 100" enable-background="new 0 0 100 100">
<path d="M50,97.137c-1.402,0-2.786-0.371-4-1.072L12.106,76.497c-2.467-1.424-4-4.079-4-6.928V30.432c0-2.849,1.533-5.504,4-6.928 L46,3.935c2.429-1.402,5.571-1.402,8,0l33.894,19.568c2.467,1.424,4,4.079,4,6.928v39.137c0,2.849-1.533,5.504-4,6.928L54,96.065 C52.786,96.766,51.402,97.137,50,97.137z M50,6.863c-0.701,0-1.393,0.185-2,0.536L14.106,26.967c-1.234,0.712-2,2.04-2,3.464v39.137 c0,1.425,0.766,2.752,2,3.464L48,92.601c1.215,0.701,2.785,0.701,4,0l33.894-19.568c1.234-0.712,2-2.04,2-3.464V30.432 c0-1.425-0.766-2.752-2-3.464L52,7.399C51.393,7.048,50.701,6.863,50,6.863z"/>
<rect style="fill: currentColor;" x="40.115" y="48.379" transform="matrix(-0.7071 0.7071 -0.7071 -0.7071 135.5746 44.8431)" width="36.77" height="4.243"/>
<rect style="fill: currentColor;" x="29.808" y="51.879" transform="matrix(-0.7071 -0.7071 0.7071 -0.7071 28.3934 119.7609)" width="18.385" height="4.243"/>
</symbol>
</svg>
</div>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section data-state="highlight">
<p>
<img src="assets/signet_reduced.svg" style="width: 100px; height:100px;" alt="Codastic">
</p>
<h1>Web icon<br>pain killer</h1>
<p>An modern approach to handling icons in web frontends</p>
<p>
<small>
Mario Volke /
JavaScript UserGroup Munich /
8. January 2015
</small>
</p>
<p>
<small>
<a href="http://codastic.com">codastic.com</a>
</small>
</p>
</section>
<section>
<img src="assets/logo.svg" style="width: 500px;" alt="Codastic">
<p class="highlighted">
We are a <strong>web agency</strong> offering full stack <strong>web application development</strong>.
</p>
</section>
<section>
<h3>Why talking about this in a JavaScript user group</h3>
<ul>
<li>
Icons are everywhere
</li>
<li>
You need workflows in your team that work for everyone
</li>
<li>
You need to define a workflow for your icons, too
</li>
</ul>
</section>
<section data-background="assets/dead_end.jpg">
<p>First of all</p>
<h1>Stop</h1>
<h3>using icon fonts!</h3>
<p>
<br><br><br><br><br><br>
</p>
<aside class="notes">
Or even worse pixel based icons, you know, retina support is a mess and giving the same icon different colors...
</aside>
</section>
<section data-background="assets/dead_end.jpg">
<h2>To be more precise</h2>
<p>
<strong>If you are on IE9+</strong> stop using icon fonts!
</p>
<p>
<br><br><br><br><br><br>
</p>
</section>
<section>
<h2>Why?</h2>
<p>
Because Chris Coyier says so...
</p>
<p>
<small><a href="http://css-tricks.com/icon-fonts-vs-svg/">http://css-tricks.com/icon-fonts-vs-svg/</a></small>
</p>
</section>
<section>
<h2>Icon fonts have problems</h2>
<ul>
<li class="fragment">Workflow integration is complex</li>
<li class="fragment">Aliasing and sharpness is different in each browser/system</li>
<li class="fragment">Positioning icon fonts is hard</li>
<li class="fragment">If your font doesn’t load you’ll see ugly characters</li>
<li class="fragment">It is againts HTML semantics and accessibility</li>
</ul>
<aside class="notes">
If there is time talk more about those points, e.g. with examples.
<ul>
<li>
There are tools like iconmoon but they are not really integrated into your grunt/gulp workflow.
What if you wanna change individual icons? Its a mess.
</li>
</ul>
</aside>
</section>
<section>
<h2>Inline SVG</h2>
<p>
<svg style="width: 100px; height: 100px;"
viewBox="0 0 100 100"
enable-background="new 0 0 100 100">
<path d="M50,97.137c-1.402,0-2.786-0.371-4-1.072L12.106,76.497c-2.467-1.424-4-4.079-4-6.928V30.432c0-2.849,1.533-5.504,4-6.928 L46,3.935c2.429-1.402,5.571-1.402,8,0l33.894,19.568c2.467,1.424,4,4.079,4,6.928v39.137c0,2.849-1.533,5.504-4,6.928L54,96.065 C52.786,96.766,51.402,97.137,50,97.137z M50,6.863c-0.701,0-1.393,0.185-2,0.536L14.106,26.967c-1.234,0.712-2,2.04-2,3.464v39.137 c0,1.425,0.766,2.752,2,3.464L48,92.601c1.215,0.701,2.785,0.701,4,0l33.894-19.568c1.234-0.712,2-2.04,2-3.464V30.432 c0-1.425-0.766-2.752-2-3.464L52,7.399C51.393,7.048,50.701,6.863,50,6.863z"/>
<rect x="40.115" y="48.379" transform="matrix(-0.7071 0.7071 -0.7071 -0.7071 135.5746 44.8431)" width="36.77" height="4.243"/>
<rect x="29.808" y="51.879" transform="matrix(-0.7071 -0.7071 0.7071 -0.7071 28.3934 119.7609)" width="18.385" height="4.243"/>
</svg>
</p>
<pre><code data-trim class="xml" style="max-height: 10em;">
<div class="somewhere-in-your-markup">
<svg style="width: 100px; height: 100px;"
viewBox="0 0 100 100"
enable-background="new 0 0 100 100">
<path d="M50,97.137c-1.402,0-2.786-0.371-4-1.072L12.106,76.497c-2.467-1.424-4-4.079-4-6.928V30.432c0-2.849,1.533-5.504,4-6.928 L46,3.935c2.429-1.402,5.571-1.402,8,0l33.894,19.568c2.467,1.424,4,4.079,4,6.928v39.137c0,2.849-1.533,5.504-4,6.928L54,96.065 C52.786,96.766,51.402,97.137,50,97.137z M50,6.863c-0.701,0-1.393,0.185-2,0.536L14.106,26.967c-1.234,0.712-2,2.04-2,3.464v39.137 c0,1.425,0.766,2.752,2,3.464L48,92.601c1.215,0.701,2.785,0.701,4,0l33.894-19.568c1.234-0.712,2-2.04,2-3.464V30.432 c0-1.425-0.766-2.752-2-3.464L52,7.399C51.393,7.048,50.701,6.863,50,6.863z"/>
<rect x="40.115" y="48.379"
transform="matrix(-0.7071 0.7071 -0.7071 -0.7071 135.5746 44.8431)"
width="36.77" height="4.243"/>
<rect x="29.808" y="51.879"
transform="matrix(-0.7071 -0.7071 0.7071 -0.7071 28.3934 119.7609)"
width="18.385" height="4.243"/>
</svg>
</div>
</code></pre>
<aside class="notes">
1) explain what inline svg is
2) but why inline svg: because we don't want to use the img-tag for non-content images and one request per icon is not good enough
</aside>
</section>
<section>
<h2>Just use <use></h2>
<p>includes existing SVG symbols</p>
<pre><code data-trim class="xml">
<!-- SVG spritemap somewhere up in the DOM -->
<div style="width: 0; height: 0; visibility: hidden;">
<svg>
<symbol id="some-icon">...</symbol>
</svg>
</div>
<!-- actual usage -->
<svg><use xlink:href="#some-icon" /></svg>
</code></pre>
<p><small>Attention: Chrome only supports symbols which come before its usage in the DOM order</small></p>
<aside class="notes">
1) Problem: don't want to embed the same icon twice
2) Explain use
3) Advantage: icons only embedded once, but can be used multiple times
4) Attention: Chrome only supports symbols which come before its usage in the DOM order.
5) Problem: not really cacheable because icons are embedded on every page
</aside>
</section>
<section>
<p>Building an SVG spritemap with</p>
<h2>grunt-svgstore</h2>
<pre><code data-trim class="xml">
grunt.initConfig({
svgstore: {
options: {},
default : {
files: {
'dest/icons.svg': ['svgs/*.svg'],
},
},
},
});
</code></pre>
<p>Then inline <em>dest/icons.svg</em> into the top of <em><body></em></p>
<p><small>There is also gulp-svgstore.</small></p>
<aside class="notes">
1) grunt-svgstore
2) inline it into the top of body
3) problem every page contains bloat of icons, caching of icons between pages not possible
</aside>
</section>
<section>
<h2>You can <use> URLs, too</h2>
<pre><code data-trim class="xml">
<svg><use xlink:href="assets/icons.svg#some-icon" /></svg>
</code></pre>
<p>
<strong>Pros:</strong> Only one request for all icons,<br>icons.svg cached by browser
</p>
<p>
<strong>But:</strong> No IE support at all!
</p>
<aside class="notes">
1) example how to use full URLs
2) problem: doesn't work in IE
3) but we can polyfill that
</aside>
</section>
<section>
<p>There’s a polyfill for Internet Explorer</p>
<h2>svg4everybody</h2>
<p><small><a href="https://github.com/jonathantneal/svg4everybody">https://github.com/jonathantneal/svg4everybody</a></small></p>
<aside class="notes">
explain the polyfill
</aside>
</section>
<section>
<h2>Our grunt workflow</h2>
<ol>
<li class="fragment">Folder with SVG icons</li>
<li class="fragment">grunt-svgmin (because Adobe Illustrator exports a lot of crap)</li>
<li class="fragment">grunt-svgstore</li>
<li class="fragment">and svg4everybody</li>
</ol>
</section>
<section>
<h2>Accessibility</h2>
<p>Within a spritemap, each symbol can have a <em><title></em></p>
<pre><code data-trim class="xml">
<symbol id="some-icon"><title>Some icon</title><path etc.../></symbol>
</code></pre>
<p>Give the <em><svg></em> a title</p>
<pre><code data-trim class="xml">
<svg title="Some icon"><use xlink:href="icons.svg#some-icon"></use></svg>
</code></pre>
<aside class="notes">
if there is not enough time skip this section.
</aside>
</section>
<section>
<h2>ARIA roles</h2>
<p>If your icon just decorates other content:</p>
<pre><code data-trim class="xml">
<a href="..."><svg role="presentation"><use xlink:href="icons.svg#twitter"></svg>
Find us on Twitter
</a>
</code></pre>
<p>Or if it stands for itself:</p>
<pre><code data-trim class="xml">
<a href="..."><svg title="Find us on Twitter" role="img">
<use xlink:href="icons.svg#twitter">
</svg></a>
</code></pre>
<aside class="notes">
if there is not enough time skip this section.
</aside>
</section>
<section>
<h2>Coloring icons</h2>
<div class="colored-icons">
<svg><use xlink:href="#some-icon" /></svg>
<svg><use xlink:href="#some-icon" /></svg>
<svg><use xlink:href="#some-icon" /></svg>
</div>
<pre><code data-trim class="css">
#inline-styled-svg {
fill: #66cc33;
}
</code></pre>
</section>
<section>
<h2>Styling limits</h2>
<img src="assets/shadow_dom.png" alt="Embedded SVG symbols are handeled by browsers as shadow DOM">
<p><small>Symbols are embedded as Shadow DOM elements.</small></p>
<p>There is no cross browser compatible way of selecting child elements of a Shadow DOM element, yet.</p>
</section>
<section>
<h2>CSS Trick: currentColor</h2>
<pre><code data-trim class="css">
.icon {
fill: currentColor;
}
</code></pre>
<p>All icons then inherit the current text color.</p>
<p><small>Works in all modern browsers and IE9+.</small></p>
</section>
<section>
<h2>CSS Trick (2): Multi-color icons</h2>
<svg style="fill: #66cc33;"><use xlink:href="#multicolor-icon" /></svg>
<pre><code data-trim class="xml">
<!-- in SVG spritesheet -->
<symbol id="multicolor-icon"
viewBox="0 0 100 100"
enable-background="new 0 0 100 100">
<path .../>
<rect style="fill: currentColor;" .../>
<rect style="fill: currentColor;" .../>
</symbol>
<!-- actual usage -->
<svg style="fill: #66cc33; color: #333333;"><use xlink:href="#multicolor-icon" /></svg>
</code></pre>
<p>Use a combination of currentColor and fill.</p>
</section>
<section data-state="highlight">
<p><strong></end></strong></p>
<h1>Questions?</h1>
<p>by Mario Volke</p>
</section>
</div>
</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,
theme: 'codastic',
transition: 'concave', // default/cube/page/concave/zoom/linear/fade/none
// Optional libraries used to extend on reveal.js
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, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
{ src: 'plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }
]
});
</script>
</body>
</html>