@behivetech/tokens 0.0.0-stage → 1.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 BEhive Tech
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,101 @@
1
- # Temporary Holding Version
1
+ # @behivetech/tokens
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The Material Design 3 token sheet every `@behivetech` component reads — `--md-sys-color-*`, typescale and shape custom properties for the light and dark schemes — plus the breakpoint mixins, generated from one source color.
4
+
5
+ Renamed: up to 1.0.0 this package was published as `@behivetech/cms.base-styles`. It is the same package under a new name, and the old name is deprecated: install `@behivetech/tokens` and change `@behivetech/cms.base-styles/` to `@behivetech/tokens/` in your `@use` and `import` lines.
6
+
7
+ ## Usage
8
+
9
+ Import the sheet once, before any component stylesheet, so the custom properties exist on `:root`:
10
+
11
+ ```scss
12
+ @use "@behivetech/tokens/tokens.scss";
13
+ @use "@behivetech/tokens/breakpoints.scss" as bp;
14
+
15
+ .Hero {
16
+ color: var(--md-sys-color-on-surface);
17
+ border-radius: var(--md-sys-shape-corner-medium);
18
+
19
+ @include bp.md {
20
+ font-size: var(--md-sys-typescale-headline-large-size);
21
+ }
22
+ }
23
+ ```
24
+
25
+ Override a token after the import to theme a site; components pick up whichever value the page sets. The JavaScript entry exports `breakpoints` and `minWidth()` for the same breakpoints in code.
26
+
27
+ To recolor the toast stripes, override `--color-success-inverse`, `--color-warning-inverse` and `--color-error-inverse` (in a plain `:root`, after the import). The `--stripe-*` properties behind them hold the per-mode defaults and are internal: overriding one changes Light only.
28
+
29
+ ## Contrast math: `@behivetech/tokens/wcag`
30
+
31
+ The WCAG 2 formulas the token generator checks its own color pairs with, as an entry of their own (an ES module, with types), so a tool that checks colors measures them the same way; the blocks builder (`@behivetech/blocks.builder`) does.
32
+
33
+ ```js
34
+ import { MIN_TEXT_CONTRAST, contrast } from "@behivetech/tokens/wcag";
35
+
36
+ // white text on the light scheme's primary: 6.5:1, so it passes
37
+ contrast("#ffffff", "#64558f") >= MIN_TEXT_CONTRAST;
38
+ ```
39
+
40
+ `contrast(a, b)` is the contrast ratio of two `#rrggbb` colors (1 to 21), `luminance(hex)` the relative luminance of one (0 to 1), and `MIN_TEXT_CONTRAST` is 4.5, WCAG AA for body text. A color is `#` and six hex digits; anything else (`#rgb`, a color with alpha, a name) throws a `TypeError` instead of being measured as a color it is not.
41
+
42
+ ## Tokens as values, for blocks
43
+
44
+ The same generator run that writes `tokens.scss` writes the tokens as typed JavaScript, so a block can refer to `tokens.color.primary` instead of a string and a misspelled or mistyped token is a compile error. Nothing here is edited by hand; `pnpm --filter @behivetech/tokens tokens` regenerates all of it from `scripts/tokenModel.mjs`, which reads the same tables and color schemes the sheet is written from, and `tokens.scss` and `breakpoints.scss` come out byte for byte as before.
45
+
46
+ The generator writes each module into the package that uses it (contract 6.1, 11.3 and D24), under `packages/`:
47
+
48
+ - `blocks/core/src/tokens.ts`: `tokens`, a reference (`{ name }`, typed by kind) for every token, plus `Token`, `TokenKind` and `createToken` from the hand-written `token-types.ts` beside it. `--md-sys-color-on-primary` is `tokens.color.onPrimary`, `--spacing-4` is `tokens.spacing[4]`. No values. Published as `@behivetech/blocks.core/tokens`.
49
+ - `blocks/builder/src/web-tokens.ts`: each token's light value as CSS, `var()` chains resolved, the fallback in `var(--md-sys-color-primary, #64558f)`. Used by `@behivetech/blocks.builder`, which writes it into each block's CSS.
50
+ - `blocks/builder/src/native-tokens.ts`: `{ light, dark }` keyed by custom property name with the resolved value: colors as hex, lengths in dp (`rem` is 16), fonts as the first family, weights as strings, tracking as an em number, durations in milliseconds, shadows (`tokens.elevation.level0` to `level5`, kind `shadow`) as the CSS box-shadow string, the same in both schemes. Used by `@behivetech/blocks.builder`, which writes the values into each block's native StyleSheet.
51
+ - `tokens/src/breakpoints.ts`: `breakpoints` in px, generated from the same table as `breakpoints.scss`; the main entry re-exports it.
52
+
53
+ These are internal source of `@behivetech/tokens`: it publishes only the sheets, the `breakpoints` entry and `wcag`.
54
+
55
+ The legacy `--color-*`, `--text-*` and `--radius-*` aliases are not exposed. The files are written only for the package's own sheet; an app's `BRAND_OUT` sheet writes none.
56
+
57
+ ## The theme builder on the docs site
58
+
59
+ The docs site's `/theme` page runs the same Material Design 3 generator in the browser: pick seeds, adjust roles, download a colors-only `theme.css` in the shape this package's `BRAND_COLORS_ONLY` output has. It covers the standard MD3 options; the command below is for the extras (neon tone map, accents, fonts).
60
+
61
+ ## Generating an app's own sheet
62
+
63
+ `tokens.scss` is generated from one source color (`#2C1760` by default) and is the sheet every consumer shares. An app with its own brand generates a colors-only sheet of its own beside it and imports that after `tokens.scss`, so the structure (type scale, shape, motion) keeps coming from this package:
64
+
65
+ ```bash
66
+ BRAND_SOURCE=#54B956 BRAND_COLORS_ONLY=1 BRAND_OUT=apps/camp/src/app/brand.scss \
67
+ pnpm --filter @behivetech/tokens tokens
68
+ ```
69
+
70
+ `BRAND_OUT` is resolved against the directory the command is started in, so run it from the repo root. A run with none of the options below produces the default `tokens.scss` unchanged.
71
+
72
+ | Option | Default | What it does |
73
+ | --------------------------------------------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
74
+ | `BRAND_SOURCE` | `#2C1760` | The primary seed. |
75
+ | `BRAND_SCHEME` | `tonalspot` | The MD3 scheme variant (`content`, `expressive`, `fidelity`, `tonalspot`, `vibrant`). |
76
+ | `BRAND_TERTIARY` | derived | A pinned tertiary seed. |
77
+ | `BRAND_NEUTRAL_CHROMA` | `0` | Chroma of the neutral palettes (true grays). |
78
+ | `BRAND_COLORS_ONLY`, `BRAND_OUT` | off, `tokens.scss` | Write only the color sheet, to a path of your choosing. Always writes a `// ---- Brand` `:root` block with `--color-error-inverse: var(--md-sys-color-error-container)`, even with no other option, so the app's error toast stripe keeps its own `error-container`. |
79
+ | `BRAND_ID` | unset | Scopes a colors-only sheet to `[data-brand="<id>"]` instead of `:root`, so several brands share one deployment and changing `data-brand` on the root element switches the theme with no rebuild. Dark selectors become `[data-brand="<id>"]:not([data-theme="light"])` and `[data-brand="<id>"][data-theme="dark"]`. Load the sheet after `tokens.scss`. The sheet declares the `--color-*` aliases that read a color role on the brand's own element too, so `data-brand` can sit on the root or on any element below it and components inside read that brand's colors. Needs `BRAND_COLORS_ONLY=1`; without it the generator throws. |
80
+ | `BRAND_TONE_MAP` | unset | `neon` builds primary, secondary, tertiary and error as full-chroma palettes from their seeds and puts the roles around the seed. Needs `BRAND_SECONDARY`, `BRAND_TERTIARY` and `BRAND_ERROR`. |
81
+ | `BRAND_SECONDARY`, `BRAND_ERROR` | unset | The secondary and error seeds for `neon`. |
82
+ | `BRAND_NEUTRAL` | unset | `hue:chroma`, for example `305:18` (neutral-variant chroma is the chroma plus 8). **Not a generic tint switch:** it also applies the-behive's full neutral tone ladder to both schemes, the tones of its Figma file. Light: `background`, `surface`, `surface-bright` n99; `surface-dim` n88; `surface-container-low` n97, `-container` n95, `-high` n93; `surface-variant` nv92; `inverse-surface` n10. Dark: `background`, `surface`, `surface-dim` n1; `surface-container-lowest` n0, `-low` n3, `-container` n5, `-high` n7, `-highest` n9; `surface-bright` n14; `surface-variant` nv9; `on-background`, `on-surface` n95; `on-surface-variant` nv82; `outline` nv62; `outline-variant` nv28; `inverse-surface` n95; `inverse-on-surface` n10 (n is the neutral palette, nv neutral-variant; roles not listed keep MD3's tone). Set it only for an app that has that file. Takes precedence over `BRAND_NEUTRAL_CHROMA`. |
83
+ | `BRAND_ACCENTS` | unset | `name:#hex` pairs, comma separated. Each becomes `--brand-<name>`, `--brand-on-<name>`, `--brand-<name>-container`, `--brand-on-<name>-container`, `--brand-<name>-vivid` (the seed) and `--brand-on-<name>-vivid` (`#000000`), plus a `--brand-rainbow` gradient through the `-vivid` colors in order. `orange` also gets `--brand-orange-inverse`. With `green` and `orange` present, `--color-success*` and `--color-warning*` (including the `-inverse` toast stripes) alias them; the error stripe, `--color-error-inverse`, always aliases `--md-sys-color-error-container`. Needs `BRAND_COLORS_ONLY=1`; without it the generator throws rather than drop them. |
84
+ | `BRAND_HEADING_FONT`, `BRAND_BODY_FONT` | Inter | Face names read from `--font-<name-in-kebab>`, the variable `next/font/google` exposes. Heading is the display and headline roles; body is title, body and label. |
85
+ | `BRAND_HEADING_WEIGHT`, `BRAND_MEDIUM_WEIGHT` | `400`, `500` | Weight of the display and headline roles, and of every role MD3 sets at 500 (title-medium, title-small, label). 100 to 900 in steps of 100; anything else throws. |
86
+
87
+ The neon tone map: in dark a role is the seed, its on-color `#000000` when black reaches 4.5:1 on it (else white), its container tone 30, and the container's on-color the seed when that reaches 4.5:1 on the container (else white). In light a role is the seed's palette at tone `min(seed tone, 40)`, its on-color white, its container the seed, and the container's on-color black under the same rule. [`scripts/options.md`](https://github.com/behivetech/bht-galaxy/blob/main/packages/tokens/scripts/options.md) has the full list.
88
+
89
+ the-behive (`apps/the-behive/src/app/brand.scss`), from the repo root:
90
+
91
+ ```bash
92
+ BRAND_SOURCE=#BC13FE BRAND_TONE_MAP=neon BRAND_SECONDARY=#00F0FF \
93
+ BRAND_TERTIARY=#FF00CC BRAND_ERROR=#FF355E BRAND_NEUTRAL=305:18 \
94
+ BRAND_ACCENTS=red:#FF355E,orange:#FF5F1F,yellow:#FFFF33,green:#39FF14,teal:#00F0FF,blue:#2C75FF,violet:#BC13FE,pink:#FF00CC \
95
+ BRAND_HEADING_FONT="Bricolage Grotesque" BRAND_BODY_FONT=Figtree \
96
+ BRAND_HEADING_WEIGHT=700 BRAND_MEDIUM_WEIGHT=600 \
97
+ BRAND_COLORS_ONLY=1 BRAND_OUT=apps/the-behive/src/app/brand.scss \
98
+ pnpm --filter @behivetech/tokens tokens
99
+ ```
100
+
101
+ `pnpm --filter @behivetech/tokens test` regenerates the default sheet and the-behive's into a temp folder and asserts that the default is unchanged, that the-behive's matches Figma and the committed `brand.scss`, that every black-on-neon pair is 4.5:1 or better, and that invalid options throw. `scripts/compareBrandToFigma.mjs <sheet> [--table]` checks a generated sheet against `scripts/figma-brand.snapshot.txt` (the Figma color variables in Light and Dark) and runs the 4.5:1 check on every black-on-neon pair.
@@ -0,0 +1,31 @@
1
+ $breakpoint-sm: 40rem;
2
+ $breakpoint-md: 48rem;
3
+ $breakpoint-lg: 64rem;
4
+ $breakpoint-xl: 80rem;
5
+ $breakpoint-2xl: 96rem;
6
+
7
+ @mixin sm {
8
+ @media (min-width: $breakpoint-sm) {
9
+ @content;
10
+ }
11
+ }
12
+ @mixin md {
13
+ @media (min-width: $breakpoint-md) {
14
+ @content;
15
+ }
16
+ }
17
+ @mixin lg {
18
+ @media (min-width: $breakpoint-lg) {
19
+ @content;
20
+ }
21
+ }
22
+ @mixin xl {
23
+ @media (min-width: $breakpoint-xl) {
24
+ @content;
25
+ }
26
+ }
27
+ @mixin xxl {
28
+ @media (min-width: $breakpoint-2xl) {
29
+ @content;
30
+ }
31
+ }
package/dist/index.cjs ADDED
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ breakpoints: () => breakpoints,
24
+ minWidth: () => minWidth
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+
28
+ // src/breakpoints.ts
29
+ var breakpoints = {
30
+ sm: 640,
31
+ md: 768,
32
+ lg: 1024,
33
+ xl: 1280,
34
+ "2xl": 1536
35
+ };
36
+
37
+ // index.ts
38
+ function minWidth(bp) {
39
+ return `(min-width: ${breakpoints[bp]}px)`;
40
+ }
41
+ // Annotate the CommonJS export names for ESM import in node:
42
+ 0 && (module.exports = {
43
+ breakpoints,
44
+ minWidth
45
+ });
46
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../index.ts","../src/breakpoints.ts"],"sourcesContent":["// Design tokens and breakpoints for the @behivetech components.\n//\n// Styles are shipped as raw SCSS and consumed directly:\n// @use \"@behivetech/tokens/breakpoints.scss\" as bp; // mixins: @include bp.md { ... }\n// @use \"@behivetech/tokens/tokens.scss\"; // global CSS custom properties\n//\n// This entry has breakpoints.scss as JS values for use in scripts\n// (e.g. window.matchMedia). Both are generated from the one table in\n// scripts/tokenTables.mjs, so the two never drift.\n\nimport { breakpoints, type Breakpoint } from \"./src/breakpoints\";\n\nexport { breakpoints, type Breakpoint };\n\nexport function minWidth(bp: Breakpoint): string {\n return `(min-width: ${breakpoints[bp]}px)`;\n}\n","// GENERATED by @behivetech/tokens — do not edit by hand.\n//\n// Regenerate: pnpm --filter @behivetech/tokens tokens\n// Source: scripts/tokenModel.mjs, the same tables and color schemes that write tokens.scss.\n\n/** The `min-width` breakpoints in px (dp on native); `breakpoints.scss` has the same values in rem. */\nexport const breakpoints = {\n sm: 640,\n md: 768,\n lg: 1024,\n xl: 1280,\n \"2xl\": 1536,\n} as const;\n\n/** A breakpoint name. */\nexport type Breakpoint = keyof typeof breakpoints;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMO,IAAM,cAAc;AAAA,EACzB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,OAAO;AACT;;;ADEO,SAAS,SAAS,IAAwB;AAC/C,SAAO,eAAe,YAAY,EAAE,CAAC;AACvC;","names":[]}
@@ -0,0 +1,14 @@
1
+ /** The `min-width` breakpoints in px (dp on native); `breakpoints.scss` has the same values in rem. */
2
+ declare const breakpoints: {
3
+ readonly sm: 640;
4
+ readonly md: 768;
5
+ readonly lg: 1024;
6
+ readonly xl: 1280;
7
+ readonly "2xl": 1536;
8
+ };
9
+ /** A breakpoint name. */
10
+ type Breakpoint = keyof typeof breakpoints;
11
+
12
+ declare function minWidth(bp: Breakpoint): string;
13
+
14
+ export { type Breakpoint, breakpoints, minWidth };
@@ -0,0 +1,14 @@
1
+ /** The `min-width` breakpoints in px (dp on native); `breakpoints.scss` has the same values in rem. */
2
+ declare const breakpoints: {
3
+ readonly sm: 640;
4
+ readonly md: 768;
5
+ readonly lg: 1024;
6
+ readonly xl: 1280;
7
+ readonly "2xl": 1536;
8
+ };
9
+ /** A breakpoint name. */
10
+ type Breakpoint = keyof typeof breakpoints;
11
+
12
+ declare function minWidth(bp: Breakpoint): string;
13
+
14
+ export { type Breakpoint, breakpoints, minWidth };
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ // src/breakpoints.ts
2
+ var breakpoints = {
3
+ sm: 640,
4
+ md: 768,
5
+ lg: 1024,
6
+ xl: 1280,
7
+ "2xl": 1536
8
+ };
9
+
10
+ // index.ts
11
+ function minWidth(bp) {
12
+ return `(min-width: ${breakpoints[bp]}px)`;
13
+ }
14
+ export {
15
+ breakpoints,
16
+ minWidth
17
+ };
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/breakpoints.ts","../index.ts"],"sourcesContent":["// GENERATED by @behivetech/tokens — do not edit by hand.\n//\n// Regenerate: pnpm --filter @behivetech/tokens tokens\n// Source: scripts/tokenModel.mjs, the same tables and color schemes that write tokens.scss.\n\n/** The `min-width` breakpoints in px (dp on native); `breakpoints.scss` has the same values in rem. */\nexport const breakpoints = {\n sm: 640,\n md: 768,\n lg: 1024,\n xl: 1280,\n \"2xl\": 1536,\n} as const;\n\n/** A breakpoint name. */\nexport type Breakpoint = keyof typeof breakpoints;\n","// Design tokens and breakpoints for the @behivetech components.\n//\n// Styles are shipped as raw SCSS and consumed directly:\n// @use \"@behivetech/tokens/breakpoints.scss\" as bp; // mixins: @include bp.md { ... }\n// @use \"@behivetech/tokens/tokens.scss\"; // global CSS custom properties\n//\n// This entry has breakpoints.scss as JS values for use in scripts\n// (e.g. window.matchMedia). Both are generated from the one table in\n// scripts/tokenTables.mjs, so the two never drift.\n\nimport { breakpoints, type Breakpoint } from \"./src/breakpoints\";\n\nexport { breakpoints, type Breakpoint };\n\nexport function minWidth(bp: Breakpoint): string {\n return `(min-width: ${breakpoints[bp]}px)`;\n}\n"],"mappings":";AAMO,IAAM,cAAc;AAAA,EACzB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,OAAO;AACT;;;ACEO,SAAS,SAAS,IAAwB;AAC/C,SAAO,eAAe,YAAY,EAAE,CAAC;AACvC;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,56 @@
1
1
  {
2
2
  "name": "@behivetech/tokens",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.1.0",
4
+ "license": "MIT",
5
+ "description": "The Material Design 3 token sheet every `@behivetech` component reads — `--md-sys-color-*`, typescale and shape custom properties for the light and dark schemes — plus the breakpoint mixins, generated from one source color.",
6
+ "type": "module",
7
+ "private": false,
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.cjs"
13
+ },
14
+ "./wcag": {
15
+ "types": "./scripts/wcag.d.mts",
16
+ "default": "./scripts/wcag.mjs"
17
+ },
18
+ "./tokens.scss": "./tokens.scss",
19
+ "./breakpoints.scss": "./breakpoints.scss"
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "scripts/wcag.mjs",
24
+ "scripts/wcag.d.mts",
25
+ "tokens.scss",
26
+ "breakpoints.scss"
27
+ ],
28
+ "devDependencies": {
29
+ "@behivetech/eslint-config": "0.1.1",
30
+ "@behivetech/typescript-config": "0.0.2",
31
+ "@material/material-color-utilities": "0.4.0",
32
+ "eslint": "^9.39.5",
33
+ "prettier": "^3.9.6",
34
+ "tsup": "^8.5.1",
35
+ "tsx": "^4.23.11",
36
+ "typescript": "^6.0.3"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "https://github.com/behivetech/bht-galaxy.git",
41
+ "directory": "packages/tokens"
42
+ },
43
+ "publishConfig": {
44
+ "registry": "https://registry.npmjs.org",
45
+ "access": "public"
46
+ },
47
+ "scripts": {
48
+ "build": "tsup",
49
+ "dev": "tsup --watch",
50
+ "tokens": "tsx scripts/generateTokens.mjs",
51
+ "test": "node --import tsx --test \"scripts/*.test.mjs\"",
52
+ "test:cascade": "node --test scripts/browser/cascade.test.mjs",
53
+ "lint": "eslint . --max-warnings 0",
54
+ "check-types": "tsc --noEmit"
55
+ }
6
56
  }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Types for `wcag.mjs`, published as `@behivetech/tokens/wcag`: the blocks builder
3
+ * (`@behivetech/blocks.builder`, issue #570) measures contrast with it.
4
+ */
5
+ /** WCAG AA for body text. */
6
+ export const MIN_TEXT_CONTRAST: number;
7
+ /**
8
+ * Relative luminance of a `#rrggbb` color, 0 (black) to 1 (white).
9
+ *
10
+ * @throws {TypeError} for anything that is not `#` and six hex digits.
11
+ */
12
+ export const luminance: (hex: string) => number;
13
+ /**
14
+ * Contrast ratio of two `#rrggbb` colors, 1 to 21.
15
+ *
16
+ * @throws {TypeError} when either is not `#` and six hex digits.
17
+ */
18
+ export const contrast: (a: string, b: string) => number;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * WCAG 2 relative luminance and contrast for `#rrggbb` colors, in one place so
3
+ * the generator, the Figma checker, the tests and the blocks builder all
4
+ * measure the same way. Published as `@behivetech/tokens/wcag`.
5
+ */
6
+
7
+ /** WCAG AA for body text. */
8
+ export const MIN_TEXT_CONTRAST = 4.5;
9
+
10
+ /** The one form a color is read in: `#` and six hex digits. */
11
+ const HEX_COLOR = /^#[0-9a-f]{6}$/i;
12
+ const BYTE_MAX = 255;
13
+ const LINEAR_CUTOFF = 0.04045;
14
+ const LINEAR_DIVISOR = 12.92;
15
+ const GAMMA_OFFSET = 0.055;
16
+ const GAMMA_DIVISOR = 1.055;
17
+ const GAMMA = 2.4;
18
+ const FLARE = 0.05;
19
+ /** Bit shift of each sRGB channel in the packed integer, and its luminance weight. */
20
+ const SRGB_CHANNELS = [
21
+ [16, 0.2126],
22
+ [8, 0.7152],
23
+ [0, 0.0722],
24
+ ];
25
+
26
+ /**
27
+ * Relative luminance of a `#rrggbb` color, 0 (black) to 1 (white).
28
+ *
29
+ * @throws {TypeError} for anything else (`#rgb`, a color with alpha, a name):
30
+ * read as six digits it would give a number that looks right and is not.
31
+ */
32
+ export const luminance = (hex) => {
33
+ if (typeof hex !== "string" || !HEX_COLOR.test(hex)) {
34
+ throw new TypeError(
35
+ `Expected a color as # and six hex digits, got ${JSON.stringify(hex)}`,
36
+ );
37
+ }
38
+ const packed = Number.parseInt(hex.slice(1), 16);
39
+ return SRGB_CHANNELS.reduce((sum, [shift, weight]) => {
40
+ const channel = ((packed >> shift) & 0xff) / BYTE_MAX;
41
+ const linear =
42
+ channel <= LINEAR_CUTOFF
43
+ ? channel / LINEAR_DIVISOR
44
+ : ((channel + GAMMA_OFFSET) / GAMMA_DIVISOR) ** GAMMA;
45
+ return sum + weight * linear;
46
+ }, 0);
47
+ };
48
+
49
+ /**
50
+ * Contrast ratio of two `#rrggbb` colors, 1 to 21.
51
+ *
52
+ * @throws {TypeError} when either is not `#` and six hex digits.
53
+ */
54
+ export const contrast = (a, b) => {
55
+ const [lighter, darker] = [luminance(a), luminance(b)].sort((x, y) => y - x);
56
+ return (lighter + FLARE) / (darker + FLARE);
57
+ };
package/tokens.scss ADDED
@@ -0,0 +1,495 @@
1
+ // GENERATED by @behivetech/tokens — do not edit by hand.
2
+ //
3
+ // Regenerate: BRAND_SOURCE=#2C1760 BRAND_SCHEME=tonalspot \
4
+ // pnpm --filter @behivetech/tokens tokens
5
+ //
6
+ // Source color: #2C1760 Scheme: tonalspot Tertiary: derived
7
+ //
8
+ // Both schemes are emitted from one palette. A consumer picks between them by
9
+ // doing nothing (the `prefers-color-scheme` query answers the OS) or by setting
10
+ // `data-theme="light" | "dark"` on a root element to force one. An app should
11
+ // never re-declare color values to select a theme; that is what produced four
12
+ // different accent colors across this ecosystem.
13
+
14
+ :root {
15
+ color-scheme: light dark;
16
+
17
+ // ---- Color: light scheme -------------------------------------------------
18
+ --md-sys-color-primary: #64558f;
19
+ --md-sys-color-on-primary: #ffffff;
20
+ --md-sys-color-primary-container: #e8ddff;
21
+ --md-sys-color-on-primary-container: #4c3e76;
22
+ --md-sys-color-secondary: #615b71;
23
+ --md-sys-color-on-secondary: #ffffff;
24
+ --md-sys-color-secondary-container: #e8def8;
25
+ --md-sys-color-on-secondary-container: #494458;
26
+ --md-sys-color-tertiary: #7d5261;
27
+ --md-sys-color-on-tertiary: #ffffff;
28
+ --md-sys-color-tertiary-container: #ffd9e3;
29
+ --md-sys-color-on-tertiary-container: #633b49;
30
+ --md-sys-color-error: #ba1a1a;
31
+ --md-sys-color-on-error: #ffffff;
32
+ --md-sys-color-error-container: #ffdad6;
33
+ --md-sys-color-on-error-container: #93000a;
34
+ --md-sys-color-background: #f9f9f9;
35
+ --md-sys-color-on-background: #1b1b1b;
36
+ --md-sys-color-surface: #f9f9f9;
37
+ --md-sys-color-on-surface: #1b1b1b;
38
+ --md-sys-color-surface-variant: #e2e2e2;
39
+ --md-sys-color-on-surface-variant: #474747;
40
+ --md-sys-color-surface-dim: #dadada;
41
+ --md-sys-color-surface-bright: #f9f9f9;
42
+ --md-sys-color-surface-container-lowest: #ffffff;
43
+ --md-sys-color-surface-container-low: #f3f3f3;
44
+ --md-sys-color-surface-container: #eeeeee;
45
+ --md-sys-color-surface-container-high: #e8e8e8;
46
+ --md-sys-color-surface-container-highest: #e2e2e2;
47
+ --md-sys-color-outline: #777777;
48
+ --md-sys-color-outline-variant: #c6c6c6;
49
+ --md-sys-color-inverse-surface: #303030;
50
+ --md-sys-color-inverse-on-surface: #f1f1f1;
51
+ --md-sys-color-inverse-primary: #cebdfe;
52
+ --md-sys-color-scrim: #000000;
53
+ --md-sys-color-shadow: #000000;
54
+ --md-sys-color-on-scrim: #ffffff;
55
+
56
+ // ---- Toast stripes: light ------------------------------------------------
57
+ --stripe-success: var(--color-success);
58
+ --stripe-warning: var(--color-warning);
59
+ --stripe-error: #ff5449;
60
+
61
+ // ---- Status text: light --------------------------------------------------
62
+ --status-success-text: #006d3c;
63
+ --status-warning-text: #914a00;
64
+
65
+ // ---- Glow: light ---------------------------------------------------------
66
+ --brand-glow-violet: transparent;
67
+
68
+ // ---- Typography ----------------------------------------------------------
69
+ //
70
+ // Families are indirected through two variables so an app re-points the whole
71
+ // scale in two lines instead of fifteen.
72
+ --md-sys-typescale-body-font: "Inter", system-ui, -apple-system, sans-serif;
73
+ --md-sys-typescale-heading-font:
74
+ "Inter", system-ui, -apple-system, sans-serif;
75
+ --md-sys-typescale-mono-font: "JetBrains Mono", "Fira Code", monospace;
76
+
77
+ --md-sys-typescale-display-large-font: var(--md-sys-typescale-heading-font);
78
+ --md-sys-typescale-display-large-size: 3.5625rem;
79
+ --md-sys-typescale-display-large-line-height: 4rem;
80
+ --md-sys-typescale-display-large-weight: 400;
81
+ --md-sys-typescale-display-large-tracking: -0.0044em;
82
+
83
+ --md-sys-typescale-display-medium-font: var(--md-sys-typescale-heading-font);
84
+ --md-sys-typescale-display-medium-size: 2.8125rem;
85
+ --md-sys-typescale-display-medium-line-height: 3.25rem;
86
+ --md-sys-typescale-display-medium-weight: 400;
87
+ --md-sys-typescale-display-medium-tracking: 0em;
88
+
89
+ --md-sys-typescale-display-small-font: var(--md-sys-typescale-heading-font);
90
+ --md-sys-typescale-display-small-size: 2.25rem;
91
+ --md-sys-typescale-display-small-line-height: 2.75rem;
92
+ --md-sys-typescale-display-small-weight: 400;
93
+ --md-sys-typescale-display-small-tracking: 0em;
94
+
95
+ --md-sys-typescale-headline-large-font: var(--md-sys-typescale-heading-font);
96
+ --md-sys-typescale-headline-large-size: 2rem;
97
+ --md-sys-typescale-headline-large-line-height: 2.5rem;
98
+ --md-sys-typescale-headline-large-weight: 400;
99
+ --md-sys-typescale-headline-large-tracking: 0em;
100
+
101
+ --md-sys-typescale-headline-medium-font: var(--md-sys-typescale-heading-font);
102
+ --md-sys-typescale-headline-medium-size: 1.75rem;
103
+ --md-sys-typescale-headline-medium-line-height: 2.25rem;
104
+ --md-sys-typescale-headline-medium-weight: 400;
105
+ --md-sys-typescale-headline-medium-tracking: 0em;
106
+
107
+ --md-sys-typescale-headline-small-font: var(--md-sys-typescale-heading-font);
108
+ --md-sys-typescale-headline-small-size: 1.5rem;
109
+ --md-sys-typescale-headline-small-line-height: 2rem;
110
+ --md-sys-typescale-headline-small-weight: 400;
111
+ --md-sys-typescale-headline-small-tracking: 0em;
112
+
113
+ --md-sys-typescale-title-large-font: var(--md-sys-typescale-body-font);
114
+ --md-sys-typescale-title-large-size: 1.375rem;
115
+ --md-sys-typescale-title-large-line-height: 1.75rem;
116
+ --md-sys-typescale-title-large-weight: 400;
117
+ --md-sys-typescale-title-large-tracking: 0em;
118
+
119
+ --md-sys-typescale-title-medium-font: var(--md-sys-typescale-body-font);
120
+ --md-sys-typescale-title-medium-size: 1rem;
121
+ --md-sys-typescale-title-medium-line-height: 1.5rem;
122
+ --md-sys-typescale-title-medium-weight: 500;
123
+ --md-sys-typescale-title-medium-tracking: 0.0094em;
124
+
125
+ --md-sys-typescale-title-small-font: var(--md-sys-typescale-body-font);
126
+ --md-sys-typescale-title-small-size: 0.875rem;
127
+ --md-sys-typescale-title-small-line-height: 1.25rem;
128
+ --md-sys-typescale-title-small-weight: 500;
129
+ --md-sys-typescale-title-small-tracking: 0.0071em;
130
+
131
+ --md-sys-typescale-body-large-font: var(--md-sys-typescale-body-font);
132
+ --md-sys-typescale-body-large-size: 1rem;
133
+ --md-sys-typescale-body-large-line-height: 1.5rem;
134
+ --md-sys-typescale-body-large-weight: 400;
135
+ --md-sys-typescale-body-large-tracking: 0.0313em;
136
+
137
+ --md-sys-typescale-body-medium-font: var(--md-sys-typescale-body-font);
138
+ --md-sys-typescale-body-medium-size: 0.875rem;
139
+ --md-sys-typescale-body-medium-line-height: 1.25rem;
140
+ --md-sys-typescale-body-medium-weight: 400;
141
+ --md-sys-typescale-body-medium-tracking: 0.0179em;
142
+
143
+ --md-sys-typescale-body-small-font: var(--md-sys-typescale-body-font);
144
+ --md-sys-typescale-body-small-size: 0.75rem;
145
+ --md-sys-typescale-body-small-line-height: 1rem;
146
+ --md-sys-typescale-body-small-weight: 400;
147
+ --md-sys-typescale-body-small-tracking: 0.0333em;
148
+
149
+ --md-sys-typescale-label-large-font: var(--md-sys-typescale-body-font);
150
+ --md-sys-typescale-label-large-size: 0.875rem;
151
+ --md-sys-typescale-label-large-line-height: 1.25rem;
152
+ --md-sys-typescale-label-large-weight: 500;
153
+ --md-sys-typescale-label-large-tracking: 0.0071em;
154
+
155
+ --md-sys-typescale-label-medium-font: var(--md-sys-typescale-body-font);
156
+ --md-sys-typescale-label-medium-size: 0.75rem;
157
+ --md-sys-typescale-label-medium-line-height: 1rem;
158
+ --md-sys-typescale-label-medium-weight: 500;
159
+ --md-sys-typescale-label-medium-tracking: 0.0417em;
160
+
161
+ --md-sys-typescale-label-small-font: var(--md-sys-typescale-body-font);
162
+ --md-sys-typescale-label-small-size: 0.6875rem;
163
+ --md-sys-typescale-label-small-line-height: 1rem;
164
+ --md-sys-typescale-label-small-weight: 500;
165
+ --md-sys-typescale-label-small-tracking: 0.0455em;
166
+
167
+ // ---- Elevation -----------------------------------------------------------
168
+ --md-sys-elevation-0: none;
169
+ --md-sys-elevation-1:
170
+ 0 1px 2px 0 rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15);
171
+ --md-sys-elevation-2:
172
+ 0 1px 2px 0 rgba(0, 0, 0, 0.3), 0 2px 6px 2px rgba(0, 0, 0, 0.15);
173
+ --md-sys-elevation-3:
174
+ 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 4px 8px 3px rgba(0, 0, 0, 0.15);
175
+ --md-sys-elevation-4:
176
+ 0 2px 3px 0 rgba(0, 0, 0, 0.3), 0 6px 10px 4px rgba(0, 0, 0, 0.15);
177
+ --md-sys-elevation-5:
178
+ 0 4px 4px 0 rgba(0, 0, 0, 0.3), 0 8px 12px 6px rgba(0, 0, 0, 0.15);
179
+
180
+ // ---- Shape ---------------------------------------------------------------
181
+ --md-sys-shape-corner-none: 0;
182
+ --md-sys-shape-corner-extra-small: 4px;
183
+ --md-sys-shape-corner-small: 8px;
184
+ --md-sys-shape-corner-medium: 12px;
185
+ --md-sys-shape-corner-large: 16px;
186
+ --md-sys-shape-corner-extra-large: 28px;
187
+ --md-sys-shape-corner-full: 9999px;
188
+
189
+ // ---- State layers --------------------------------------------------------
190
+ --md-sys-state-hover-opacity: 0.08;
191
+ --md-sys-state-focus-opacity: 0.1;
192
+ --md-sys-state-pressed-opacity: 0.1;
193
+ --md-sys-state-dragged-opacity: 0.16;
194
+
195
+ // ---- Motion --------------------------------------------------------------
196
+ --md-sys-motion-easing-standard: cubic-bezier(0.2, 0, 0, 1);
197
+ --md-sys-motion-easing-standard-accelerate: cubic-bezier(0.3, 0, 1, 1);
198
+ --md-sys-motion-easing-standard-decelerate: cubic-bezier(0, 0, 0, 1);
199
+ --md-sys-motion-easing-emphasized: cubic-bezier(0.2, 0, 0, 1);
200
+ --md-sys-motion-easing-emphasized-accelerate: cubic-bezier(0.3, 0, 0.8, 0.15);
201
+ --md-sys-motion-easing-emphasized-decelerate: cubic-bezier(0.05, 0.7, 0.1, 1);
202
+ --md-sys-motion-easing-linear: linear;
203
+
204
+ --md-sys-motion-duration-short-1: 50ms;
205
+ --md-sys-motion-duration-short-2: 100ms;
206
+ --md-sys-motion-duration-short-3: 150ms;
207
+ --md-sys-motion-duration-short-4: 200ms;
208
+ --md-sys-motion-duration-medium-1: 250ms;
209
+ --md-sys-motion-duration-medium-2: 300ms;
210
+ --md-sys-motion-duration-medium-3: 350ms;
211
+ --md-sys-motion-duration-medium-4: 400ms;
212
+ --md-sys-motion-duration-long-1: 450ms;
213
+ --md-sys-motion-duration-long-2: 500ms;
214
+ --md-sys-motion-duration-long-3: 550ms;
215
+ --md-sys-motion-duration-long-4: 600ms;
216
+ --md-sys-motion-duration-extra-long-1: 700ms;
217
+ --md-sys-motion-duration-extra-long-2: 800ms;
218
+ --md-sys-motion-duration-extra-long-3: 900ms;
219
+ --md-sys-motion-duration-extra-long-4: 1000ms;
220
+ }
221
+
222
+ // ---- Color: dark scheme ----------------------------------------------------
223
+ //
224
+ // Applied when the OS asks for dark and the document has not forced light, or
225
+ // when a root element forces dark outright.
226
+ @media (prefers-color-scheme: dark) {
227
+ :root:not([data-theme="light"]) {
228
+ --md-sys-color-primary: #cebdfe;
229
+ --md-sys-color-on-primary: #35275d;
230
+ --md-sys-color-primary-container: #4c3e76;
231
+ --md-sys-color-on-primary-container: #e8ddff;
232
+ --md-sys-color-secondary: #cbc3dc;
233
+ --md-sys-color-on-secondary: #332e41;
234
+ --md-sys-color-secondary-container: #494458;
235
+ --md-sys-color-on-secondary-container: #e8def8;
236
+ --md-sys-color-tertiary: #efb8c9;
237
+ --md-sys-color-on-tertiary: #492532;
238
+ --md-sys-color-tertiary-container: #633b49;
239
+ --md-sys-color-on-tertiary-container: #ffd9e3;
240
+ --md-sys-color-error: #ffb4ab;
241
+ --md-sys-color-on-error: #690005;
242
+ --md-sys-color-error-container: #93000a;
243
+ --md-sys-color-on-error-container: #ffdad6;
244
+ --md-sys-color-background: #131313;
245
+ --md-sys-color-on-background: #e2e2e2;
246
+ --md-sys-color-surface: #131313;
247
+ --md-sys-color-on-surface: #e2e2e2;
248
+ --md-sys-color-surface-variant: #474747;
249
+ --md-sys-color-on-surface-variant: #c6c6c6;
250
+ --md-sys-color-surface-dim: #131313;
251
+ --md-sys-color-surface-bright: #393939;
252
+ --md-sys-color-surface-container-lowest: #0e0e0e;
253
+ --md-sys-color-surface-container-low: #1b1b1b;
254
+ --md-sys-color-surface-container: #1f1f1f;
255
+ --md-sys-color-surface-container-high: #2a2a2a;
256
+ --md-sys-color-surface-container-highest: #353535;
257
+ --md-sys-color-outline: #919191;
258
+ --md-sys-color-outline-variant: #474747;
259
+ --md-sys-color-inverse-surface: #e2e2e2;
260
+ --md-sys-color-inverse-on-surface: #303030;
261
+ --md-sys-color-inverse-primary: #64558f;
262
+ --md-sys-color-scrim: #000000;
263
+ --md-sys-color-shadow: #000000;
264
+ --md-sys-color-on-scrim: #ffffff;
265
+ --stripe-success: #006d3c;
266
+ --stripe-warning: #944b00;
267
+ --stripe-error: #ba1a1a;
268
+ --status-success-text: #64c58d;
269
+ --status-warning-text: #f09f5b;
270
+ --brand-glow-violet: #bc13fe8c;
271
+ }
272
+ }
273
+
274
+ :root[data-theme="dark"] {
275
+ --md-sys-color-primary: #cebdfe;
276
+ --md-sys-color-on-primary: #35275d;
277
+ --md-sys-color-primary-container: #4c3e76;
278
+ --md-sys-color-on-primary-container: #e8ddff;
279
+ --md-sys-color-secondary: #cbc3dc;
280
+ --md-sys-color-on-secondary: #332e41;
281
+ --md-sys-color-secondary-container: #494458;
282
+ --md-sys-color-on-secondary-container: #e8def8;
283
+ --md-sys-color-tertiary: #efb8c9;
284
+ --md-sys-color-on-tertiary: #492532;
285
+ --md-sys-color-tertiary-container: #633b49;
286
+ --md-sys-color-on-tertiary-container: #ffd9e3;
287
+ --md-sys-color-error: #ffb4ab;
288
+ --md-sys-color-on-error: #690005;
289
+ --md-sys-color-error-container: #93000a;
290
+ --md-sys-color-on-error-container: #ffdad6;
291
+ --md-sys-color-background: #131313;
292
+ --md-sys-color-on-background: #e2e2e2;
293
+ --md-sys-color-surface: #131313;
294
+ --md-sys-color-on-surface: #e2e2e2;
295
+ --md-sys-color-surface-variant: #474747;
296
+ --md-sys-color-on-surface-variant: #c6c6c6;
297
+ --md-sys-color-surface-dim: #131313;
298
+ --md-sys-color-surface-bright: #393939;
299
+ --md-sys-color-surface-container-lowest: #0e0e0e;
300
+ --md-sys-color-surface-container-low: #1b1b1b;
301
+ --md-sys-color-surface-container: #1f1f1f;
302
+ --md-sys-color-surface-container-high: #2a2a2a;
303
+ --md-sys-color-surface-container-highest: #353535;
304
+ --md-sys-color-outline: #919191;
305
+ --md-sys-color-outline-variant: #474747;
306
+ --md-sys-color-inverse-surface: #e2e2e2;
307
+ --md-sys-color-inverse-on-surface: #303030;
308
+ --md-sys-color-inverse-primary: #64558f;
309
+ --md-sys-color-scrim: #000000;
310
+ --md-sys-color-shadow: #000000;
311
+ --md-sys-color-on-scrim: #ffffff;
312
+ --stripe-success: #006d3c;
313
+ --stripe-warning: #944b00;
314
+ --stripe-error: #ba1a1a;
315
+ --status-success-text: #64c58d;
316
+ --status-warning-text: #f09f5b;
317
+ --brand-glow-violet: #bc13fe8c;
318
+ }
319
+
320
+ // ---- Compatibility aliases -------------------------------------------------
321
+ //
322
+ // The pre-MD3 token names, re-pointed at their nearest MD3 role so that every
323
+ // existing component keeps working unchanged while packages migrate one at a
324
+ // time. **These are scheduled for removal** — a component still reading
325
+ // `--color-primary` has not been migrated yet, and grepping for these names is
326
+ // how you find the remaining work.
327
+ //
328
+ // The `-inverse` toast stripes alias per-mode `--stripe-*` helpers set in the
329
+ // scheme blocks. They are declared here, in a plain `:root`, so an app sheet
330
+ // loaded after this one can re-point them with a plain `:root` of its own.
331
+ //
332
+ // Two of them cannot be faithful and are called out rather than fudged:
333
+ // * `--color-surface-light` had no MD3 equivalent; it maps to
334
+ // `surface-container-high`, which is the nearest role by intent.
335
+ // * `--color-text-disabled` was a fixed translucent black/white. MD3 expresses
336
+ // disabled as 38% of `on-surface`, which `color-mix` reproduces exactly.
337
+ :root {
338
+ --color-background: var(--md-sys-color-background);
339
+ --color-primary: var(--md-sys-color-primary);
340
+ --color-on-primary: var(--md-sys-color-on-primary);
341
+
342
+ --color-text-body: var(--md-sys-color-on-surface);
343
+ --color-text-heading: var(--md-sys-color-on-surface);
344
+ --color-text-muted: var(--md-sys-color-on-surface-variant);
345
+ --color-text-disabled: color-mix(
346
+ in srgb,
347
+ var(--md-sys-color-on-surface) 38%,
348
+ transparent
349
+ );
350
+
351
+ --color-link: var(--md-sys-color-primary);
352
+ --color-link-hover: var(--md-sys-color-primary);
353
+ --color-link-active: var(--md-sys-color-primary);
354
+ --color-link-visited: var(--md-sys-color-primary);
355
+
356
+ --color-surface: var(--md-sys-color-surface);
357
+ --color-on-surface: var(--md-sys-color-on-surface);
358
+ --color-surface-light: var(--md-sys-color-surface-container-high);
359
+ --color-on-surface-light: var(--md-sys-color-on-surface);
360
+ --color-surface-raised: var(--md-sys-color-surface-container);
361
+ --color-overlay: color-mix(
362
+ in srgb,
363
+ var(--md-sys-color-scrim) 50%,
364
+ transparent
365
+ );
366
+ --color-on-scrim-outline: rgba(255, 255, 255, 0.7);
367
+
368
+ --color-border: var(--md-sys-color-outline-variant);
369
+ --color-border-strong: var(--md-sys-color-outline);
370
+ --color-border-focus: var(--md-sys-color-primary);
371
+
372
+ --color-error: var(--md-sys-color-error);
373
+ --color-error-surface: var(--md-sys-color-error-container);
374
+ --color-error-inverse: var(--stripe-error);
375
+ --color-success: #48bb78;
376
+ --color-success-surface: rgba(72, 187, 120, 0.15);
377
+ --color-success-inverse: var(--stripe-success);
378
+ --color-success-text: var(--status-success-text);
379
+ --color-warning: #ed8936;
380
+ --color-warning-surface: rgba(237, 137, 54, 0.15);
381
+ --color-warning-inverse: var(--stripe-warning);
382
+ --color-warning-text: var(--status-warning-text);
383
+ --color-info: var(--md-sys-color-tertiary);
384
+ --color-info-surface: var(--md-sys-color-tertiary-container);
385
+
386
+ // Spacing, radius, shadow, type scale and z-index keep their old names and
387
+ // values: nothing about them was wrong, and renaming them would churn every
388
+ // stylesheet for no gain. Radius and shadow stay in px on purpose — corners
389
+ // and shadow geometry are not text metrics and should not scale with the
390
+ // reader's font size. Spacing and type sizes are rem, which is why they do.
391
+ --spacing-1: 0.25rem;
392
+ --spacing-2: 0.5rem;
393
+ --spacing-3: 0.75rem;
394
+ --spacing-4: 1rem;
395
+ --spacing-5: 1.25rem;
396
+ --spacing-6: 1.5rem;
397
+ --spacing-8: 2rem;
398
+ --spacing-10: 2.5rem;
399
+ --spacing-12: 3rem;
400
+ --spacing-16: 4rem;
401
+ --spacing-20: 5rem;
402
+ --spacing-24: 6rem;
403
+
404
+ --font-body: var(--md-sys-typescale-body-font);
405
+ --font-heading: var(--md-sys-typescale-heading-font);
406
+ --font-mono: var(--md-sys-typescale-mono-font);
407
+
408
+ --text-xs: 0.75rem;
409
+ --text-sm: 0.875rem;
410
+ --text-base: 1rem;
411
+ --text-lg: 1.125rem;
412
+ --text-xl: 1.25rem;
413
+ --text-2xl: 1.5rem;
414
+ --text-3xl: 1.875rem;
415
+ --text-4xl: 2.25rem;
416
+ --text-5xl: 3rem;
417
+
418
+ --font-weight-normal: 400;
419
+ --font-weight-medium: 500;
420
+ --font-weight-semibold: 600;
421
+ --font-weight-bold: 700;
422
+
423
+ --leading-none: 1;
424
+ --leading-tight: 1.25;
425
+ --leading-snug: 1.375;
426
+ --leading-normal: 1.5;
427
+ --leading-relaxed: 1.625;
428
+ --leading-loose: 2;
429
+
430
+ --tracking-tight: -0.025em;
431
+ --tracking-normal: 0;
432
+ --tracking-wide: 0.025em;
433
+ --tracking-wider: 0.05em;
434
+ --tracking-widest: 0.1em;
435
+
436
+ --radius-sm: var(--md-sys-shape-corner-extra-small);
437
+ --radius-md: var(--md-sys-shape-corner-small);
438
+ --radius-lg: var(--md-sys-shape-corner-medium);
439
+ --radius-xl: var(--md-sys-shape-corner-large);
440
+ --radius-2xl: var(--md-sys-shape-corner-extra-large);
441
+ --radius-full: var(--md-sys-shape-corner-full);
442
+
443
+ --shadow-sm: var(--md-sys-elevation-1);
444
+ --shadow-md: var(--md-sys-elevation-2);
445
+ --shadow-lg: var(--md-sys-elevation-3);
446
+ --shadow-xl: var(--md-sys-elevation-4);
447
+ --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.3);
448
+
449
+ // Z-index is unchanged. See the note kept from the original file: surfaces
450
+ // (base -> modal) nest normally, while transient layers (dropdown -> tooltip)
451
+ // are portalled to document.body and are therefore *siblings* of the modal
452
+ // that opened them — raw z-index is the only thing ordering them, so every
453
+ // transient layer must outrank every surface.
454
+ --z-base: 0;
455
+ --z-raised: 10;
456
+ --z-sticky: 200;
457
+ --z-overlay: 300;
458
+ --z-modal: 400;
459
+ --z-dropdown: 450;
460
+ --z-toast: 500;
461
+ --z-tooltip: 600;
462
+
463
+ --transition-fast: var(--md-sys-motion-duration-short-3)
464
+ var(--md-sys-motion-easing-standard);
465
+ --transition-base: var(--md-sys-motion-duration-short-4)
466
+ var(--md-sys-motion-easing-standard);
467
+ --transition-slow: var(--md-sys-motion-duration-medium-2)
468
+ var(--md-sys-motion-easing-standard);
469
+ --transition-slower: var(--md-sys-motion-duration-long-2)
470
+ var(--md-sys-motion-easing-standard);
471
+ }
472
+
473
+ *,
474
+ *::before,
475
+ *::after {
476
+ box-sizing: border-box;
477
+ }
478
+
479
+ html,
480
+ body {
481
+ margin: 0;
482
+ padding: 0;
483
+ border: 0;
484
+ }
485
+
486
+ html {
487
+ font-family: var(--md-sys-typescale-body-font);
488
+ font-size: var(--md-sys-typescale-body-large-size);
489
+ line-height: var(--md-sys-typescale-body-large-line-height);
490
+ letter-spacing: var(--md-sys-typescale-body-large-tracking);
491
+ color: var(--md-sys-color-on-background);
492
+ background-color: var(--md-sys-color-background);
493
+ -webkit-font-smoothing: antialiased;
494
+ -moz-osx-font-smoothing: grayscale;
495
+ }