-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy paththeme-variables.js
504 lines (490 loc) · 13.3 KB
/
theme-variables.js
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
/*
* Custom function used to generate the output of the theme variables
*/
var generateThemeVariables = function (params) {
let fontParams = {
'system-ui': {
name: 'SystemUI',
family: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
hasItalic: false
},
'adventpro': {
name: 'Advent Pro',
family: '\'Advent Pro\', sans-serif',
weight: '100 900',
hasItalic: true
},
'aleo': {
name: 'Aleo',
family: '\'Aleo\', serif',
weight: '100 900',
hasItalic: true
},
'andadapro': {
name: 'Andada Pro',
family: '\'Andada Pro\', serif',
weight: '400 840',
hasItalic: true
},
'antonio': {
name: 'Antonio',
family: '\'Antonio\', sans-serif',
weight: '100 700',
hasItalic: false
},
'archivonarrow': {
name: 'Archivo Narrow',
family: '\'Archivo Narrow\', sans-serif',
weight: '400 700',
hasItalic: true
},
'asap': {
name: 'Asap',
family: '\'Asap\', sans-serif',
weight: '400 700',
hasItalic: true
},
'assistant': {
name: 'Assistant',
family: '\'Assistant\', sans-serif',
weight: '200 800',
hasItalic: false
},
'besley': {
name: 'Besley',
family: '\'Besley\', serif',
weight: '400 900',
hasItalic: true
},
'bitter': {
name: 'Bitter',
family: '\'Bitter\', serif',
weight: '100 900',
hasItalic: true
},
'brygada1918': {
name: 'Brygada 1918',
family: '\'Brygada 1918\', serif',
weight: '400 700',
hasItalic: true
},
'cabin': {
name: 'Cabin',
family: '\'Cabin\', sans-serif',
weight: '400 700',
hasItalic: true
},
'cairo': {
name: 'Cairo',
family: '\'Cairo\', sans-serif',
weight: '200 1000',
hasItalic: false
},
'comfortaa': {
name: 'Comfortaa',
family: '\'Comfortaa\', cursive',
weight: '300 700',
hasItalic: false
},
'dancingscript': {
name: 'Dancing Script',
family: '\'Dancing Script\', cursive',
weight: '400 700',
hasItalic: false
},
'dosis': {
name: 'Dosis',
family: '\'Dosis\', sans-serif',
weight: '200 800',
hasItalic: false
},
'domine': {
name: 'Domine',
family: '\'Domine\', serif',
weight: '400 700',
hasItalic: false
},
'exo': {
name: 'Exo',
family: '\'Exo\', sans-serif',
weight: '100 900',
hasItalic: true
},
'faustina': {
name: 'Faustina',
family: '\'Faustina\', serif',
weight: '300 800',
hasItalic: true
},
'figtree': {
name: 'Figtree',
family: '\'Figtree\', sans-serif',
weight: '300 900',
hasItalic: true
},
'frankruhllibre': {
name: 'Frank Ruhl Libre',
family: '\'Frank Ruhl Libre\', serif',
weight: '300 900',
hasItalic: false
},
'glory': {
name: 'Glory',
family: '\'Glory\', sans-serif',
weight: '100 800',
hasItalic: true
},
'gluten': {
name: 'Gluten',
family: '\'Gluten\', cursive',
weight: '100 900',
hasItalic: false
},
'heebo': {
name: 'Heebo',
family: '\'Heebo\', sans-serif',
weight: '100 900',
hasItalic: false
},
'imbue': {
name: 'Imbue',
family: '\'Imbue\', serif',
weight: '100 900',
hasItalic: false
},
'instrumentsans': {
name: 'Instrument Sans',
family: '\'Instrument Sans\', serif',
weight: '400 700',
hasItalic: true
},
'inter': {
name: 'Inter',
family: '\'Inter\', serif',
weight: '100 900',
hasItalic: true
},
'jetbrainsmono': {
name: 'JetBrains Mono',
family: '\'JetBrains Mono\', monospace',
weight: '100 800',
hasItalic: true
},
'jura': {
name: 'Jura',
family: '\'Jura\', sans-serif',
weight: '300 700',
hasItalic: false
},
'karla': {
name: 'Karla',
family: '\'Karla\', sans-serif',
weight: '200 800',
hasItalic: true
},
'kreon': {
name: 'Kreon',
family: '\'Kreon\', serif',
weight: '300 700',
hasItalic: false
},
'labrada': {
name: 'Labrada',
family: '\'Labrada\', serif',
weight: '100 900',
hasItalic: true
},
'lemonada': {
name: 'Lemonada',
family: '\'Lemonada\', cursive',
weight: '300 700',
hasItalic: false
},
'lexend': {
name: 'Lexend',
family: '\'Lexend\', sans-serif',
weight: '100 900',
hasItalic: false
},
'librefranklin': {
name: 'Libre Franklin',
family: '\'Libre Franklin\', sans-serif',
weight: '100 900',
hasItalic: true
},
'lora': {
name: 'Lora',
family: '\'Lora\', serif',
weight: '400 700',
hasItalic: true
},
'manuale': {
name: 'Manuale',
family: '\'Manuale\', serif',
weight: '300 800',
hasItalic: true
},
'manrope': {
name: 'Manrope',
family: '\'Manrope\', sans-serif',
weight: '100 900',
hasItalic: false
},
'mavenpro': {
name: 'Maven Pro',
family: '\'Maven Pro\', sans-serif',
weight: '400 900',
hasItalic: false
},
'merriweathersans': {
name: 'Merriweather Sans',
family: '\'Merriweather Sans\', sans-serif',
weight: '300 800',
hasItalic: true
},
'montserrat': {
name: 'Montserrat',
family: '\'Montserrat\', sans-serif',
weight: '100 900',
hasItalic: true
},
'nunito': {
name: 'Nunito',
family: '\'Nunito\', sans-serif',
weight: '200 1000',
hasItalic: true
},
'orbitron': {
name: 'Orbitron',
family: '\'Orbitron\', sans-serif',
weight: '400 900',
hasItalic: false
},
'oswald': {
name: 'Oswald',
family: '\'Oswald\', sans-serif',
weight: '200 700',
hasItalic: false
},
'petrona': {
name: 'Petrona',
family: '\'Petrona\', serif',
weight: '100 900',
hasItalic: true
},
'playfairdisplay': {
name: 'Playfair Display',
family: '\'Playfair Display\', serif',
weight: '400 900',
hasItalic: true
},
'plusjakartasans': {
name: 'Plus Jakarta Sans',
family: '\'Plus Jakarta Sans\', sans-serif',
weight: '200 800',
hasItalic: true
},
'publicsans': {
name: 'Public Sans',
family: '\'Public Sans\', sans-serif',
weight: '100 900',
hasItalic: true
},
'quicksand': {
name: 'Quicksand',
family: '\'Quicksand\', sans-serif',
weight: '300 700',
hasItalic: false
},
'raleway': {
name: 'Raleway',
family: '\'Raleway\', sans-serif',
weight: '100 900',
hasItalic: true
},
'redhatdisplay': {
name: 'Red Hat Display',
family: '\'Red Hat Display\', sans-serif',
weight: '300 900',
hasItalic: true
},
'redhatmono': {
name: 'Red Hat Mono',
family: '\'Red Hat Mono\', monospace',
weight: '300 700',
hasItalic: true
},
'robotoflex': {
name: 'Roboto Flex',
family: '\'Roboto Flex\', sans-serif',
weight: '100 900',
hasItalic: false
},
'robotoslab': {
name: 'Roboto Slab',
family: '\'Roboto Slab\', serif',
weight: '100 900',
hasItalic: false
},
'rokkitt': {
name: 'Rokkitt',
family: '\'Rokkitt\', serif',
weight: '100 900',
hasItalic: true
},
'rubik': {
name: 'Rubik',
family: '\'Rubik\', sans-serif',
weight: '300 900',
hasItalic: true
},
'ruda': {
name: 'Ruda',
family: '\'Ruda\', sans-serif',
weight: '400 900',
hasItalic: false
},
'smoochsans': {
name: 'Smooch Sans',
family: '\'Smooch Sans\', sans-serif',
weight: '100 900',
hasItalic: false
},
'sourcecodepro': {
name: 'Source Code Pro',
family: '\'Source Code Pro\', monospace',
weight: '200 900',
hasItalic: true
},
'spartan': {
name: 'Spartan',
family: '\'Spartan\', sans-serif',
weight: '100 900',
hasItalic: false
},
'urbanist': {
name: 'Urbanist',
family: '\'Urbanist\', sans-serif',
weight: '100 900',
hasItalic: true
},
'worksans': {
name: 'Work Sans',
family: '\'Work Sans\', sans-serif',
weight: '100 900',
hasItalic: true
},
'yanonekaffeesatz': {
name: 'Yanone Kaffeesatz',
family: '\'Yanone Kaffeesatz\', sans-serif',
weight: '200 700',
hasItalic: false
},
'yrsa': {
name: 'Yrsa',
family: '\'Yrsa\', serif',
weight: '300 700',
hasItalic: true
}
};
let fontBodyName = fontParams[params.fontBody]?.name;
let fontBodyFamily = fontParams[params.fontBody]?.family;
let fontBodyWeight = fontParams[params.fontBody]?.weight;
let fontBodyHasItalic = fontParams[params.fontBody]?.hasItalic;
let fontHeadingsName = fontParams[params.fontHeadings]?.name;
let fontHeadingsFamily = fontParams[params.fontHeadings]?.family;
let fontHeadingsWeight = fontParams[params.fontHeadings]?.weight;
let fontHeadingsHasItalic = fontParams[params.fontHeadings]?.hasItalic;
let output = '';
let loadedFonts = new Set();
const addFontFace = (key, name, weight, hasItalic) => {
if (!loadedFonts.has(name)) {
output += `
@font-face {
font-family: '${name}';
src: url('../dynamic/fonts/${key}/${key}.woff2') format('woff2');
font-weight: ${weight};
font-display: swap;
font-style: normal;
}
`;
loadedFonts.add(name);
}
if (hasItalic && !loadedFonts.has(`${name}-italic`)) {
output += `
@font-face {
font-family: '${name}';
src: url('../dynamic/fonts/${key}/${key}-italic.woff2') format('woff2');
font-weight: ${weight};
font-display: swap;
font-style: italic;
}
`;
loadedFonts.add(`${name}-italic`);
}
};
if (params.fontBody !== 'system-ui') {
addFontFace(params.fontBody, fontBodyName, fontBodyWeight, params.fontBodyItalic && fontBodyHasItalic);
}
if (params.fontHeadings !== 'system-ui') {
addFontFace(params.fontHeadings, fontHeadingsName, fontHeadingsWeight, params.fontHeadingsItalic && fontHeadingsHasItalic);
}
if (params.fontMenu === 'system-ui') {
params.fontMenu = fontParams['system-ui'].family;
}
if (params.fontLogo === 'system-ui') {
params.fontLogo = fontParams['system-ui'].family;
}
// Fluid base font-size
const minScreen = 20; // rem
const maxScreen = 100; // rem
const screenRange = maxScreen - minScreen;
const minFontSize = params.minFontSize;
const maxFontSize = params.maxFontSize;
const fontSizeRange = maxFontSize - minFontSize;
const fontSizeValue = `clamp(${minFontSize}rem, ${minFontSize}rem + (${fontSizeRange} * ((100vw - ${minScreen}rem) / ${screenRange})), ${maxFontSize}rem)`;
output += `
:root {
--page-margin: ${params.pageMargin};
--page-width: ${params.pageWidth};
--entry-width: ${params.entryWidth};
--header-height: 4rem;
--border-radius: 8px;
--card-image-height: ${params.cardsImageHeight};
--body-font: ${fontBodyFamily};
--heading-font: ${fontHeadingsFamily};
--logo-font: ${params.fontLogo};
--menu-font: ${params.fontMenu};
--font-size: ${fontSizeValue};
--font-weight-normal: ${params.fontBodyWeight};
--font-weight-bold: ${params.fontBoldWeight};
--line-height: ${params.lineHeight};
--letter-spacing: ${params.letterSpacing}em;
--headings-weight: ${params.fontHeadignsWeight};
--headings-transform: ${params.fontHeadingsTransform};
--headings-style: ${params.fontHeadingsStyle};
--headings-letter-spacing: ${params.fontHeadingsletterSpacing}em;
--headings-line-height: ${params.fontHeadingsLineHeight};
--white: #FFFFFF;
--black: #000000;
--dark: #101011;
--gray-1: #343435;
--gray-2: #6D6E6F;
--light: #D5D5D5;
--lighter: #F3F3F3;
--color: ${params.primaryColor};
--color-rgb: ${params.primaryColor.replace('#', '').match(/[a-f0-9]{2,2}/gmi).map(n => parseInt(n, 16)).join(', ')};
--text-color: ${params.textColor};
--headings-color: ${params.headingsColor};
--link-color: ${params.primaryColor};
--link-color-hover: #101011;
}
@media all and (min-width: 56.25em) {
:root {
--header-height: ${params.navbarHeight};
}
}
`;
return output;
}
module.exports = generateThemeVariables;