@eluan/tokens 0.1.0 → 0.3.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 +45 -6
- package/dist/files/paper-mono-variable.woff2 +0 -0
- package/dist/fonts-base.css +12 -3
- package/dist/fonts.css +9 -9
- package/dist/index.d.ts +154 -2
- package/dist/index.js +162 -14
- package/dist/modes.css +23 -24
- package/dist/primitives.css +261 -232
- package/dist/spacing.css +72 -55
- package/dist/themes.css +40 -156
- package/dist/tokens.css +3 -2
- package/dist/typeset.css +149 -0
- package/package.json +8 -6
- package/dist/fonts-industrial-retro.css +0 -3
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> Design tokens, CSS variables, themes, and fonts for the [Eluan](https://github.com/vasfio/eluan) design system.
|
|
4
4
|
|
|
5
|
-
A three-layer token architecture (primitives → modes → themes) exposed as CSS custom properties scoped to `[data-theme]`, `[data-mode]`, `[data-spacing]`, and `[data-
|
|
5
|
+
A three-layer token architecture (primitives → modes → themes) exposed as CSS custom properties scoped to `[data-theme]`, `[data-mode]`, `[data-spacing]`, `[data-curves]`, and `[data-typeset]` attributes.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -24,22 +24,61 @@ import "@eluan/tokens/css"
|
|
|
24
24
|
Then activate a theme by setting attributes on `<html>` (or use `<EluanProvider>` from `@eluan/core`, which wires this up automatically):
|
|
25
25
|
|
|
26
26
|
```html
|
|
27
|
-
<html data-theme="
|
|
27
|
+
<html data-theme="minimal" data-mode="light" data-spacing="standard" data-curves="slight">
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
+
## Token families
|
|
31
|
+
|
|
32
|
+
| Family | Tokens | Driven by |
|
|
33
|
+
|---|---|---|
|
|
34
|
+
| Color | `--container-*`, `--interactive-*`, `--action-*-*`, `--positive-*`, `--cautionary-*`, `--destructive-*`, `--informative-*`, `--important-*`, `--dataviz-N-*` | `data-theme` + `data-mode` |
|
|
35
|
+
| Spacing | `--spacing-xxs` … `--spacing-4xl` | `data-spacing` |
|
|
36
|
+
| Sizing | `--size-xxs` … `--size-4xl` | `data-spacing` |
|
|
37
|
+
| Curves | `--curves-xxs` … `--curves-xl` | `data-curves` |
|
|
38
|
+
| Typeset | `--font-size-step-6` … `--font-size-step-neg3`, plus `--line-height-step-*` and `--letter-spacing-step-*` | viewport, or `data-typeset` |
|
|
39
|
+
| Font-size aliases | `--font-size-xs` … `--font-size-5xl` | `data-spacing` picks a typeset step |
|
|
40
|
+
| Fonts | `--font-heading`, `--font-body`, `--font-mono` | `data-theme` |
|
|
41
|
+
|
|
42
|
+
The typeset is a fluid 12-step scale: each step interpolates between anchors at 480px, 748px, and 1024px viewport widths, so type resizes without media queries. `data-typeset="small" \| "medium" \| "large"` pins the whole scale (or any subtree) to one column; omit the attribute for fluid behaviour. Spacing density shifts the `--font-size-*` aliases one step up or down. Full details in the [theming guide](https://github.com/vasfio/eluan/blob/main/docs/theming.md#the-typeset-axis).
|
|
43
|
+
|
|
44
|
+
## Fonts
|
|
45
|
+
|
|
46
|
+
Two faces ship with the package:
|
|
47
|
+
|
|
48
|
+
- **Paper Mono** — the monospace face for every theme. A variable font (weight axis 100–800) vendored as WOFF2 inside the package, so it works offline with no CDN or extra dependency. Licensed under the SIL Open Font License 1.1.
|
|
49
|
+
- **Inter** — the `minimal` theme's heading and body face, self-hosted via `@fontsource/inter` (weights 400 and 500 only).
|
|
50
|
+
|
|
30
51
|
## Subpath exports
|
|
31
52
|
|
|
32
53
|
```ts
|
|
33
54
|
import "@eluan/tokens/css" // all tokens
|
|
34
|
-
import "@eluan/tokens/fonts/all" // every theme's fonts
|
|
35
|
-
import "@eluan/tokens/fonts/
|
|
36
|
-
import "@eluan/tokens/fonts/minimal"
|
|
55
|
+
import "@eluan/tokens/fonts/all" // every built-in theme's fonts
|
|
56
|
+
import "@eluan/tokens/fonts/base" // shared mono face only
|
|
57
|
+
import "@eluan/tokens/fonts/minimal" // a single theme's fonts
|
|
37
58
|
import { themes, modes, type Theme } from "@eluan/tokens"
|
|
38
59
|
```
|
|
39
60
|
|
|
61
|
+
## JS exports
|
|
62
|
+
|
|
63
|
+
Alongside the CSS, the package exports the raw values for non-CSS consumers (React Native, canvas rendering, design-tool sync):
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import {
|
|
67
|
+
primitiveColors, radius, sizing, sizingSteps, spacing, viewports,
|
|
68
|
+
typeset, typesetAnchors, typesetSteps, lineHeightSteps, letterSpacingSteps,
|
|
69
|
+
resolveTypesetSize,
|
|
70
|
+
fontWeights, fontFamilies, shadows, durations, easings, zIndices, breakpoints,
|
|
71
|
+
themes, modes, spacingScales, curveScales, themeFonts, loadThemeFonts,
|
|
72
|
+
} from "@eluan/tokens"
|
|
73
|
+
|
|
74
|
+
resolveTypesetSize("0", 900) // the fluid step-0 size at a 900px viewport
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`fontSizes` is deprecated — it predates the fluid typeset. Use `typeset` with `resolveTypesetSize()`.
|
|
78
|
+
|
|
40
79
|
## Built-in themes
|
|
41
80
|
|
|
42
|
-
`
|
|
81
|
+
`minimal` is the only built-in theme — it is the neutral, typographic baseline every other look starts from. Define your own via `createTheme()` from `@eluan/core`, or generate a full token set from your brand colors with [`@eluan/theme-generator`](https://github.com/vasfio/eluan/tree/main/packages/theme-generator). See the [theming guide](https://github.com/vasfio/eluan/blob/main/docs/theming.md).
|
|
43
82
|
|
|
44
83
|
## License
|
|
45
84
|
|
|
Binary file
|
package/dist/fonts-base.css
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
/*
|
|
2
2
|
Eluan Design System — Base fonts (shared across all themes)
|
|
3
|
-
|
|
3
|
+
Paper Mono is used by every theme for monospace.
|
|
4
|
+
|
|
5
|
+
Self-hosted variable font (wght 100–800), vendored as WOFF2 next to this
|
|
6
|
+
file. Paper Mono is licensed under the SIL Open Font License 1.1 — see
|
|
7
|
+
THIRD_PARTY_NOTICES.md at the repo root.
|
|
4
8
|
*/
|
|
5
9
|
|
|
6
|
-
@
|
|
7
|
-
|
|
10
|
+
@font-face {
|
|
11
|
+
font-family: "Paper Mono";
|
|
12
|
+
font-style: normal;
|
|
13
|
+
font-weight: 100 800;
|
|
14
|
+
font-display: swap;
|
|
15
|
+
src: url("./files/paper-mono-variable.woff2") format("woff2");
|
|
16
|
+
}
|
package/dist/fonts.css
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Eluan Design System —
|
|
2
|
+
Eluan Design System — every face the built-in themes use.
|
|
3
3
|
Self-hosted, no CDN dependency.
|
|
4
|
-
Only medium weight loaded (max weight across all themes = 500).
|
|
5
|
-
*/
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
Paper Mono ships inside this package as a variable WOFF2 (wght 100–800) and
|
|
6
|
+
is declared in fonts-base.css. Inter comes from Google Fonts via @fontsource;
|
|
7
|
+
only the weights the system actually uses are loaded (max weight across all
|
|
8
|
+
themes = 500), which is why there is no 600+ import — components cap their
|
|
9
|
+
`weight` prop at medium rather than faux-bolding.
|
|
10
|
+
*/
|
|
10
11
|
|
|
11
|
-
/*
|
|
12
|
-
@import "
|
|
13
|
-
@import "@fontsource/geist-mono/500.css";
|
|
12
|
+
/* Paper Mono — all themes mono */
|
|
13
|
+
@import "./fonts-base.css";
|
|
14
14
|
|
|
15
15
|
/* Inter — minimal heading + body */
|
|
16
16
|
@import "@fontsource/inter/400.css";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export declare const modes: readonly ["light", "dim", "dark"];
|
|
2
2
|
export type Mode = (typeof modes)[number];
|
|
3
|
-
export declare const themes: readonly ["
|
|
3
|
+
export declare const themes: readonly ["minimal"];
|
|
4
4
|
export type Theme = (typeof themes)[number];
|
|
5
5
|
export declare const spacingScales: readonly ["compact", "standard", "wide"];
|
|
6
6
|
export type SpacingScale = (typeof spacingScales)[number];
|
|
7
7
|
export declare const curveScales: readonly ["sharp", "slight", "sweeping"];
|
|
8
8
|
export type CurveScale = (typeof curveScales)[number];
|
|
9
|
-
export declare const colorPalettes: readonly ["blazeorange", "bluechill", "blueribbon", "bostonblue", "cerise", "crimson", "electriclime", "electricviolet", "forestgreen", "gossamer", "lochmara", "maitai", "mono", "purpleheart", "redviolet", "rockspray", "seagreen", "teak", "torchred", "violeteggplant"];
|
|
9
|
+
export declare const colorPalettes: readonly ["blazeorange", "bluechill", "blueribbon", "bostonblue", "cerise", "concrete", "crimson", "electriclime", "electricviolet", "forestgreen", "gossamer", "lochmara", "maitai", "mono", "purpleheart", "redviolet", "rockspray", "seagreen", "teak", "torchred", "violeteggplant"];
|
|
10
10
|
export type ColorPalette = (typeof colorPalettes)[number];
|
|
11
11
|
export declare const colorShades: readonly ["50", "100", "200", "300", "400", "500", "600", "700", "800", "900", "950"];
|
|
12
12
|
export type ColorShade = (typeof colorShades)[number];
|
|
@@ -78,6 +78,20 @@ export declare const primitiveColors: {
|
|
|
78
78
|
readonly 900: "#821d3e";
|
|
79
79
|
readonly 950: "#4d0c20";
|
|
80
80
|
};
|
|
81
|
+
readonly concrete: {
|
|
82
|
+
readonly 0: "#ffffff";
|
|
83
|
+
readonly 50: "#fafbf9";
|
|
84
|
+
readonly 100: "#eef0eb";
|
|
85
|
+
readonly 200: "#d7dace";
|
|
86
|
+
readonly 300: "#bfc4b1";
|
|
87
|
+
readonly 400: "#a7ae93";
|
|
88
|
+
readonly 500: "#909876";
|
|
89
|
+
readonly 600: "#757d5e";
|
|
90
|
+
readonly 700: "#5a6048";
|
|
91
|
+
readonly 800: "#3f4332";
|
|
92
|
+
readonly 900: "#2c2f23";
|
|
93
|
+
readonly 950: "#1b1d15";
|
|
94
|
+
};
|
|
81
95
|
readonly crimson: {
|
|
82
96
|
readonly 50: "#fdf2f2";
|
|
83
97
|
readonly 100: "#fde3e4";
|
|
@@ -301,6 +315,22 @@ export declare const sizing: {
|
|
|
301
315
|
readonly xxl: "5rem";
|
|
302
316
|
readonly xxxl: "10rem";
|
|
303
317
|
};
|
|
318
|
+
export declare const sizingSteps: {
|
|
319
|
+
readonly 12: "0.75rem";
|
|
320
|
+
readonly 16: "1rem";
|
|
321
|
+
readonly 20: "1.25rem";
|
|
322
|
+
readonly 24: "1.5rem";
|
|
323
|
+
readonly 32: "2rem";
|
|
324
|
+
readonly 40: "2.5rem";
|
|
325
|
+
readonly 48: "3rem";
|
|
326
|
+
readonly 56: "3.5rem";
|
|
327
|
+
readonly 64: "4rem";
|
|
328
|
+
readonly 80: "5rem";
|
|
329
|
+
readonly 96: "6rem";
|
|
330
|
+
readonly 120: "7.5rem";
|
|
331
|
+
readonly 160: "10rem";
|
|
332
|
+
readonly 240: "15rem";
|
|
333
|
+
};
|
|
304
334
|
export declare const spacing: {
|
|
305
335
|
readonly 0: "0rem";
|
|
306
336
|
readonly 2: "0.125rem";
|
|
@@ -338,6 +368,125 @@ export declare const viewports: {
|
|
|
338
368
|
readonly "3xl": "120rem";
|
|
339
369
|
readonly "4xl": "161.25rem";
|
|
340
370
|
};
|
|
371
|
+
/** Viewport anchors the typeset interpolates between, in CSS px. */
|
|
372
|
+
export declare const typesetAnchors: {
|
|
373
|
+
readonly small: 480;
|
|
374
|
+
readonly medium: 748;
|
|
375
|
+
readonly large: 1024;
|
|
376
|
+
};
|
|
377
|
+
export type TypesetViewport = keyof typeof typesetAnchors;
|
|
378
|
+
/** Per-step anchor sizes in CSS px. */
|
|
379
|
+
export declare const typeset: {
|
|
380
|
+
readonly "6": {
|
|
381
|
+
readonly small: 41.81;
|
|
382
|
+
readonly medium: 53.62;
|
|
383
|
+
readonly large: 68.66;
|
|
384
|
+
};
|
|
385
|
+
readonly "5": {
|
|
386
|
+
readonly small: 34.84;
|
|
387
|
+
readonly medium: 43.68;
|
|
388
|
+
readonly large: 54.93;
|
|
389
|
+
};
|
|
390
|
+
readonly "4": {
|
|
391
|
+
readonly small: 29.03;
|
|
392
|
+
readonly medium: 35.59;
|
|
393
|
+
readonly large: 43.95;
|
|
394
|
+
};
|
|
395
|
+
readonly "3": {
|
|
396
|
+
readonly small: 24.19;
|
|
397
|
+
readonly medium: 29.02;
|
|
398
|
+
readonly large: 35.16;
|
|
399
|
+
};
|
|
400
|
+
readonly "2": {
|
|
401
|
+
readonly small: 20.16;
|
|
402
|
+
readonly medium: 23.66;
|
|
403
|
+
readonly large: 28.13;
|
|
404
|
+
};
|
|
405
|
+
readonly "1": {
|
|
406
|
+
readonly small: 16.8;
|
|
407
|
+
readonly medium: 19.31;
|
|
408
|
+
readonly large: 22.5;
|
|
409
|
+
};
|
|
410
|
+
readonly "0": {
|
|
411
|
+
readonly small: 14;
|
|
412
|
+
readonly medium: 15.76;
|
|
413
|
+
readonly large: 18;
|
|
414
|
+
};
|
|
415
|
+
readonly neg1: {
|
|
416
|
+
readonly small: 11.67;
|
|
417
|
+
readonly medium: 12.87;
|
|
418
|
+
readonly large: 14.4;
|
|
419
|
+
};
|
|
420
|
+
readonly neg2: {
|
|
421
|
+
readonly small: 9.72;
|
|
422
|
+
readonly medium: 10.51;
|
|
423
|
+
readonly large: 11.52;
|
|
424
|
+
};
|
|
425
|
+
readonly neg3: {
|
|
426
|
+
readonly small: 8.1;
|
|
427
|
+
readonly medium: 8.59;
|
|
428
|
+
readonly large: 9.22;
|
|
429
|
+
};
|
|
430
|
+
};
|
|
431
|
+
export type TypesetStep = keyof typeof typeset;
|
|
432
|
+
/** Every step, largest first — handy for iterating a scale showcase. */
|
|
433
|
+
export declare const typesetSteps: readonly ["6", "5", "4", "3", "2", "1", "0", "neg1", "neg2", "neg3"];
|
|
434
|
+
/**
|
|
435
|
+
* Unitless line height per step. Body copy stays generous; headings tighten
|
|
436
|
+
* as they grow. Viewport-independent — the same value at every anchor.
|
|
437
|
+
*/
|
|
438
|
+
export declare const lineHeightSteps: {
|
|
439
|
+
readonly "6": 1.2;
|
|
440
|
+
readonly "5": 1.2;
|
|
441
|
+
readonly "4": 1.2;
|
|
442
|
+
readonly "3": 1.2;
|
|
443
|
+
readonly "2": 1.375;
|
|
444
|
+
readonly "1": 1.375;
|
|
445
|
+
readonly "0": 1.5;
|
|
446
|
+
readonly neg1: 1.5;
|
|
447
|
+
readonly neg2: 1.5;
|
|
448
|
+
readonly neg3: 1.5;
|
|
449
|
+
};
|
|
450
|
+
/**
|
|
451
|
+
* Letter spacing per step, expressed as an **em multiplier** (the CSS tokens
|
|
452
|
+
* use `em` so tracking scales with the fluid size). Multiply by the resolved
|
|
453
|
+
* font size to get an absolute value:
|
|
454
|
+
*
|
|
455
|
+
* const px = resolveTypesetSize("5", width) * letterSpacingSteps["5"]
|
|
456
|
+
*
|
|
457
|
+
* Progressive negative tracking above step-1 gives display text the tight
|
|
458
|
+
* optical fit a dedicated "Tight" cut would, without a second font payload.
|
|
459
|
+
*/
|
|
460
|
+
export declare const letterSpacingSteps: {
|
|
461
|
+
readonly "6": -0.03;
|
|
462
|
+
readonly "5": -0.025;
|
|
463
|
+
readonly "4": -0.02;
|
|
464
|
+
readonly "3": -0.015;
|
|
465
|
+
readonly "2": -0.01;
|
|
466
|
+
readonly "1": 0;
|
|
467
|
+
readonly "0": 0;
|
|
468
|
+
readonly neg1: 0;
|
|
469
|
+
readonly neg2: 0;
|
|
470
|
+
readonly neg3: 0;
|
|
471
|
+
};
|
|
472
|
+
/**
|
|
473
|
+
* Resolve a typeset step to a px size for a given viewport width, using the
|
|
474
|
+
* same two-segment linear interpolation as the CSS clamp()s in typeset.css:
|
|
475
|
+
*
|
|
476
|
+
* <= 480px pinned to the small anchor
|
|
477
|
+
* 480px .. 748px small -> medium
|
|
478
|
+
* 748px .. 1024px medium -> large
|
|
479
|
+
* >= 1024px pinned to the large anchor
|
|
480
|
+
*
|
|
481
|
+
* Lets @eluan/native (and any other non-CSS consumer) match web rendering.
|
|
482
|
+
*/
|
|
483
|
+
export declare function resolveTypesetSize(step: TypesetStep, viewportWidthPx: number): number;
|
|
484
|
+
/**
|
|
485
|
+
* @deprecated Static font sizes were replaced by the fluid typeset. Use
|
|
486
|
+
* `typeset` (with `resolveTypesetSize`) instead — its steps are what the
|
|
487
|
+
* `--font-size-step-*` CSS tokens and the density-scaled `--font-size-*`
|
|
488
|
+
* aliases resolve to. Kept only so existing consumers keep compiling.
|
|
489
|
+
*/
|
|
341
490
|
export declare const fontSizes: {
|
|
342
491
|
readonly xs: 12;
|
|
343
492
|
readonly sm: 14;
|
|
@@ -389,6 +538,7 @@ export declare const themeFonts: Record<Theme, {
|
|
|
389
538
|
heading: string;
|
|
390
539
|
body: string;
|
|
391
540
|
}>;
|
|
541
|
+
export declare const themeNeutrals: Record<Theme, ColorPalette>;
|
|
392
542
|
/**
|
|
393
543
|
* Dynamically load the font CSS for a given theme.
|
|
394
544
|
* Fonts are loaded once and cached — switching back to a previously
|
|
@@ -452,8 +602,10 @@ export declare const breakpoints: {
|
|
|
452
602
|
export type PrimitiveColor = typeof primitiveColors;
|
|
453
603
|
export type RadiusToken = keyof typeof radius;
|
|
454
604
|
export type SizingToken = keyof typeof sizing;
|
|
605
|
+
export type SizingStepToken = keyof typeof sizingSteps;
|
|
455
606
|
export type SpacingToken = keyof typeof spacing;
|
|
456
607
|
export type ViewportToken = keyof typeof viewports;
|
|
608
|
+
/** @deprecated Use `TypesetStep` — see the `fontSizes` deprecation note. */
|
|
457
609
|
export type FontSizeToken = keyof typeof fontSizes;
|
|
458
610
|
export type FontWeightToken = keyof typeof fontWeights;
|
|
459
611
|
export type ShadowToken = keyof typeof shadows;
|
package/dist/index.js
CHANGED
|
@@ -8,10 +8,9 @@ export const modes = ["light", "dim", "dark"];
|
|
|
8
8
|
// ============================================
|
|
9
9
|
// Available Themes
|
|
10
10
|
// ============================================
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
];
|
|
11
|
+
// `minimal` is the only built-in theme. Everything else is a consumer theme
|
|
12
|
+
// built with createTheme() from @eluan/core or @eluan/theme-generator.
|
|
13
|
+
export const themes = ["minimal"];
|
|
15
14
|
// ============================================
|
|
16
15
|
// Available Spacing Scales
|
|
17
16
|
// ============================================
|
|
@@ -29,6 +28,7 @@ export const colorPalettes = [
|
|
|
29
28
|
"blueribbon",
|
|
30
29
|
"bostonblue",
|
|
31
30
|
"cerise",
|
|
31
|
+
"concrete",
|
|
32
32
|
"crimson",
|
|
33
33
|
"electriclime",
|
|
34
34
|
"electricviolet",
|
|
@@ -61,7 +61,7 @@ export const colorShades = [
|
|
|
61
61
|
"900",
|
|
62
62
|
"950",
|
|
63
63
|
];
|
|
64
|
-
// Mono
|
|
64
|
+
// Mono and concrete have an extra "0" shade for pure white
|
|
65
65
|
export const monoShades = ["0", ...colorShades];
|
|
66
66
|
// ============================================
|
|
67
67
|
// Primitive Color Values (Layer 1)
|
|
@@ -133,6 +133,20 @@ export const primitiveColors = {
|
|
|
133
133
|
900: "#821d3e",
|
|
134
134
|
950: "#4d0c20",
|
|
135
135
|
},
|
|
136
|
+
concrete: {
|
|
137
|
+
0: "#ffffff",
|
|
138
|
+
50: "#fafbf9",
|
|
139
|
+
100: "#eef0eb",
|
|
140
|
+
200: "#d7dace",
|
|
141
|
+
300: "#bfc4b1",
|
|
142
|
+
400: "#a7ae93",
|
|
143
|
+
500: "#909876",
|
|
144
|
+
600: "#757d5e",
|
|
145
|
+
700: "#5a6048",
|
|
146
|
+
800: "#3f4332",
|
|
147
|
+
900: "#2c2f23",
|
|
148
|
+
950: "#1b1d15",
|
|
149
|
+
},
|
|
136
150
|
crimson: {
|
|
137
151
|
50: "#fdf2f2",
|
|
138
152
|
100: "#fde3e4",
|
|
@@ -362,6 +376,26 @@ export const sizing = {
|
|
|
362
376
|
xxl: "5rem",
|
|
363
377
|
xxxl: "10rem",
|
|
364
378
|
};
|
|
379
|
+
// Numeric sizing steps — the sizing counterpart of the `spacing` scale, and
|
|
380
|
+
// the primitives the density-scaled --size-* tokens resolve to (spacing.css).
|
|
381
|
+
// Exported alongside `sizing` (the t-shirt scale) for cross-platform parity;
|
|
382
|
+
// the two are separate scales, not aliases of one another.
|
|
383
|
+
export const sizingSteps = {
|
|
384
|
+
12: "0.75rem",
|
|
385
|
+
16: "1rem",
|
|
386
|
+
20: "1.25rem",
|
|
387
|
+
24: "1.5rem",
|
|
388
|
+
32: "2rem",
|
|
389
|
+
40: "2.5rem",
|
|
390
|
+
48: "3rem",
|
|
391
|
+
56: "3.5rem",
|
|
392
|
+
64: "4rem",
|
|
393
|
+
80: "5rem",
|
|
394
|
+
96: "6rem",
|
|
395
|
+
120: "7.5rem",
|
|
396
|
+
160: "10rem",
|
|
397
|
+
240: "15rem",
|
|
398
|
+
};
|
|
365
399
|
// ============================================
|
|
366
400
|
// Spacing Tokens (Layer 1)
|
|
367
401
|
// ============================================
|
|
@@ -406,8 +440,121 @@ export const viewports = {
|
|
|
406
440
|
"4xl": "161.25rem",
|
|
407
441
|
};
|
|
408
442
|
// ============================================
|
|
443
|
+
// Typeset — Fluid Type Scale
|
|
444
|
+
// ============================================
|
|
445
|
+
// The 12-step scale that replaced the static font-size primitives. Each step
|
|
446
|
+
// has three anchor values; on the web they are interpolated by the two-segment
|
|
447
|
+
// clamp()s in typeset.css, on other platforms by resolveTypesetSize() below.
|
|
448
|
+
//
|
|
449
|
+
// small = 14px x 1.2^step at 480px viewport (--viewports-screen-s)
|
|
450
|
+
// large = 18px x 1.25^step at 1024px viewport (--viewports-screen-l)
|
|
451
|
+
// medium = small + 0.44 x (large - small) at 748px (--viewports-screen-m)
|
|
452
|
+
//
|
|
453
|
+
// Keys mirror the CSS token suffixes, so the token name for any step is
|
|
454
|
+
// `--font-size-step-${step}` (likewise --line-height-step-*,
|
|
455
|
+
// --letter-spacing-step-*).
|
|
456
|
+
/** Viewport anchors the typeset interpolates between, in CSS px. */
|
|
457
|
+
export const typesetAnchors = {
|
|
458
|
+
small: 480,
|
|
459
|
+
medium: 748,
|
|
460
|
+
large: 1024,
|
|
461
|
+
};
|
|
462
|
+
/** Per-step anchor sizes in CSS px. */
|
|
463
|
+
export const typeset = {
|
|
464
|
+
"6": { small: 41.81, medium: 53.62, large: 68.66 },
|
|
465
|
+
"5": { small: 34.84, medium: 43.68, large: 54.93 },
|
|
466
|
+
"4": { small: 29.03, medium: 35.59, large: 43.95 },
|
|
467
|
+
"3": { small: 24.19, medium: 29.02, large: 35.16 },
|
|
468
|
+
"2": { small: 20.16, medium: 23.66, large: 28.13 },
|
|
469
|
+
"1": { small: 16.8, medium: 19.31, large: 22.5 },
|
|
470
|
+
"0": { small: 14, medium: 15.76, large: 18 },
|
|
471
|
+
neg1: { small: 11.67, medium: 12.87, large: 14.4 },
|
|
472
|
+
neg2: { small: 9.72, medium: 10.51, large: 11.52 },
|
|
473
|
+
neg3: { small: 8.1, medium: 8.59, large: 9.22 },
|
|
474
|
+
};
|
|
475
|
+
/** Every step, largest first — handy for iterating a scale showcase. */
|
|
476
|
+
export const typesetSteps = [
|
|
477
|
+
"6",
|
|
478
|
+
"5",
|
|
479
|
+
"4",
|
|
480
|
+
"3",
|
|
481
|
+
"2",
|
|
482
|
+
"1",
|
|
483
|
+
"0",
|
|
484
|
+
"neg1",
|
|
485
|
+
"neg2",
|
|
486
|
+
"neg3",
|
|
487
|
+
];
|
|
488
|
+
/**
|
|
489
|
+
* Unitless line height per step. Body copy stays generous; headings tighten
|
|
490
|
+
* as they grow. Viewport-independent — the same value at every anchor.
|
|
491
|
+
*/
|
|
492
|
+
export const lineHeightSteps = {
|
|
493
|
+
"6": 1.2,
|
|
494
|
+
"5": 1.2,
|
|
495
|
+
"4": 1.2,
|
|
496
|
+
"3": 1.2,
|
|
497
|
+
"2": 1.375,
|
|
498
|
+
"1": 1.375,
|
|
499
|
+
"0": 1.5,
|
|
500
|
+
neg1: 1.5,
|
|
501
|
+
neg2: 1.5,
|
|
502
|
+
neg3: 1.5,
|
|
503
|
+
};
|
|
504
|
+
/**
|
|
505
|
+
* Letter spacing per step, expressed as an **em multiplier** (the CSS tokens
|
|
506
|
+
* use `em` so tracking scales with the fluid size). Multiply by the resolved
|
|
507
|
+
* font size to get an absolute value:
|
|
508
|
+
*
|
|
509
|
+
* const px = resolveTypesetSize("5", width) * letterSpacingSteps["5"]
|
|
510
|
+
*
|
|
511
|
+
* Progressive negative tracking above step-1 gives display text the tight
|
|
512
|
+
* optical fit a dedicated "Tight" cut would, without a second font payload.
|
|
513
|
+
*/
|
|
514
|
+
export const letterSpacingSteps = {
|
|
515
|
+
"6": -0.03,
|
|
516
|
+
"5": -0.025,
|
|
517
|
+
"4": -0.02,
|
|
518
|
+
"3": -0.015,
|
|
519
|
+
"2": -0.01,
|
|
520
|
+
"1": 0,
|
|
521
|
+
"0": 0,
|
|
522
|
+
neg1: 0,
|
|
523
|
+
neg2: 0,
|
|
524
|
+
neg3: 0,
|
|
525
|
+
};
|
|
526
|
+
/**
|
|
527
|
+
* Resolve a typeset step to a px size for a given viewport width, using the
|
|
528
|
+
* same two-segment linear interpolation as the CSS clamp()s in typeset.css:
|
|
529
|
+
*
|
|
530
|
+
* <= 480px pinned to the small anchor
|
|
531
|
+
* 480px .. 748px small -> medium
|
|
532
|
+
* 748px .. 1024px medium -> large
|
|
533
|
+
* >= 1024px pinned to the large anchor
|
|
534
|
+
*
|
|
535
|
+
* Lets @eluan/native (and any other non-CSS consumer) match web rendering.
|
|
536
|
+
*/
|
|
537
|
+
export function resolveTypesetSize(step, viewportWidthPx) {
|
|
538
|
+
const { small, medium, large } = typeset[step];
|
|
539
|
+
const { small: vS, medium: vM, large: vL } = typesetAnchors;
|
|
540
|
+
if (viewportWidthPx <= vS)
|
|
541
|
+
return small;
|
|
542
|
+
if (viewportWidthPx >= vL)
|
|
543
|
+
return large;
|
|
544
|
+
if (viewportWidthPx <= vM) {
|
|
545
|
+
return small + ((medium - small) * (viewportWidthPx - vS)) / (vM - vS);
|
|
546
|
+
}
|
|
547
|
+
return medium + ((large - medium) * (viewportWidthPx - vM)) / (vL - vM);
|
|
548
|
+
}
|
|
549
|
+
// ============================================
|
|
409
550
|
// Typography Tokens
|
|
410
551
|
// ============================================
|
|
552
|
+
/**
|
|
553
|
+
* @deprecated Static font sizes were replaced by the fluid typeset. Use
|
|
554
|
+
* `typeset` (with `resolveTypesetSize`) instead — its steps are what the
|
|
555
|
+
* `--font-size-step-*` CSS tokens and the density-scaled `--font-size-*`
|
|
556
|
+
* aliases resolve to. Kept only so existing consumers keep compiling.
|
|
557
|
+
*/
|
|
411
558
|
export const fontSizes = {
|
|
412
559
|
xs: 12,
|
|
413
560
|
sm: 14,
|
|
@@ -459,16 +606,21 @@ export const fontFamilies = {
|
|
|
459
606
|
// Theme → Font Mapping (Google Fonts via @fontsource)
|
|
460
607
|
// ============================================
|
|
461
608
|
export const themeFonts = {
|
|
462
|
-
"industrial-retro": {
|
|
463
|
-
heading: "Geist",
|
|
464
|
-
body: "Geist",
|
|
465
|
-
},
|
|
466
609
|
"minimal": {
|
|
467
610
|
heading: "Inter",
|
|
468
611
|
body: "Inter",
|
|
469
612
|
},
|
|
470
613
|
};
|
|
471
614
|
// ============================================
|
|
615
|
+
// Theme → Neutral Ramp Mapping
|
|
616
|
+
// ============================================
|
|
617
|
+
// Which raw palette each theme aliases to --color-neutral-* (see themes.css).
|
|
618
|
+
// Cross-platform consumers and sync tooling (e.g. Figma variables) can use
|
|
619
|
+
// this to resolve mode backgrounds/foregrounds per theme.
|
|
620
|
+
export const themeNeutrals = {
|
|
621
|
+
"minimal": "mono",
|
|
622
|
+
};
|
|
623
|
+
// ============================================
|
|
472
624
|
// Dynamic Font Loader
|
|
473
625
|
// ============================================
|
|
474
626
|
// Loads theme-specific font CSS on demand via <link> injection.
|
|
@@ -478,7 +630,7 @@ export const themeFonts = {
|
|
|
478
630
|
// useEffect(() => { loadThemeFonts(theme) }, [theme])
|
|
479
631
|
//
|
|
480
632
|
// Usage (vanilla):
|
|
481
|
-
// loadThemeFonts('
|
|
633
|
+
// loadThemeFonts('minimal')
|
|
482
634
|
const _loadedFonts = new Set();
|
|
483
635
|
/**
|
|
484
636
|
* Dynamically load the font CSS for a given theme.
|
|
@@ -493,10 +645,6 @@ export async function loadThemeFonts(theme) {
|
|
|
493
645
|
if (_loadedFonts.has(theme))
|
|
494
646
|
return;
|
|
495
647
|
switch (theme) {
|
|
496
|
-
case "industrial-retro":
|
|
497
|
-
await import("@fontsource/geist/400.css");
|
|
498
|
-
await import("@fontsource/geist/500.css");
|
|
499
|
-
break;
|
|
500
648
|
case "minimal":
|
|
501
649
|
await import("@fontsource/inter/400.css");
|
|
502
650
|
await import("@fontsource/inter/500.css");
|
package/dist/modes.css
CHANGED
|
@@ -8,19 +8,19 @@
|
|
|
8
8
|
* Light Mode (Default)
|
|
9
9
|
* ---------------------------------------- */
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
[data-mode="Light"],
|
|
13
13
|
[data-mode="light"] {
|
|
14
|
-
--backgrounds-primary: var(--color-
|
|
15
|
-
--backgrounds-secondary: var(--color-
|
|
16
|
-
--backgrounds-tertiary: var(--color-
|
|
17
|
-
--backgrounds-quaternary: var(--color-
|
|
18
|
-
--backgrounds-quinary: var(--color-
|
|
19
|
-
--foregrounds-primary: var(--color-
|
|
20
|
-
--foregrounds-secondary: var(--color-
|
|
21
|
-
--foregrounds-tertiary: var(--color-
|
|
22
|
-
--foregrounds-quaternary: var(--color-
|
|
23
|
-
--foregrounds-quinary: var(--color-
|
|
14
|
+
--backgrounds-primary: var(--color-neutral-0);
|
|
15
|
+
--backgrounds-secondary: var(--color-neutral-100);
|
|
16
|
+
--backgrounds-tertiary: var(--color-neutral-200);
|
|
17
|
+
--backgrounds-quaternary: var(--color-neutral-300);
|
|
18
|
+
--backgrounds-quinary: var(--color-neutral-400);
|
|
19
|
+
--foregrounds-primary: var(--color-neutral-950);
|
|
20
|
+
--foregrounds-secondary: var(--color-neutral-800);
|
|
21
|
+
--foregrounds-tertiary: var(--color-neutral-600);
|
|
22
|
+
--foregrounds-quaternary: var(--color-neutral-500);
|
|
23
|
+
--foregrounds-quinary: var(--color-neutral-400);
|
|
24
24
|
--maitai-main: var(--color-maitai-500);
|
|
25
25
|
--maitai-background: var(--color-maitai-50);
|
|
26
26
|
--maitai-tint: var(--color-maitai-100);
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
--blazeorange-shade: var(--color-blazeorange-800);
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
[data-mode="dim"] {
|
|
120
|
+
[data-mode="Dim"], [data-mode="dim"] {
|
|
121
121
|
--backgrounds-primary: var(--color-teak-100);
|
|
122
122
|
--backgrounds-secondary: var(--color-teak-200);
|
|
123
123
|
--backgrounds-tertiary: var(--color-teak-300);
|
|
@@ -224,17 +224,17 @@
|
|
|
224
224
|
--blazeorange-shade: var(--color-blazeorange-900);
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
[data-mode="dark"] {
|
|
228
|
-
--backgrounds-primary: var(--color-
|
|
229
|
-
--backgrounds-secondary: var(--color-
|
|
230
|
-
--backgrounds-tertiary: var(--color-
|
|
231
|
-
--backgrounds-quaternary: var(--color-
|
|
232
|
-
--backgrounds-quinary: var(--color-
|
|
233
|
-
--foregrounds-primary: var(--color-
|
|
234
|
-
--foregrounds-secondary: var(--color-
|
|
235
|
-
--foregrounds-tertiary: var(--color-
|
|
236
|
-
--foregrounds-quaternary: var(--color-
|
|
237
|
-
--foregrounds-quinary: var(--color-
|
|
227
|
+
[data-mode="Dark"], [data-mode="dark"] {
|
|
228
|
+
--backgrounds-primary: var(--color-neutral-800);
|
|
229
|
+
--backgrounds-secondary: var(--color-neutral-900);
|
|
230
|
+
--backgrounds-tertiary: var(--color-neutral-950);
|
|
231
|
+
--backgrounds-quaternary: var(--color-neutral-700);
|
|
232
|
+
--backgrounds-quinary: var(--color-neutral-600);
|
|
233
|
+
--foregrounds-primary: var(--color-neutral-0);
|
|
234
|
+
--foregrounds-secondary: var(--color-neutral-100);
|
|
235
|
+
--foregrounds-tertiary: var(--color-neutral-200);
|
|
236
|
+
--foregrounds-quaternary: var(--color-neutral-300);
|
|
237
|
+
--foregrounds-quinary: var(--color-neutral-400);
|
|
238
238
|
--maitai-main: var(--color-maitai-500);
|
|
239
239
|
--maitai-background: var(--color-maitai-950);
|
|
240
240
|
--maitai-tint: var(--color-maitai-900);
|
|
@@ -330,4 +330,3 @@
|
|
|
330
330
|
--blazeorange-foreground: var(--color-blazeorange-50);
|
|
331
331
|
--blazeorange-shade: var(--color-blazeorange-100);
|
|
332
332
|
}
|
|
333
|
-
|