-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
461 lines (453 loc) · 19.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Fluid Typography Calculator</title>
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png" />
<link rel="manifest" href="site.webmanifest" />
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bulma@0.9.1/css/bulma.min.css"
/>
<link rel="stylesheet" href="style.css" />
<!-- Twitter -->
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="🧮 Fluid Typography Calculator" />
<meta
name="twitter:description"
content="Calculate a fluid typography scale to level up your web dev and web design. "
/>
<meta name="twitter:site" content="@theroyalfig" />
<meta name="twitter:creator" content="@theroyalfig" />
<meta
name="twitter:image"
content="https://royalfig.github.io/fluid-typography-calculator/banner.png"
/>
<!-- Open Graph general (Facebook, Pinterest)-->
<meta property="og:title" content="🧮 Fluid Typography Calculator" />
<meta
property="og:description"
content="Calculate a fluid typography scale to level up your web dev and web design. "
/>
<meta
property="og:url"
content="https://royalfig.github.io/fluid-typography-calculator/"
/>
<meta property="og:site_name" content="royalfig.github.io" />
<meta property="og:type" content="website" />
<meta
property="og:image"
content="https://royalfig.github.io/fluid-typography-calculator/banner.png"
/>
</head>
<body class="has-background-light">
<section class="section">
<div class="container">
<div class="tile is-ancestor">
<div class="tile is-parent">
<div class="tile is-child box is-info notification">
<h1 class="title">The Clamp Calculator 🧮</h1>
<p class="subtitle">Calculate a Fluid Typography Scale</p>
</div>
</div>
</div>
<!-- Credits -->
<div class="tile is-ancestor">
<div class="tile is-parent">
<div class="tile is-child notification box is-info is-light">
<p class="title">Credits 👏</p>
<p>
This calculator is inspired by Christopher Kirk-Nielsen's post,
"<a
href="https://chriskirknielsen.com/blog/modern-fluid-typography-with-clamp/"
>Modern Fluid Typography with Clamp()</a
>"
</p>
</div>
</div>
</div>
<div class="tile is-ancestor">
<!-- Instructions -->
<div class="tile is-parent">
<article class="tile is-child notification box">
<div class="content">
<p class="title">Instructions</p>
<p class="subtitle">How to Use This Calculator</p>
<div class="content">
<ul>
<li>
Enter min and max font sizes in <code>px</code> or
<code>rem</code>. Your base font will always remain within
these limits
</li>
<li>
Enter your min and max viewport widths in
<code>px</code> or <code>rem</code>.
</li>
<li>
In between these viewport limits, font size will scale in
proportion to the client's viewport width
</li>
<li>
The <strong>Result</strong> panel shows the generated
formula that you can copy into your CSS
</li>
</ul>
<p>
Confused about fluid typography? Read my post, "<a
href="https://ryanfeigenbaum.com/fluid-typography"
>Fluid Typography</a
>" which explains how this calculator works in detail
</p>
</div>
</div>
</article>
</div>
<!-- Form -->
<div class="tile is-vertical is-8">
<div class="tile">
<div class="tile is-parent is-vertical">
<article class="tile is-child notification box">
<div class="field">
<label for="min-fs" class="label">Min Font Size</label>
<div class="field has-addons">
<p class="control is-expanded">
<input
id="min-fs"
type="text"
value="1rem"
class="input"
placeholder="1rem"
pattern="[\d.]+([Rr][Ee][Mm]|[Pp][Xx])"
required
/>
</p>
<p class="control">
<a
class="button is-static is-family-code"
data-unit="min-fs"
></a>
</p>
</div>
<p class="help"></p>
</div>
</article>
<article class="tile is-child notification box">
<div class="field">
<label for="max-fs" class="label">Max Font Size </label>
<div class="field has-addons">
<p class="control is-expanded">
<input
id="max-fs"
type="text"
value="1.25rem"
class="input"
placeholder="1.25rem"
pattern="[\d.]+([Rr][Ee][Mm]|[Pp][Xx])"
required
/>
</p>
<p class="control">
<a
class="button is-static is-family-code"
data-unit="max-fs"
></a>
</p>
</div>
<p class="help"></p>
</div>
</article>
</div>
<div class="tile is-parent is-vertical">
<article class="tile is-child notification box">
<div class="field">
<label for="min-vw" class="label">Min Viewport</label>
<div class="field has-addons">
<p class="control is-expanded">
<input
id="min-vw"
type="text"
value="20rem"
class="input"
placeholder="20rem"
pattern="[\d.]+([Rr][Ee][Mm]|[Pp][Xx])"
required
/>
</p>
<p class="control">
<a
class="button is-static is-family-code"
data-unit="min-vw"
></a>
</p>
</div>
<p class="help"></p>
</div>
</article>
<article class="tile is-child notification box">
<div class="field">
<label for="max-vp" class="label">Max Viewport</label>
<div class="field has-addons">
<p class="control is-expanded">
<input
id="max-vw"
type="text"
value="120rem"
class="input"
placeholder="120rem"
pattern="[\d.]+([Rr][Ee][Mm]|[Pp][Xx])"
required
/>
</p>
<p class="control">
<a
class="button is-static is-family-code"
data-unit="max-vw"
></a>
</p>
</div>
<p class="help"></p>
</div>
</article>
</div>
</div>
<div class="tile is-parent">
<article class="tile is-child notification box">
<p class="title">Result</p>
<p class="subtitle">CSS clamp property with fallback</p>
<pre
id="calc"
class="notification user-select-all is-family-code"
>
... </pre
>
<p>
Another
<a
href="https://dev.to/yuschick/fluid-typography-with-css-clamp-is-my-new-favorite-thing-4lg3"
>fallback strategy</a
>
that more closely replicates clamp's functionality is
available.
</p>
</article>
</div>
</div>
</div>
<div class="tile is-ancestor">
<div class="tile is-parent">
<div class="tile is-child box notification is-info">
<h2 class="title">Simulated Viewport</h2>
<p class="subtitle">Visualize the Scale 👁️🗨️</p>
</div>
</div>
</div>
<div class="tile is-ancestor">
<div class="tile is-vertical is-6">
<div class="tile">
<div class="tile is-parent">
<div class="tile is-child box notification">
<div class="content">
<p class="title">See Your Scale</p>
<p>
Use the slider below to simulate the increase and decrease
of the viewport's size. Font size will scale according to
the values chosen above.
</p>
</div>
</div>
</div>
</div>
<div class="tile">
<div class="tile is-parent">
<div class="tile is-child box notification">
<p class="title">Viewport Control</p>
<div class="content">
<form id="change-viewport" class="field">
<label for="slider" class="label slider-label"
>Slide to change viewport width
</label>
<div class="control columns">
<div class="column is-three-quarters is-flex">
<input
type="range"
class="is-flex-grow-1"
min="250"
max="2550"
step="50"
id="slider"
value="600"
/>
</div>
<div class="column">
<span
id="viewport"
class="tag is-info is-dark"
></span>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="tile is-hidden-mobile">
<div class="tile is-parent">
<div class="tile is-child notification box">
<p class="header is-uppercase has-text-centered">
Base Font Size
</p>
<p id="computed" class="title has-text-centered"></p>
</div>
</div>
<div class="tile is-parent">
<div class="tile is-child notification box">
<p class="header is-uppercase has-text-centered">
Viewport Width
</p>
<p id="viewport-title" class="title has-text-centered"></p>
</div>
</div>
</div>
</div>
<div class="tile">
<div class="tile is-parent">
<div class="tile is-child box notification">
<div class="sample-container">
<div class="sample">
<div class="mb-2">
<h2>Metamorphosis</h2>
</div>
<div class="is-flex is-align-items-center mb-5">
<img
class="mr-2 avatar"
src="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b4/Kafka.jpg/197px-Kafka.jpg"
/>
<h3>Franz Kafka</h3>
</div>
<div class="content">
<p>
One morning, when Gregor Samsa woke from troubled
dreams, he found himself transformed in his bed into a
horrible vermin. He lay on his armour-like back, and if
he lifted his head a little he could see his brown
belly, slightly domed and divided by arches into stiff
sections. The bedding was hardly able to cover it and
seemed ready to slide off any moment. His many legs,
pitifully thin compared with the size of the rest of
him, waved about helplessly as he looked.
</p>
<p>
"What's happened to me?" he thought. It wasn't a dream.
His room, a proper human room although a little too
small, lay peacefully between its four familiar walls. A
collection of textile samples lay spread out on the
table - Samsa was a travelling salesman - and above it
there hung a picture that he had recently cut out of an
illustrated magazine and housed in a nice, gilded frame.
It showed a lady fitted out with a fur hat and fur boa
who sat upright, raising a heavy fur muff that covered
the whole of her lower arm towards the viewer.
</p>
<p>
Gregor then turned to look out the window at the dull
weather. Drops of rain could be heard hitting the pane,
which made him feel quite sad. "How about if I sleep a
little bit longer and forget all this nonsense", he
thought, but that was something he was unable to do
because he was used to sleeping on his right, and in his
present state couldn't get into that position. However
hard he threw himself onto his right, he always rolled
back to where he was. He must have tried it a hundred
times, shut his eyes so that he wouldn't have to look at
the floundering legs, and only stopped when he began to
feel a mild, dull pain there that he had never felt
before.
</p>
<a
class="button is-info"
href="http://www.gutenberg.org/ebooks/5200"
target="_blank"
rel="noopener noreferrer"
>Continue Reading 🪲</a
>
</div>
</div>
</div>
<!-- Viewport Icon -->
<div
class="
is-justify-content-center
is-flex-direction-column
is-align-items-center
is-flex
icon-box
has-background-light
p-2
box
notification
"
>
<div class="viewport-icon is-hidden mobile image is-64x64">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="currentColor"
class="bi bi-phone"
viewBox="0 0 16 16"
>
<path
d="M11 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1h6zM5 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H5z"
/>
<path d="M8 14a1 1 0 1 0 0-2 1 1 0 0 0 0 2z" />
</svg>
</div>
<div class="viewport-icon is-hidden tablet image is-64x64">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="currentColor"
class="bi bi-tablet"
viewBox="0 0 16 16"
>
<path
d="M12 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1h8zM4 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H4z"
/>
<path d="M8 14a1 1 0 1 0 0-2 1 1 0 0 0 0 2z" />
</svg>
</div>
<div class="viewport-icon is-hidden laptop image is-64x64">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="currentColor"
class="bi bi-laptop"
viewBox="0 0 16 16"
>
<path
d="M13.5 3a.5.5 0 0 1 .5.5V11H2V3.5a.5.5 0 0 1 .5-.5h11zm-11-1A1.5 1.5 0 0 0 1 3.5V12h14V3.5A1.5 1.5 0 0 0 13.5 2h-11zM0 12.5h16a1.5 1.5 0 0 1-1.5 1.5h-13A1.5 1.5 0 0 1 0 12.5z"
/>
</svg>
</div>
<div class="viewport-icon is-hidden desktop image is-64x64">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="currentColor"
class="bi bi-display"
viewBox="0 0 16 16"
>
<path
d="M0 4s0-2 2-2h12s2 0 2 2v6s0 2-2 2h-4c0 .667.083 1.167.25 1.5H11a.5.5 0 0 1 0 1H5a.5.5 0 0 1 0-1h.75c.167-.333.25-.833.25-1.5H2s-2 0-2-2V4zm1.398-.855a.758.758 0 0 0-.254.302A1.46 1.46 0 0 0 1 4.01V10c0 .325.078.502.145.602.07.105.17.188.302.254a1.464 1.464 0 0 0 .538.143L2.01 11H14c.325 0 .502-.078.602-.145a.758.758 0 0 0 .254-.302 1.464 1.464 0 0 0 .143-.538L15 9.99V4c0-.325-.078-.502-.145-.602a.757.757 0 0 0-.302-.254A1.46 1.46 0 0 0 13.99 3H2c-.325 0-.502.078-.602.145z"
/>
</svg>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<script src="index.js"></script>
</body>
</html>