@hanzo/design 0.4.10 → 0.4.12

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/dist/index.d.ts CHANGED
@@ -33,6 +33,6 @@ export declare function tokenValue(name: CssVarName): string | undefined;
33
33
  * bare. Pass a URL you serve.
34
34
  */
35
35
  export declare function injectDesignCss(href: string): void;
36
- export { vars, css, isColor, TYPE_MIN, TYPE_MAX } from './preference';
37
- export type { Preference, Density } from './preference';
36
+ export { vars, css, isColor, TYPE_MIN, TYPE_MAX } from './preference.js';
37
+ export type { Preference, Density } from './preference.js';
38
38
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,cAAc,iBAAiB,CAAA;AAC/B,OAAO,EAAW,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE1D,uFAAuF;AACvF,MAAM,MAAM,SAAS,GAAG,UAAU,SAAS,KAAK,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,CAAA;AAErE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAI9E;AAED,oFAAoF;AACpF,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAE/D;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAQlD;AAKD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACtE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,cAAc,iBAAiB,CAAA;AAC/B,OAAO,EAAW,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE1D,uFAAuF;AACvF,MAAM,MAAM,SAAS,GAAG,UAAU,SAAS,KAAK,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,CAAA;AAErE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAI9E;AAED,oFAAoF;AACpF,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAE/D;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAQlD;AAKD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACzE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -61,4 +61,4 @@ export function injectDesignCss(href) {
61
61
  // A person's own reading of the system — type size, density, accent — as CSS
62
62
  // custom properties. Pure: it maps a preference to variables and returns them,
63
63
  // so an app, an embedded preview and a server render all apply it the same way.
64
- export { vars, css, isColor, TYPE_MIN, TYPE_MAX } from './preference';
64
+ export { vars, css, isColor, TYPE_MIN, TYPE_MAX } from './preference.js';
@@ -1,23 +1,29 @@
1
1
  /**
2
2
  * A person's own reading of the system: type size, density, accent.
3
3
  *
4
- * The ramps in `tokens/*.css` are the SHAPEthe relationships between sizes,
5
- * gaps and hues that make a surface read as one thing. A preference does not
6
- * replace them and cannot reach inside them. It applies ONE transform to a whole
7
- * axis, so every size still stands in the same relation to every other size and
8
- * a customised UI is the same design at a different setting, not a different
9
- * design.
4
+ * Three knobs, and each is ONE multiplier on a whole axis never a restated
5
+ * ramp. The ramps live in `tokens/*.css`, authored once, and each rung carries
6
+ * its own `calc(<base> * var(--type-scale, 1))`. So a preference sets three
7
+ * numbers and every rung follows, including rungs added later and rungs this
8
+ * file has never heard of.
10
9
  *
11
- * It is a pure function on purpose. `vars()` maps a preference to the custom
12
- * properties that carry it, and returns them; nothing here touches a document.
13
- * That is what lets it be tested without a browser and reused by every surface —
14
- * an app, an embedded builder preview, a server render that inlines the result.
10
+ * That is not a style choice; it is the fix for a real bug. The first version of
11
+ * this module kept its own copy of the type ramp so it could recompute each
12
+ * rung, and the copy was WRONG it had `lg: 1rem` and `xl: 1.125rem` (16px and
13
+ * 18px) while `tokens/typography.css` says `0.9375rem` and `1.0625rem` (15px and
14
+ * 17px). Setting a preference of 1 — "leave it alone" — would have silently
15
+ * resized two rungs of the published design. A second copy of a value is a
16
+ * second source of truth, and it drifted before anyone used it.
15
17
  *
16
- * Three axes, because those are the three the token files already separate:
18
+ * Because the knobs are plain multipliers, any OTHER ramp can opt in the same
19
+ * way. @hanzo/gui compiles its own `--f-size-*` scale for the 1600-odd
20
+ * `fontSize="$n"` call sites in the apps; an app that redeclares those as
21
+ * `calc(<its px> * var(--type-scale, 1))` gets the same control with no change
22
+ * at scale 1.
17
23
  *
18
- * type scales the --text-* ramp
19
- * density scales the --grid-gap-* ramp (the spacing between things)
20
- * accent sets --primary / --accent (the one hue the monochrome brand allows)
24
+ * It is a pure function on purpose: it maps a preference to custom properties
25
+ * and returns them, touching no document. That is what lets an app, an embedded
26
+ * preview and a server render apply it identically.
21
27
  */
22
28
  export type Density = "compact" | "default" | "comfortable";
23
29
  export interface Preference {
@@ -1 +1 @@
1
- {"version":3,"file":"preference.d.ts","sourceRoot":"","sources":["../src/preference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,aAAa,CAAC;AAE5D,MAAM,WAAW,UAAU;IACzB,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CA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@
1
1
  /**
2
2
  * A person's own reading of the system: type size, density, accent.
3
3
  *
4
- * The ramps in `tokens/*.css` are the SHAPEthe relationships between sizes,
5
- * gaps and hues that make a surface read as one thing. A preference does not
6
- * replace them and cannot reach inside them. It applies ONE transform to a whole
7
- * axis, so every size still stands in the same relation to every other size and
8
- * a customised UI is the same design at a different setting, not a different
9
- * design.
4
+ * Three knobs, and each is ONE multiplier on a whole axis never a restated
5
+ * ramp. The ramps live in `tokens/*.css`, authored once, and each rung carries
6
+ * its own `calc(<base> * var(--type-scale, 1))`. So a preference sets three
7
+ * numbers and every rung follows, including rungs added later and rungs this
8
+ * file has never heard of.
10
9
  *
11
- * It is a pure function on purpose. `vars()` maps a preference to the custom
12
- * properties that carry it, and returns them; nothing here touches a document.
13
- * That is what lets it be tested without a browser and reused by every surface —
14
- * an app, an embedded builder preview, a server render that inlines the result.
10
+ * That is not a style choice; it is the fix for a real bug. The first version of
11
+ * this module kept its own copy of the type ramp so it could recompute each
12
+ * rung, and the copy was WRONG it had `lg: 1rem` and `xl: 1.125rem` (16px and
13
+ * 18px) while `tokens/typography.css` says `0.9375rem` and `1.0625rem` (15px and
14
+ * 17px). Setting a preference of 1 — "leave it alone" — would have silently
15
+ * resized two rungs of the published design. A second copy of a value is a
16
+ * second source of truth, and it drifted before anyone used it.
15
17
  *
16
- * Three axes, because those are the three the token files already separate:
18
+ * Because the knobs are plain multipliers, any OTHER ramp can opt in the same
19
+ * way. @hanzo/gui compiles its own `--f-size-*` scale for the 1600-odd
20
+ * `fontSize="$n"` call sites in the apps; an app that redeclares those as
21
+ * `calc(<its px> * var(--type-scale, 1))` gets the same control with no change
22
+ * at scale 1.
17
23
  *
18
- * type scales the --text-* ramp
19
- * density scales the --grid-gap-* ramp (the spacing between things)
20
- * accent sets --primary / --accent (the one hue the monochrome brand allows)
24
+ * It is a pure function on purpose: it maps a preference to custom properties
25
+ * and returns them, touching no document. That is what lets an app, an embedded
26
+ * preview and a server render apply it identically.
21
27
  */
22
28
  /**
23
29
  * The type multiplier is CLAMPED, and the bounds are not arbitrary.
@@ -30,26 +36,22 @@
30
36
  */
31
37
  export const TYPE_MIN = 0.85;
32
38
  export const TYPE_MAX = 1.4;
33
- const DENSITY_SCALE = {
34
- compact: 0.75,
39
+ /**
40
+ * Density moves SPACING only, and its range is much tighter than type's.
41
+ *
42
+ * Spacing compounds: a page nests padding inside gap inside margin, so a 0.75
43
+ * multiplier is already three-quarters of every one of those in sequence. Below
44
+ * that, touch targets fall under the 44px floor `base.css` sets for coarse
45
+ * pointers, and the control that promised comfort takes it away.
46
+ */
47
+ const DENSITY = {
48
+ compact: 0.85,
35
49
  default: 1,
36
- comfortable: 1.35,
37
- };
38
- /** The type ramp, by name, in rem at a 16px root — mirrors tokens/typography.css. */
39
- const TEXT = {
40
- xs: 0.6875, sm: 0.8125, base: 0.875, lg: 1, xl: 1.125,
41
- "2xl": 1.3125, "3xl": 1.625, "4xl": 2, "5xl": 2.5,
42
- "6xl": 3.25, "7xl": 4, "8xl": 5.25, "9xl": 7,
43
- };
44
- /** The gap ramp, in rem — mirrors tokens/grid.css. */
45
- const GAP = {
46
- "grid-gap-tight": 0.5,
47
- "grid-gap": 1,
48
- "grid-gap-loose": 1.5,
50
+ comfortable: 1.15,
49
51
  };
50
52
  const clamp = (n, lo, hi) => Math.min(hi, Math.max(lo, n));
51
53
  /** Trim to 4dp so a multiplier cannot emit a 17-digit float into a stylesheet. */
52
- const rem = (n) => `${Math.round(n * 10000) / 10000}rem`;
54
+ const round = (n) => String(Math.round(n * 10000) / 10000);
53
55
  /**
54
56
  * Is this a colour, or is it something being smuggled into a style attribute?
55
57
  *
@@ -77,14 +79,10 @@ export function isColor(v) {
77
79
  export function vars(p) {
78
80
  const out = {};
79
81
  if (typeof p.type === "number" && Number.isFinite(p.type)) {
80
- const k = clamp(p.type, TYPE_MIN, TYPE_MAX);
81
- for (const [name, size] of Object.entries(TEXT))
82
- out[`--text-${name}`] = rem(size * k);
82
+ out["--type-scale"] = round(clamp(p.type, TYPE_MIN, TYPE_MAX));
83
83
  }
84
- if (p.density && p.density in DENSITY_SCALE) {
85
- const k = DENSITY_SCALE[p.density];
86
- for (const [name, size] of Object.entries(GAP))
87
- out[`--${name}`] = rem(size * k);
84
+ if (p.density && p.density in DENSITY) {
85
+ out["--density"] = round(DENSITY[p.density]);
88
86
  }
89
87
  if (p.accent && isColor(p.accent)) {
90
88
  // Both names, because the ramp uses --primary for action surfaces and
@@ -91,31 +91,32 @@ export declare const colors: {
91
91
  };
92
92
  /** typography tokens (from tokens/typography.css). Values are raw CSS. */
93
93
  export declare const typography: {
94
- readonly 'text-xs': "0.6875rem";
95
- readonly 'leading-xs': "1rem";
96
- readonly 'text-sm': "0.8125rem";
97
- readonly 'leading-sm': "1.15rem";
98
- readonly 'text-base': "0.875rem";
99
- readonly 'leading-base': "1.35rem";
100
- readonly 'text-lg': "0.9375rem";
101
- readonly 'leading-lg': "1.4rem";
102
- readonly 'text-xl': "1.0625rem";
103
- readonly 'leading-xl': "1.55rem";
104
- readonly 'text-2xl': "1.3125rem";
105
- readonly 'leading-2xl': "1.7rem";
106
- readonly 'text-3xl': "1.625rem";
107
- readonly 'leading-3xl': "1.95rem";
108
- readonly 'text-4xl': "2rem";
109
- readonly 'leading-4xl': "2.25rem";
110
- readonly 'text-5xl': "2.5rem";
94
+ readonly 'type-scale': "1";
95
+ readonly 'text-xs': "calc(0.6875rem * var(--type-scale, 1))";
96
+ readonly 'leading-xs': "calc(1rem * var(--type-scale, 1))";
97
+ readonly 'text-sm': "calc(0.8125rem * var(--type-scale, 1))";
98
+ readonly 'leading-sm': "calc(1.15rem * var(--type-scale, 1))";
99
+ readonly 'text-base': "calc(0.875rem * var(--type-scale, 1))";
100
+ readonly 'leading-base': "calc(1.35rem * var(--type-scale, 1))";
101
+ readonly 'text-lg': "calc(0.9375rem * var(--type-scale, 1))";
102
+ readonly 'leading-lg': "calc(1.4rem * var(--type-scale, 1))";
103
+ readonly 'text-xl': "calc(1.0625rem * var(--type-scale, 1))";
104
+ readonly 'leading-xl': "calc(1.55rem * var(--type-scale, 1))";
105
+ readonly 'text-2xl': "calc(1.3125rem * var(--type-scale, 1))";
106
+ readonly 'leading-2xl': "calc(1.7rem * var(--type-scale, 1))";
107
+ readonly 'text-3xl': "calc(1.625rem * var(--type-scale, 1))";
108
+ readonly 'leading-3xl': "calc(1.95rem * var(--type-scale, 1))";
109
+ readonly 'text-4xl': "calc(2rem * var(--type-scale, 1))";
110
+ readonly 'leading-4xl': "calc(2.25rem * var(--type-scale, 1))";
111
+ readonly 'text-5xl': "calc(2.5rem * var(--type-scale, 1))";
111
112
  readonly 'leading-5xl': "1.05";
112
- readonly 'text-6xl': "3.25rem";
113
+ readonly 'text-6xl': "calc(3.25rem * var(--type-scale, 1))";
113
114
  readonly 'leading-6xl': "1";
114
- readonly 'text-7xl': "4rem";
115
+ readonly 'text-7xl': "calc(4rem * var(--type-scale, 1))";
115
116
  readonly 'leading-7xl': "1";
116
- readonly 'text-8xl': "5.25rem";
117
+ readonly 'text-8xl': "calc(5.25rem * var(--type-scale, 1))";
117
118
  readonly 'leading-8xl': "1";
118
- readonly 'text-9xl': "7rem";
119
+ readonly 'text-9xl': "calc(7rem * var(--type-scale, 1))";
119
120
  readonly 'leading-9xl': "1";
120
121
  readonly 'font-size-xs': "var(--text-xs)";
121
122
  readonly 'font-size-sm': "var(--text-sm)";
@@ -156,21 +157,22 @@ export declare const typography: {
156
157
  };
157
158
  /** spacing tokens (from tokens/spacing.css). Values are raw CSS. */
158
159
  export declare const spacing: {
160
+ readonly density: "1";
159
161
  readonly 'space-0': "0";
160
- readonly 'space-1': "0.25rem";
161
- readonly 'space-2': "0.5rem";
162
- readonly 'space-3': "0.75rem";
163
- readonly 'space-4': "1rem";
164
- readonly 'space-5': "1.25rem";
165
- readonly 'space-6': "1.5rem";
166
- readonly 'space-8': "2rem";
167
- readonly 'space-10': "2.5rem";
168
- readonly 'space-12': "3rem";
169
- readonly 'space-14': "3.5rem";
170
- readonly 'space-16': "4rem";
171
- readonly 'space-20': "5rem";
172
- readonly 'space-24': "6rem";
173
- readonly 'space-32': "8rem";
162
+ readonly 'space-1': "calc(0.25rem * var(--density, 1))";
163
+ readonly 'space-2': "calc(0.5rem * var(--density, 1))";
164
+ readonly 'space-3': "calc(0.75rem * var(--density, 1))";
165
+ readonly 'space-4': "calc(1rem * var(--density, 1))";
166
+ readonly 'space-5': "calc(1.25rem * var(--density, 1))";
167
+ readonly 'space-6': "calc(1.5rem * var(--density, 1))";
168
+ readonly 'space-8': "calc(2rem * var(--density, 1))";
169
+ readonly 'space-10': "calc(2.5rem * var(--density, 1))";
170
+ readonly 'space-12': "calc(3rem * var(--density, 1))";
171
+ readonly 'space-14': "calc(3.5rem * var(--density, 1))";
172
+ readonly 'space-16': "calc(4rem * var(--density, 1))";
173
+ readonly 'space-20': "calc(5rem * var(--density, 1))";
174
+ readonly 'space-24': "calc(6rem * var(--density, 1))";
175
+ readonly 'space-32': "calc(8rem * var(--density, 1))";
174
176
  readonly 'golden-1': "0.25rem";
175
177
  readonly 'golden-2': "0.405rem";
176
178
  readonly 'golden-3': "0.654rem";
@@ -374,31 +376,32 @@ export declare const cssVars: {
374
376
  readonly '--chrome-dot-red': "rgb(239 68 68 / .6)";
375
377
  readonly '--chrome-dot-yellow': "rgb(234 179 8 / .6)";
376
378
  readonly '--chrome-dot-green': "rgb(34 197 94 / .6)";
377
- readonly '--text-xs': "0.6875rem";
378
- readonly '--leading-xs': "1rem";
379
- readonly '--text-sm': "0.8125rem";
380
- readonly '--leading-sm': "1.15rem";
381
- readonly '--text-base': "0.875rem";
382
- readonly '--leading-base': "1.35rem";
383
- readonly '--text-lg': "0.9375rem";
384
- readonly '--leading-lg': "1.4rem";
385
- readonly '--text-xl': "1.0625rem";
386
- readonly '--leading-xl': "1.55rem";
387
- readonly '--text-2xl': "1.3125rem";
388
- readonly '--leading-2xl': "1.7rem";
389
- readonly '--text-3xl': "1.625rem";
390
- readonly '--leading-3xl': "1.95rem";
391
- readonly '--text-4xl': "2rem";
392
- readonly '--leading-4xl': "2.25rem";
393
- readonly '--text-5xl': "2.5rem";
379
+ readonly '--type-scale': "1";
380
+ readonly '--text-xs': "calc(0.6875rem * var(--type-scale, 1))";
381
+ readonly '--leading-xs': "calc(1rem * var(--type-scale, 1))";
382
+ readonly '--text-sm': "calc(0.8125rem * var(--type-scale, 1))";
383
+ readonly '--leading-sm': "calc(1.15rem * var(--type-scale, 1))";
384
+ readonly '--text-base': "calc(0.875rem * var(--type-scale, 1))";
385
+ readonly '--leading-base': "calc(1.35rem * var(--type-scale, 1))";
386
+ readonly '--text-lg': "calc(0.9375rem * var(--type-scale, 1))";
387
+ readonly '--leading-lg': "calc(1.4rem * var(--type-scale, 1))";
388
+ readonly '--text-xl': "calc(1.0625rem * var(--type-scale, 1))";
389
+ readonly '--leading-xl': "calc(1.55rem * var(--type-scale, 1))";
390
+ readonly '--text-2xl': "calc(1.3125rem * var(--type-scale, 1))";
391
+ readonly '--leading-2xl': "calc(1.7rem * var(--type-scale, 1))";
392
+ readonly '--text-3xl': "calc(1.625rem * var(--type-scale, 1))";
393
+ readonly '--leading-3xl': "calc(1.95rem * var(--type-scale, 1))";
394
+ readonly '--text-4xl': "calc(2rem * var(--type-scale, 1))";
395
+ readonly '--leading-4xl': "calc(2.25rem * var(--type-scale, 1))";
396
+ readonly '--text-5xl': "calc(2.5rem * var(--type-scale, 1))";
394
397
  readonly '--leading-5xl': "1.05";
395
- readonly '--text-6xl': "3.25rem";
398
+ readonly '--text-6xl': "calc(3.25rem * var(--type-scale, 1))";
396
399
  readonly '--leading-6xl': "1";
397
- readonly '--text-7xl': "4rem";
400
+ readonly '--text-7xl': "calc(4rem * var(--type-scale, 1))";
398
401
  readonly '--leading-7xl': "1";
399
- readonly '--text-8xl': "5.25rem";
402
+ readonly '--text-8xl': "calc(5.25rem * var(--type-scale, 1))";
400
403
  readonly '--leading-8xl': "1";
401
- readonly '--text-9xl': "7rem";
404
+ readonly '--text-9xl': "calc(7rem * var(--type-scale, 1))";
402
405
  readonly '--leading-9xl': "1";
403
406
  readonly '--font-size-xs': "var(--text-xs)";
404
407
  readonly '--font-size-sm': "var(--text-sm)";
@@ -436,21 +439,22 @@ export declare const cssVars: {
436
439
  readonly '--type-caption': "400 var(--text-xs)/var(--leading-xs) var(--font-sans)";
437
440
  readonly '--type-code': "400 var(--text-sm)/var(--leading-relaxed) var(--font-mono)";
438
441
  readonly '--type-eyebrow': "600 0.625rem/1 var(--font-sans)";
442
+ readonly '--density': "1";
439
443
  readonly '--space-0': "0";
440
- readonly '--space-1': "0.25rem";
441
- readonly '--space-2': "0.5rem";
442
- readonly '--space-3': "0.75rem";
443
- readonly '--space-4': "1rem";
444
- readonly '--space-5': "1.25rem";
445
- readonly '--space-6': "1.5rem";
446
- readonly '--space-8': "2rem";
447
- readonly '--space-10': "2.5rem";
448
- readonly '--space-12': "3rem";
449
- readonly '--space-14': "3.5rem";
450
- readonly '--space-16': "4rem";
451
- readonly '--space-20': "5rem";
452
- readonly '--space-24': "6rem";
453
- readonly '--space-32': "8rem";
444
+ readonly '--space-1': "calc(0.25rem * var(--density, 1))";
445
+ readonly '--space-2': "calc(0.5rem * var(--density, 1))";
446
+ readonly '--space-3': "calc(0.75rem * var(--density, 1))";
447
+ readonly '--space-4': "calc(1rem * var(--density, 1))";
448
+ readonly '--space-5': "calc(1.25rem * var(--density, 1))";
449
+ readonly '--space-6': "calc(1.5rem * var(--density, 1))";
450
+ readonly '--space-8': "calc(2rem * var(--density, 1))";
451
+ readonly '--space-10': "calc(2.5rem * var(--density, 1))";
452
+ readonly '--space-12': "calc(3rem * var(--density, 1))";
453
+ readonly '--space-14': "calc(3.5rem * var(--density, 1))";
454
+ readonly '--space-16': "calc(4rem * var(--density, 1))";
455
+ readonly '--space-20': "calc(5rem * var(--density, 1))";
456
+ readonly '--space-24': "calc(6rem * var(--density, 1))";
457
+ readonly '--space-32': "calc(8rem * var(--density, 1))";
454
458
  readonly '--golden-1': "0.25rem";
455
459
  readonly '--golden-2': "0.405rem";
456
460
  readonly '--golden-3': "0.654rem";
@@ -1 +1 @@
1
- {"version":3,"file":"tokens.gen.d.ts","sourceRoot":"","sources":["../src/tokens.gen.ts"],"names":[],"mappings":"AAIA,kEAAkE;AAClE,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyFT,CAAA;AAEV,0EAA0E;AAC1E,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Db,CAAA;AAEV,oEAAoE;AACpE,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CV,CAAA;AAEV,8DAA8D;AAC9D,eAAO,MAAM,IAAI;;;;;;;;;;;;CAYP,CAAA;AAEV,kEAAkE;AAClE,eAAO,MAAM,MAAM;;;;;;;;;CAST,CAAA;AAEV,wEAAwE;AACxE,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;CAoBZ,CAAA;AAEV,kEAAkE;AAClE,eAAO,MAAM,MAAM;;;;;;;;;;;;;CAaT,CAAA;AAEV,6DAA6D;AAC7D,eAAO,MAAM,MAAM;;;;;;;;;;;;CAYT,CAAA;AAEV,gEAAgE;AAChE,eAAO,MAAM,KAAK;;;;;;CAMR,CAAA;AAEV,8DAA8D;AAC9D,eAAO,MAAM,IAAI,IAEP,CAAA;AAEV,sFAAsF;AACtF,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoQV,CAAA;AAEV,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,OAAO,CAAA"}
@@ -94,31 +94,32 @@ export const colors = {
94
94
  };
95
95
  /** typography tokens (from tokens/typography.css). Values are raw CSS. */
96
96
  export const typography = {
97
- 'text-xs': '0.6875rem',
98
- 'leading-xs': '1rem',
99
- 'text-sm': '0.8125rem',
100
- 'leading-sm': '1.15rem',
101
- 'text-base': '0.875rem',
102
- 'leading-base': '1.35rem',
103
- 'text-lg': '0.9375rem',
104
- 'leading-lg': '1.4rem',
105
- 'text-xl': '1.0625rem',
106
- 'leading-xl': '1.55rem',
107
- 'text-2xl': '1.3125rem',
108
- 'leading-2xl': '1.7rem',
109
- 'text-3xl': '1.625rem',
110
- 'leading-3xl': '1.95rem',
111
- 'text-4xl': '2rem',
112
- 'leading-4xl': '2.25rem',
113
- 'text-5xl': '2.5rem',
97
+ 'type-scale': '1',
98
+ 'text-xs': 'calc(0.6875rem * var(--type-scale, 1))',
99
+ 'leading-xs': 'calc(1rem * var(--type-scale, 1))',
100
+ 'text-sm': 'calc(0.8125rem * var(--type-scale, 1))',
101
+ 'leading-sm': 'calc(1.15rem * var(--type-scale, 1))',
102
+ 'text-base': 'calc(0.875rem * var(--type-scale, 1))',
103
+ 'leading-base': 'calc(1.35rem * var(--type-scale, 1))',
104
+ 'text-lg': 'calc(0.9375rem * var(--type-scale, 1))',
105
+ 'leading-lg': 'calc(1.4rem * var(--type-scale, 1))',
106
+ 'text-xl': 'calc(1.0625rem * var(--type-scale, 1))',
107
+ 'leading-xl': 'calc(1.55rem * var(--type-scale, 1))',
108
+ 'text-2xl': 'calc(1.3125rem * var(--type-scale, 1))',
109
+ 'leading-2xl': 'calc(1.7rem * var(--type-scale, 1))',
110
+ 'text-3xl': 'calc(1.625rem * var(--type-scale, 1))',
111
+ 'leading-3xl': 'calc(1.95rem * var(--type-scale, 1))',
112
+ 'text-4xl': 'calc(2rem * var(--type-scale, 1))',
113
+ 'leading-4xl': 'calc(2.25rem * var(--type-scale, 1))',
114
+ 'text-5xl': 'calc(2.5rem * var(--type-scale, 1))',
114
115
  'leading-5xl': '1.05',
115
- 'text-6xl': '3.25rem',
116
+ 'text-6xl': 'calc(3.25rem * var(--type-scale, 1))',
116
117
  'leading-6xl': '1',
117
- 'text-7xl': '4rem',
118
+ 'text-7xl': 'calc(4rem * var(--type-scale, 1))',
118
119
  'leading-7xl': '1',
119
- 'text-8xl': '5.25rem',
120
+ 'text-8xl': 'calc(5.25rem * var(--type-scale, 1))',
120
121
  'leading-8xl': '1',
121
- 'text-9xl': '7rem',
122
+ 'text-9xl': 'calc(7rem * var(--type-scale, 1))',
122
123
  'leading-9xl': '1',
123
124
  'font-size-xs': 'var(--text-xs)',
124
125
  'font-size-sm': 'var(--text-sm)',
@@ -159,21 +160,22 @@ export const typography = {
159
160
  };
160
161
  /** spacing tokens (from tokens/spacing.css). Values are raw CSS. */
161
162
  export const spacing = {
163
+ 'density': '1',
162
164
  'space-0': '0',
163
- 'space-1': '0.25rem',
164
- 'space-2': '0.5rem',
165
- 'space-3': '0.75rem',
166
- 'space-4': '1rem',
167
- 'space-5': '1.25rem',
168
- 'space-6': '1.5rem',
169
- 'space-8': '2rem',
170
- 'space-10': '2.5rem',
171
- 'space-12': '3rem',
172
- 'space-14': '3.5rem',
173
- 'space-16': '4rem',
174
- 'space-20': '5rem',
175
- 'space-24': '6rem',
176
- 'space-32': '8rem',
165
+ 'space-1': 'calc(0.25rem * var(--density, 1))',
166
+ 'space-2': 'calc(0.5rem * var(--density, 1))',
167
+ 'space-3': 'calc(0.75rem * var(--density, 1))',
168
+ 'space-4': 'calc(1rem * var(--density, 1))',
169
+ 'space-5': 'calc(1.25rem * var(--density, 1))',
170
+ 'space-6': 'calc(1.5rem * var(--density, 1))',
171
+ 'space-8': 'calc(2rem * var(--density, 1))',
172
+ 'space-10': 'calc(2.5rem * var(--density, 1))',
173
+ 'space-12': 'calc(3rem * var(--density, 1))',
174
+ 'space-14': 'calc(3.5rem * var(--density, 1))',
175
+ 'space-16': 'calc(4rem * var(--density, 1))',
176
+ 'space-20': 'calc(5rem * var(--density, 1))',
177
+ 'space-24': 'calc(6rem * var(--density, 1))',
178
+ 'space-32': 'calc(8rem * var(--density, 1))',
177
179
  'golden-1': '0.25rem',
178
180
  'golden-2': '0.405rem',
179
181
  'golden-3': '0.654rem',
@@ -377,31 +379,32 @@ export const cssVars = {
377
379
  '--chrome-dot-red': 'rgb(239 68 68 / .6)',
378
380
  '--chrome-dot-yellow': 'rgb(234 179 8 / .6)',
379
381
  '--chrome-dot-green': 'rgb(34 197 94 / .6)',
380
- '--text-xs': '0.6875rem',
381
- '--leading-xs': '1rem',
382
- '--text-sm': '0.8125rem',
383
- '--leading-sm': '1.15rem',
384
- '--text-base': '0.875rem',
385
- '--leading-base': '1.35rem',
386
- '--text-lg': '0.9375rem',
387
- '--leading-lg': '1.4rem',
388
- '--text-xl': '1.0625rem',
389
- '--leading-xl': '1.55rem',
390
- '--text-2xl': '1.3125rem',
391
- '--leading-2xl': '1.7rem',
392
- '--text-3xl': '1.625rem',
393
- '--leading-3xl': '1.95rem',
394
- '--text-4xl': '2rem',
395
- '--leading-4xl': '2.25rem',
396
- '--text-5xl': '2.5rem',
382
+ '--type-scale': '1',
383
+ '--text-xs': 'calc(0.6875rem * var(--type-scale, 1))',
384
+ '--leading-xs': 'calc(1rem * var(--type-scale, 1))',
385
+ '--text-sm': 'calc(0.8125rem * var(--type-scale, 1))',
386
+ '--leading-sm': 'calc(1.15rem * var(--type-scale, 1))',
387
+ '--text-base': 'calc(0.875rem * var(--type-scale, 1))',
388
+ '--leading-base': 'calc(1.35rem * var(--type-scale, 1))',
389
+ '--text-lg': 'calc(0.9375rem * var(--type-scale, 1))',
390
+ '--leading-lg': 'calc(1.4rem * var(--type-scale, 1))',
391
+ '--text-xl': 'calc(1.0625rem * var(--type-scale, 1))',
392
+ '--leading-xl': 'calc(1.55rem * var(--type-scale, 1))',
393
+ '--text-2xl': 'calc(1.3125rem * var(--type-scale, 1))',
394
+ '--leading-2xl': 'calc(1.7rem * var(--type-scale, 1))',
395
+ '--text-3xl': 'calc(1.625rem * var(--type-scale, 1))',
396
+ '--leading-3xl': 'calc(1.95rem * var(--type-scale, 1))',
397
+ '--text-4xl': 'calc(2rem * var(--type-scale, 1))',
398
+ '--leading-4xl': 'calc(2.25rem * var(--type-scale, 1))',
399
+ '--text-5xl': 'calc(2.5rem * var(--type-scale, 1))',
397
400
  '--leading-5xl': '1.05',
398
- '--text-6xl': '3.25rem',
401
+ '--text-6xl': 'calc(3.25rem * var(--type-scale, 1))',
399
402
  '--leading-6xl': '1',
400
- '--text-7xl': '4rem',
403
+ '--text-7xl': 'calc(4rem * var(--type-scale, 1))',
401
404
  '--leading-7xl': '1',
402
- '--text-8xl': '5.25rem',
405
+ '--text-8xl': 'calc(5.25rem * var(--type-scale, 1))',
403
406
  '--leading-8xl': '1',
404
- '--text-9xl': '7rem',
407
+ '--text-9xl': 'calc(7rem * var(--type-scale, 1))',
405
408
  '--leading-9xl': '1',
406
409
  '--font-size-xs': 'var(--text-xs)',
407
410
  '--font-size-sm': 'var(--text-sm)',
@@ -439,21 +442,22 @@ export const cssVars = {
439
442
  '--type-caption': '400 var(--text-xs)/var(--leading-xs) var(--font-sans)',
440
443
  '--type-code': '400 var(--text-sm)/var(--leading-relaxed) var(--font-mono)',
441
444
  '--type-eyebrow': '600 0.625rem/1 var(--font-sans)',
445
+ '--density': '1',
442
446
  '--space-0': '0',
443
- '--space-1': '0.25rem',
444
- '--space-2': '0.5rem',
445
- '--space-3': '0.75rem',
446
- '--space-4': '1rem',
447
- '--space-5': '1.25rem',
448
- '--space-6': '1.5rem',
449
- '--space-8': '2rem',
450
- '--space-10': '2.5rem',
451
- '--space-12': '3rem',
452
- '--space-14': '3.5rem',
453
- '--space-16': '4rem',
454
- '--space-20': '5rem',
455
- '--space-24': '6rem',
456
- '--space-32': '8rem',
447
+ '--space-1': 'calc(0.25rem * var(--density, 1))',
448
+ '--space-2': 'calc(0.5rem * var(--density, 1))',
449
+ '--space-3': 'calc(0.75rem * var(--density, 1))',
450
+ '--space-4': 'calc(1rem * var(--density, 1))',
451
+ '--space-5': 'calc(1.25rem * var(--density, 1))',
452
+ '--space-6': 'calc(1.5rem * var(--density, 1))',
453
+ '--space-8': 'calc(2rem * var(--density, 1))',
454
+ '--space-10': 'calc(2.5rem * var(--density, 1))',
455
+ '--space-12': 'calc(3rem * var(--density, 1))',
456
+ '--space-14': 'calc(3.5rem * var(--density, 1))',
457
+ '--space-16': 'calc(4rem * var(--density, 1))',
458
+ '--space-20': 'calc(5rem * var(--density, 1))',
459
+ '--space-24': 'calc(6rem * var(--density, 1))',
460
+ '--space-32': 'calc(8rem * var(--density, 1))',
457
461
  '--golden-1': '0.25rem',
458
462
  '--golden-2': '0.405rem',
459
463
  '--golden-3': '0.654rem',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/design",
3
- "version": "0.4.10",
3
+ "version": "0.4.12",
4
4
  "packageManager": "pnpm@11.17.0",
5
5
  "description": "Hanzo Design System \u2014 monochrome, dark-default tokens + components + brand assets, the single source of truth for every Hanzo surface. CSS + typed programmatic tokens.",
6
6
  "license": "MIT OR Apache-2.0",
@@ -33,7 +33,7 @@
33
33
  "scripts": {
34
34
  "gen": "node scripts/gen-tokens.mjs",
35
35
  "test": "node scripts/check-tokens.mjs && node scripts/check-preference.mjs && node scripts/lint.mjs .",
36
- "build": "pnpm gen && pnpm test && tsc -p tsconfig.json",
36
+ "build": "pnpm gen && pnpm test && tsc -p tsconfig.json && node scripts/check-dist.mjs",
37
37
  "prepublishOnly": "pnpm build",
38
38
  "lint": "node scripts/lint.mjs"
39
39
  },