@kwtv/tokens 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/package.json +1 -1
- package/tokens/tokens.css +61 -53
- package/tokens/utilities.css +1 -1
package/README.md
CHANGED
|
@@ -26,6 +26,37 @@ import "@kwtv/tokens/tokens.css";
|
|
|
26
26
|
The default theme follows the operating system. Set `data-theme="light"` or
|
|
27
27
|
`data-theme="dark"` on the root element to choose a theme explicitly.
|
|
28
28
|
|
|
29
|
+
## Hosts with a different root font size
|
|
30
|
+
|
|
31
|
+
Space, radius, type and line-height tokens are rem sizes designed for a 16px
|
|
32
|
+
root. In `tokens.css` each one is a multiple of `--kw-rem`, which is `1rem`.
|
|
33
|
+
By default nothing changes.
|
|
34
|
+
|
|
35
|
+
A host that sets its own root font size, like Payload's admin at 13px or
|
|
36
|
+
14px, shrinks every token with it. Set `--kw-rem` on `:root` to keep the
|
|
37
|
+
designed sizes:
|
|
38
|
+
|
|
39
|
+
```css
|
|
40
|
+
:root {
|
|
41
|
+
--kw-rem: 16px;
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Set it on `:root`, not on a nested element. The tokens are computed on
|
|
46
|
+
`:root`, so a value further down the tree has no effect. `16px` fixes the
|
|
47
|
+
scale no matter what the root does. `calc(1rem * 16 / 14)` keeps it relative
|
|
48
|
+
to a 14px root instead. The JSON, TS and SCSS exports keep plain rem values.
|
|
49
|
+
|
|
50
|
+
## Variable names
|
|
51
|
+
|
|
52
|
+
The tokens use short, unprefixed names such as `--text`, `--bg`,
|
|
53
|
+
`--font-mono` and `--z-modal`. Some hosts use the same names. Payload's admin
|
|
54
|
+
defines `--font-serif`, `--font-mono` and `--z-modal`, for example. Every
|
|
55
|
+
token sits in `@layer tokens`, so a host's own unlayered declaration always
|
|
56
|
+
wins. Declare the host's value unlayered on `:root` to keep it. A host that
|
|
57
|
+
puts its own variables in a layer declared before `tokens`, as Payload does,
|
|
58
|
+
loses them to the tokens until it does so.
|
|
59
|
+
|
|
29
60
|
## Exports
|
|
30
61
|
|
|
31
62
|
| Import | Contents |
|
package/package.json
CHANGED
package/tokens/tokens.css
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/* Generated by scripts/build-tokens.py. Do not edit by hand. */
|
|
2
2
|
|
|
3
|
-
@layer
|
|
3
|
+
@layer reset, tokens, base, components, motion, utilities;
|
|
4
|
+
@layer tokens.palette, tokens.theme, tokens.scale;
|
|
4
5
|
|
|
5
|
-
@layer palette {
|
|
6
|
+
@layer tokens.palette {
|
|
6
7
|
:root {
|
|
7
8
|
--sage-xlight: #DCF1E8;
|
|
8
9
|
--sage-light: #B1C9BF;
|
|
@@ -39,7 +40,7 @@
|
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
@layer theme {
|
|
43
|
+
@layer tokens.theme {
|
|
43
44
|
:root {
|
|
44
45
|
/* Both themes named explicitly, so either can be referenced
|
|
45
46
|
directly regardless of which one is active. */
|
|
@@ -319,9 +320,16 @@
|
|
|
319
320
|
}
|
|
320
321
|
}
|
|
321
322
|
|
|
322
|
-
@layer scale {
|
|
323
|
+
@layer tokens.scale {
|
|
323
324
|
:root {
|
|
324
|
-
/*
|
|
325
|
+
/* Root size. Every rem size below is a multiple of it. Set it on
|
|
326
|
+
:root when the host changes the root font size, for example
|
|
327
|
+
--kw-rem: 16px, and the scale stays where it was designed. */
|
|
328
|
+
--kw-rem: 1rem;
|
|
329
|
+
|
|
330
|
+
/* Type family. Generic names on purpose, like every token here.
|
|
331
|
+
They sit in a layer, so a host that uses the same names wins
|
|
332
|
+
by declaring them unlayered. */
|
|
325
333
|
--font-sans: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
|
326
334
|
--font-serif: "Source Serif 4 Variable", "Source Serif 4", ui-serif, Georgia, serif;
|
|
327
335
|
--font-mono: "JetBrains Mono Variable", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
|
|
@@ -343,34 +351,34 @@
|
|
|
343
351
|
/* Space */
|
|
344
352
|
--space-0: 0;
|
|
345
353
|
--space-px: 1px;
|
|
346
|
-
--space-0-5: 0.
|
|
347
|
-
--space-1: 0.
|
|
348
|
-
--space-1-5: 0.
|
|
349
|
-
--space-2: 0.
|
|
350
|
-
--space-2-5: 0.
|
|
351
|
-
--space-3: 0.
|
|
352
|
-
--space-4:
|
|
353
|
-
--space-4-5: 1.
|
|
354
|
-
--space-5: 1.
|
|
355
|
-
--space-6: 1.
|
|
356
|
-
--space-7: 1.
|
|
357
|
-
--space-8:
|
|
358
|
-
--space-10: 2.
|
|
359
|
-
--space-12:
|
|
360
|
-
--space-16:
|
|
361
|
-
--space-20:
|
|
362
|
-
--space-24:
|
|
363
|
-
--space-32:
|
|
364
|
-
--space-40:
|
|
365
|
-
--space-48:
|
|
354
|
+
--space-0-5: calc(0.125 * var(--kw-rem));
|
|
355
|
+
--space-1: calc(0.25 * var(--kw-rem));
|
|
356
|
+
--space-1-5: calc(0.375 * var(--kw-rem));
|
|
357
|
+
--space-2: calc(0.5 * var(--kw-rem));
|
|
358
|
+
--space-2-5: calc(0.625 * var(--kw-rem));
|
|
359
|
+
--space-3: calc(0.75 * var(--kw-rem));
|
|
360
|
+
--space-4: var(--kw-rem);
|
|
361
|
+
--space-4-5: calc(1.125 * var(--kw-rem));
|
|
362
|
+
--space-5: calc(1.25 * var(--kw-rem));
|
|
363
|
+
--space-6: calc(1.5 * var(--kw-rem));
|
|
364
|
+
--space-7: calc(1.75 * var(--kw-rem));
|
|
365
|
+
--space-8: calc(2 * var(--kw-rem));
|
|
366
|
+
--space-10: calc(2.5 * var(--kw-rem));
|
|
367
|
+
--space-12: calc(3 * var(--kw-rem));
|
|
368
|
+
--space-16: calc(4 * var(--kw-rem));
|
|
369
|
+
--space-20: calc(5 * var(--kw-rem));
|
|
370
|
+
--space-24: calc(6 * var(--kw-rem));
|
|
371
|
+
--space-32: calc(8 * var(--kw-rem));
|
|
372
|
+
--space-40: calc(10 * var(--kw-rem));
|
|
373
|
+
--space-48: calc(12 * var(--kw-rem));
|
|
366
374
|
|
|
367
375
|
/* Radius */
|
|
368
376
|
--radius-none: 0;
|
|
369
|
-
--radius-sm: 0.
|
|
370
|
-
--radius-md: 0.
|
|
371
|
-
--radius-lg: 0.
|
|
372
|
-
--radius-xl:
|
|
373
|
-
--radius-2xl: 1.
|
|
377
|
+
--radius-sm: calc(0.1875 * var(--kw-rem));
|
|
378
|
+
--radius-md: calc(0.375 * var(--kw-rem));
|
|
379
|
+
--radius-lg: calc(0.625 * var(--kw-rem));
|
|
380
|
+
--radius-xl: var(--kw-rem);
|
|
381
|
+
--radius-2xl: calc(1.5 * var(--kw-rem));
|
|
374
382
|
--radius-full: 9999px;
|
|
375
383
|
|
|
376
384
|
/* Duration */
|
|
@@ -404,31 +412,31 @@
|
|
|
404
412
|
--z-tooltip: 1600;
|
|
405
413
|
|
|
406
414
|
/* Type scale */
|
|
407
|
-
--text-3xs: 0.
|
|
408
|
-
--leading-3xs:
|
|
409
|
-
--text-2xs: 0.
|
|
410
|
-
--leading-2xs:
|
|
411
|
-
--text-xs: 0.
|
|
412
|
-
--leading-xs: 1.
|
|
413
|
-
--text-sm: 0.
|
|
414
|
-
--leading-sm: 1.
|
|
415
|
-
--text-base:
|
|
416
|
-
--leading-base: 1.
|
|
417
|
-
--text-lg: 1.
|
|
418
|
-
--leading-lg: 1.
|
|
419
|
-
--text-xl: 1.
|
|
420
|
-
--leading-xl: 1.
|
|
421
|
-
--text-2xl: 1.
|
|
422
|
-
--leading-2xl:
|
|
423
|
-
--text-3xl: 1.
|
|
424
|
-
--leading-3xl: 2.
|
|
425
|
-
--text-4xl: 2.
|
|
426
|
-
--leading-4xl: 2.
|
|
427
|
-
--text-5xl:
|
|
415
|
+
--text-3xs: calc(0.625 * var(--kw-rem));
|
|
416
|
+
--leading-3xs: var(--kw-rem);
|
|
417
|
+
--text-2xs: calc(0.6875 * var(--kw-rem));
|
|
418
|
+
--leading-2xs: var(--kw-rem);
|
|
419
|
+
--text-xs: calc(0.75 * var(--kw-rem));
|
|
420
|
+
--leading-xs: calc(1.125 * var(--kw-rem));
|
|
421
|
+
--text-sm: calc(0.875 * var(--kw-rem));
|
|
422
|
+
--leading-sm: calc(1.375 * var(--kw-rem));
|
|
423
|
+
--text-base: var(--kw-rem);
|
|
424
|
+
--leading-base: calc(1.625 * var(--kw-rem));
|
|
425
|
+
--text-lg: calc(1.125 * var(--kw-rem));
|
|
426
|
+
--leading-lg: calc(1.75 * var(--kw-rem));
|
|
427
|
+
--text-xl: calc(1.25 * var(--kw-rem));
|
|
428
|
+
--leading-xl: calc(1.875 * var(--kw-rem));
|
|
429
|
+
--text-2xl: calc(1.5 * var(--kw-rem));
|
|
430
|
+
--leading-2xl: calc(2 * var(--kw-rem));
|
|
431
|
+
--text-3xl: calc(1.875 * var(--kw-rem));
|
|
432
|
+
--leading-3xl: calc(2.25 * var(--kw-rem));
|
|
433
|
+
--text-4xl: calc(2.25 * var(--kw-rem));
|
|
434
|
+
--leading-4xl: calc(2.5 * var(--kw-rem));
|
|
435
|
+
--text-5xl: calc(3 * var(--kw-rem));
|
|
428
436
|
--leading-5xl: 1.08;
|
|
429
|
-
--text-6xl: 3.
|
|
437
|
+
--text-6xl: calc(3.75 * var(--kw-rem));
|
|
430
438
|
--leading-6xl: 1.05;
|
|
431
|
-
--text-7xl: 4.
|
|
439
|
+
--text-7xl: calc(4.5 * var(--kw-rem));
|
|
432
440
|
--leading-7xl: 1.02;
|
|
433
441
|
}
|
|
434
442
|
|