@eluan/tokens 0.2.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 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-curves]` attributes.
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
 
@@ -27,6 +27,27 @@ Then activate a theme by setting attributes on `<html>` (or use `<EluanProvider>
27
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
@@ -37,6 +58,24 @@ 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).
@@ -1,7 +1,16 @@
1
1
  /*
2
2
  Eluan Design System — Base fonts (shared across all themes)
3
- Geist Mono is used by every theme for monospace.
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
- @import "@fontsource/geist-mono/400.css";
7
- @import "@fontsource/geist-mono/500.css";
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,12 +1,16 @@
1
1
  /*
2
- Eluan Design System — Google Fonts via @fontsource
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).
4
+
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.
5
10
  */
6
11
 
7
- /* Geist Mono — all themes mono */
8
- @import "@fontsource/geist-mono/400.css";
9
- @import "@fontsource/geist-mono/500.css";
12
+ /* Paper Mono — all themes mono */
13
+ @import "./fonts-base.css";
10
14
 
11
15
  /* Inter — minimal heading + body */
12
16
  @import "@fontsource/inter/400.css";
package/dist/index.d.ts CHANGED
@@ -315,6 +315,22 @@ export declare const sizing: {
315
315
  readonly xxl: "5rem";
316
316
  readonly xxxl: "10rem";
317
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
+ };
318
334
  export declare const spacing: {
319
335
  readonly 0: "0rem";
320
336
  readonly 2: "0.125rem";
@@ -352,6 +368,125 @@ export declare const viewports: {
352
368
  readonly "3xl": "120rem";
353
369
  readonly "4xl": "161.25rem";
354
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
+ */
355
490
  export declare const fontSizes: {
356
491
  readonly xs: 12;
357
492
  readonly sm: 14;
@@ -467,8 +602,10 @@ export declare const breakpoints: {
467
602
  export type PrimitiveColor = typeof primitiveColors;
468
603
  export type RadiusToken = keyof typeof radius;
469
604
  export type SizingToken = keyof typeof sizing;
605
+ export type SizingStepToken = keyof typeof sizingSteps;
470
606
  export type SpacingToken = keyof typeof spacing;
471
607
  export type ViewportToken = keyof typeof viewports;
608
+ /** @deprecated Use `TypesetStep` — see the `fontSizes` deprecation note. */
472
609
  export type FontSizeToken = keyof typeof fontSizes;
473
610
  export type FontWeightToken = keyof typeof fontWeights;
474
611
  export type ShadowToken = keyof typeof shadows;
package/dist/index.js CHANGED
@@ -376,6 +376,26 @@ export const sizing = {
376
376
  xxl: "5rem",
377
377
  xxxl: "10rem",
378
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
+ };
379
399
  // ============================================
380
400
  // Spacing Tokens (Layer 1)
381
401
  // ============================================
@@ -420,8 +440,121 @@ export const viewports = {
420
440
  "4xl": "161.25rem",
421
441
  };
422
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
+ // ============================================
423
550
  // Typography Tokens
424
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
+ */
425
558
  export const fontSizes = {
426
559
  xs: 12,
427
560
  sm: 14,
package/dist/modes.css CHANGED
@@ -8,18 +8,9 @@
8
8
  * Light Mode (Default)
9
9
  * ---------------------------------------- */
10
10
 
11
-
11
+
12
12
  [data-mode="Light"],
13
13
  [data-mode="light"] {
14
- /* Skeuomorphic light ingredients — light falls from the top-left along a
15
- 127deg diagonal. Shadows carry the active theme's neutral-950 tone; the
16
- surface gradients are translucent overlays that model convex (raised)
17
- and concave (pressed) faces over any base color. */
18
- --skeuo-highlight: rgba(255, 255, 255, 0.4);
19
- --skeuo-shade: color-mix(in srgb, var(--color-neutral-950) 10%, transparent);
20
- --skeuo-shadow: color-mix(in srgb, var(--color-neutral-950) 7%, transparent);
21
- --skeuo-surface-raised: linear-gradient(127deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0.04) 45%, color-mix(in srgb, var(--color-neutral-950) 5%, transparent) 100%);
22
- --skeuo-surface-pressed: linear-gradient(127deg, color-mix(in srgb, var(--color-neutral-950) 5%, transparent) 0%, rgba(255, 255, 255, 0.01) 60%, rgba(255, 255, 255, 0.06) 100%);
23
14
  --backgrounds-primary: var(--color-neutral-0);
24
15
  --backgrounds-secondary: var(--color-neutral-100);
25
16
  --backgrounds-tertiary: var(--color-neutral-200);
@@ -126,13 +117,7 @@
126
117
  --blazeorange-shade: var(--color-blazeorange-800);
127
118
  }
128
119
 
129
- [data-mode="dim"] {
130
- /* Skeuomorphic light ingredients (shadows carry the teak-950 tone) */
131
- --skeuo-highlight: rgba(255, 255, 255, 0.35);
132
- --skeuo-shade: rgba(51, 35, 25, 0.12);
133
- --skeuo-shadow: rgba(51, 35, 25, 0.09);
134
- --skeuo-surface-raised: linear-gradient(127deg, rgba(255, 255, 255, 0.14) 0%, rgba(255, 255, 255, 0.03) 45%, rgba(51, 35, 25, 0.05) 100%);
135
- --skeuo-surface-pressed: linear-gradient(127deg, rgba(51, 35, 25, 0.05) 0%, rgba(255, 255, 255, 0.01) 60%, rgba(255, 255, 255, 0.05) 100%);
120
+ [data-mode="Dim"], [data-mode="dim"] {
136
121
  --backgrounds-primary: var(--color-teak-100);
137
122
  --backgrounds-secondary: var(--color-teak-200);
138
123
  --backgrounds-tertiary: var(--color-teak-300);
@@ -239,13 +224,7 @@
239
224
  --blazeorange-shade: var(--color-blazeorange-900);
240
225
  }
241
226
 
242
- [data-mode="dark"] {
243
- /* Skeuomorphic light ingredients — highlights dim, shadows deepen in dark */
244
- --skeuo-highlight: rgba(255, 255, 255, 0.07);
245
- --skeuo-shade: rgba(0, 0, 0, 0.4);
246
- --skeuo-shadow: rgba(0, 0, 0, 0.28);
247
- --skeuo-surface-raised: linear-gradient(127deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.015) 45%, rgba(0, 0, 0, 0.15) 100%);
248
- --skeuo-surface-pressed: linear-gradient(127deg, rgba(0, 0, 0, 0.18) 0%, rgba(0, 0, 0, 0.03) 60%, rgba(255, 255, 255, 0.03) 100%);
227
+ [data-mode="Dark"], [data-mode="dark"] {
249
228
  --backgrounds-primary: var(--color-neutral-800);
250
229
  --backgrounds-secondary: var(--color-neutral-900);
251
230
  --backgrounds-tertiary: var(--color-neutral-950);
@@ -351,4 +330,3 @@
351
330
  --blazeorange-foreground: var(--color-blazeorange-50);
352
331
  --blazeorange-shade: var(--color-blazeorange-100);
353
332
  }
354
-