@kwtv/tokens 0.4.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 +56 -49
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
|
@@ -322,7 +322,14 @@
|
|
|
322
322
|
|
|
323
323
|
@layer tokens.scale {
|
|
324
324
|
:root {
|
|
325
|
-
/*
|
|
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. */
|
|
326
333
|
--font-sans: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
|
327
334
|
--font-serif: "Source Serif 4 Variable", "Source Serif 4", ui-serif, Georgia, serif;
|
|
328
335
|
--font-mono: "JetBrains Mono Variable", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
|
|
@@ -344,34 +351,34 @@
|
|
|
344
351
|
/* Space */
|
|
345
352
|
--space-0: 0;
|
|
346
353
|
--space-px: 1px;
|
|
347
|
-
--space-0-5: 0.
|
|
348
|
-
--space-1: 0.
|
|
349
|
-
--space-1-5: 0.
|
|
350
|
-
--space-2: 0.
|
|
351
|
-
--space-2-5: 0.
|
|
352
|
-
--space-3: 0.
|
|
353
|
-
--space-4:
|
|
354
|
-
--space-4-5: 1.
|
|
355
|
-
--space-5: 1.
|
|
356
|
-
--space-6: 1.
|
|
357
|
-
--space-7: 1.
|
|
358
|
-
--space-8:
|
|
359
|
-
--space-10: 2.
|
|
360
|
-
--space-12:
|
|
361
|
-
--space-16:
|
|
362
|
-
--space-20:
|
|
363
|
-
--space-24:
|
|
364
|
-
--space-32:
|
|
365
|
-
--space-40:
|
|
366
|
-
--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));
|
|
367
374
|
|
|
368
375
|
/* Radius */
|
|
369
376
|
--radius-none: 0;
|
|
370
|
-
--radius-sm: 0.
|
|
371
|
-
--radius-md: 0.
|
|
372
|
-
--radius-lg: 0.
|
|
373
|
-
--radius-xl:
|
|
374
|
-
--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));
|
|
375
382
|
--radius-full: 9999px;
|
|
376
383
|
|
|
377
384
|
/* Duration */
|
|
@@ -405,31 +412,31 @@
|
|
|
405
412
|
--z-tooltip: 1600;
|
|
406
413
|
|
|
407
414
|
/* Type scale */
|
|
408
|
-
--text-3xs: 0.
|
|
409
|
-
--leading-3xs:
|
|
410
|
-
--text-2xs: 0.
|
|
411
|
-
--leading-2xs:
|
|
412
|
-
--text-xs: 0.
|
|
413
|
-
--leading-xs: 1.
|
|
414
|
-
--text-sm: 0.
|
|
415
|
-
--leading-sm: 1.
|
|
416
|
-
--text-base:
|
|
417
|
-
--leading-base: 1.
|
|
418
|
-
--text-lg: 1.
|
|
419
|
-
--leading-lg: 1.
|
|
420
|
-
--text-xl: 1.
|
|
421
|
-
--leading-xl: 1.
|
|
422
|
-
--text-2xl: 1.
|
|
423
|
-
--leading-2xl:
|
|
424
|
-
--text-3xl: 1.
|
|
425
|
-
--leading-3xl: 2.
|
|
426
|
-
--text-4xl: 2.
|
|
427
|
-
--leading-4xl: 2.
|
|
428
|
-
--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));
|
|
429
436
|
--leading-5xl: 1.08;
|
|
430
|
-
--text-6xl: 3.
|
|
437
|
+
--text-6xl: calc(3.75 * var(--kw-rem));
|
|
431
438
|
--leading-6xl: 1.05;
|
|
432
|
-
--text-7xl: 4.
|
|
439
|
+
--text-7xl: calc(4.5 * var(--kw-rem));
|
|
433
440
|
--leading-7xl: 1.02;
|
|
434
441
|
}
|
|
435
442
|
|