foldkit-mixins 0.8.0 → 0.9.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 +11 -5
- package/dist/app.d.mts +1 -1
- package/dist/app.mjs +1 -1
- package/dist/defaults.d.mts.map +1 -1
- package/dist/defaults.mjs +4 -2
- package/dist/defaults.mjs.map +1 -1
- package/dist/{oklch-FOemcYSv.d.mts → oklch-CLKxbFpD.d.mts} +16 -5
- package/dist/{oklch-FOemcYSv.d.mts.map → oklch-CLKxbFpD.d.mts.map} +1 -1
- package/dist/theme.d.mts +20 -6
- package/dist/theme.d.mts.map +1 -1
- package/dist/theme.mjs +16 -17
- package/dist/theme.mjs.map +1 -1
- package/dist/{tokens-BkWHtxjY.mjs → tokens-B3i8bXZp.mjs} +21 -11
- package/dist/tokens-B3i8bXZp.mjs.map +1 -0
- package/dist/{tokens-XZSP0AvO.d.mts → tokens-BaLmrfbp.d.mts} +4 -1
- package/dist/tokens-BaLmrfbp.d.mts.map +1 -0
- package/dist/utilities.d.mts +4 -2
- package/dist/utilities.mjs +13 -1
- package/dist/utilities.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/tokens-BkWHtxjY.mjs.map +0 -1
- package/dist/tokens-XZSP0AvO.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -339,10 +339,14 @@ feedback hues) and returns typed tokens for surfaces, text, outlines, and the ac
|
|
|
339
339
|
tertiary and feedback families. Only the `knob` group holds literals; every other value is a CSS
|
|
340
340
|
expression over other tokens (`oklch(from …)`, `color-mix()`, `light-dark()`), so the browser does
|
|
341
341
|
the derivation and one knob override recolors everything below it. Each family (`accent`,
|
|
342
|
-
`secondary`, `tertiary`, `success`, `warning`, `error`, `info`)
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
342
|
+
`secondary`, `tertiary`, `success`, `warning`, `error`, `info`) is one shape: a fill, `default`,
|
|
343
|
+
lighter in a dark scheme; `hover` and `active`; `subtle`, a tint of it on the base; `outline`, a
|
|
344
|
+
line in it that stands off the base; and two text colors named for where they go: `on-fill` is
|
|
345
|
+
text on that fill (near white on a mid accent), and `ink` is text in the family's color on the
|
|
346
|
+
base surface, dark enough to read in a light scheme and light enough in a dark one. Colored text
|
|
347
|
+
is `ink`, never `default`. The surfaces are the base at a few lightnesses with its chroma, so a
|
|
348
|
+
panel and a sidebar read as the page's own color; `bedrock` is the deepest of them in both
|
|
349
|
+
schemes, and the focus ring, `outline.focus`, is the accent. `Theme.tokens` is the
|
|
346
350
|
non-color scales, with `space` and `radius` multiplied by the `density` and `radius-factor` knobs.
|
|
347
351
|
|
|
348
352
|
A theme reaches the page as pieces, and the page chooses the layers:
|
|
@@ -424,7 +428,9 @@ distinct value is its own class. `sidebar` and `switcher` are flex math and need
|
|
|
424
428
|
|
|
425
429
|
`foldkit-mixins/defaults` is the baseline plain HTML gets before any slot is styled: `Defaults.reset`
|
|
426
430
|
(box model, media, form-control fonts, reduced motion) and `body`, `headings`, `links`, `code`,
|
|
427
|
-
`controls`, composed as `Defaults.all` (everything except `reset`).
|
|
431
|
+
`controls`, composed as `Defaults.all` (everything except `reset`). Native checkboxes, radios and
|
|
432
|
+
sliders take the accent (`accent-color`), selected text is the accent's tint, `kbd` is a raised
|
|
433
|
+
key and `hr` one quiet line. Each is element-selector CSS
|
|
428
434
|
under `:where()` over `--fk-*` tokens with a fallback, so a class rule always beats it and it reads
|
|
429
435
|
with or without a theme. Headings are `text-overt` unless a container sets `--fk-heading`: a band
|
|
430
436
|
drawn in its own color writes `Style.vars({ '--fk-heading': 'currentColor' })` and the headings
|
package/dist/app.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import { standard } from "./layers.mjs";
|
|
|
3
3
|
import { a as NamedStyle, c as StyleOptions, l as StylePieces, n as Declared, r as DeclaredPieces } from "./style-CtCqaL0l.mjs";
|
|
4
4
|
import { a as compose, r as ThemeTokens, t as Refs } from "./core-CUw_n1Nd.mjs";
|
|
5
5
|
import { n as RootOptions } from "./root-xyWS6geK.mjs";
|
|
6
|
-
import { t as Tokens } from "./tokens-
|
|
6
|
+
import { t as Tokens } from "./tokens-BaLmrfbp.mjs";
|
|
7
7
|
//#region src/app.d.ts
|
|
8
8
|
export interface AppStyleOptions<Palette extends ThemeTokens> {
|
|
9
9
|
/** The application's own tokens, usually `Theme.oklch(…)`, laid over `Theme.tokens`. */
|
package/dist/app.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { i as compose } from "./styleValue-Cj4YjgVB.mjs";
|
|
|
3
3
|
import { r as standard } from "./layers-keV38soP.mjs";
|
|
4
4
|
import { o as ref, r as compose$1 } from "./core-IMVYU8JN.mjs";
|
|
5
5
|
import { t as root } from "./root-BBi88KYx.mjs";
|
|
6
|
-
import { r as tokens } from "./tokens-
|
|
6
|
+
import { r as tokens } from "./tokens-B3i8bXZp.mjs";
|
|
7
7
|
import { body, reset } from "./defaults.mjs";
|
|
8
8
|
//#region src/app.ts
|
|
9
9
|
/**
|
package/dist/defaults.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.d.mts","names":[],"sources":["../src/defaults.ts"],"mappings":";;;qBAca,OAAO;;qBAcP,MAAM;;;;;;
|
|
1
|
+
{"version":3,"file":"defaults.d.mts","names":[],"sources":["../src/defaults.ts"],"mappings":";;;qBAca,OAAO;;qBAcP,MAAM;;;;;;qBAcN,UAAU;;qBAaV,OAAO;;qBASP,MAAM;;qBAWN,UAAU;;qBAaV,KAAK;qBAEL"}
|
package/dist/defaults.mjs
CHANGED
|
@@ -21,7 +21,7 @@ const reset = global([
|
|
|
21
21
|
`@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:0.01ms!important;transition-duration:0.01ms!important;scroll-behavior:auto!important}}`
|
|
22
22
|
].join(""));
|
|
23
23
|
/** The page's font, color, background, and color scheme. */
|
|
24
|
-
const body = global(`:where(:root){scrollbar-color:${v("outline-overt", "auto")} transparent}:where(body){font-family:${v("font-body", "system-ui, sans-serif")};font-size:${v("size-md", "1rem")};line-height:${v("leading-normal", "1.5")};font-weight:${v("weight-normal", "400")};color:${v("text-default", "CanvasText")};background:${v("surface-base", "Canvas")};-webkit-font-smoothing:antialiased}`);
|
|
24
|
+
const body = global(`:where(:root){scrollbar-color:${v("outline-overt", "auto")} transparent;accent-color:${v("accent-default", "auto")}}:where(::selection){background:color-mix(in oklab, ${v("accent-default", "Highlight")} 28%, transparent)}:where(body){font-family:${v("font-body", "system-ui, sans-serif")};font-size:${v("size-md", "1rem")};line-height:${v("leading-normal", "1.5")};font-weight:${v("weight-normal", "400")};color:${v("text-default", "CanvasText")};background:${v("surface-base", "Canvas")};-webkit-font-smoothing:antialiased}`);
|
|
25
25
|
/**
|
|
26
26
|
* A type hierarchy for h1 to h6 from the size scale, in `text-overt`. A
|
|
27
27
|
* container drawn in a color of its own, such as a band on the accent, sets
|
|
@@ -45,7 +45,9 @@ const links = global([
|
|
|
45
45
|
/** Inline code and code blocks on the subtle surface. */
|
|
46
46
|
const code = global([
|
|
47
47
|
`:where(:is(code,kbd,samp,pre)){font-family:${v("font-mono", "ui-monospace, monospace")};font-size:${v("size-sm", "0.875rem")}}`,
|
|
48
|
-
`:where(:not(pre)>code){padding:0.1em 0.35em;border-radius:${v("radius-sm", "3px")};background:${v("surface-
|
|
48
|
+
`:where(:not(pre)>code){padding:0.1em 0.35em;border-radius:${v("radius-sm", "3px")};background:${v("surface-muted", "transparent")};overflow-wrap:anywhere}`,
|
|
49
|
+
`:where(kbd){padding:0.1em 0.4em;border:${v("border-thin", "1px")} solid ${v("outline-default", "currentColor")};border-block-end-width:2px;border-radius:${v("radius-sm", "3px")};font-size:0.85em}`,
|
|
50
|
+
`:where(hr){border:0;border-block-start:${v("border-thin", "1px")} solid ${v("outline-subtle", "currentColor")}}`,
|
|
49
51
|
`:where(pre){padding:${v("space-md", "1rem")};border:${v("border-thin", "1px")} solid ${v("outline-subtle", "transparent")};border-radius:${v("radius-md", "6px")};background:${v("surface-subtle", "transparent")};overflow-x:auto;line-height:${v("leading-snug", "1.375")}}`
|
|
50
52
|
].join(""));
|
|
51
53
|
/** Text inputs, selects, textareas, and buttons: one radius, one border, one focus. */
|
package/dist/defaults.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.mjs","names":[],"sources":["../src/defaults.ts"],"sourcesContent":["/**\n * `foldkit-mixins/defaults`: the baseline plain HTML gets before any slot is\n * styled. Every member is element-selector CSS over `--fk-*` tokens with a\n * fallback, so it re-themes with the tokens and still reads without them.\n * The pieces are unlayered; a page puts `reset` in `reset` and the rest in\n * `defaults` with `Layers.standard.in`. Selectors use `:where()` so any\n * class rule beats them.\n */\nimport { compose, global } from './styleValue.js'\nimport type { StyleValue } from './styleValue.js'\n\nconst v = (name: string, fallback: string): string => `var(--fk-${name}, ${fallback})`\n\n/** Box model, margins, media, form-control fonts: what every page assumes. */\nexport const reset: StyleValue = global(\n [\n '*,*::before,*::after{box-sizing:border-box;margin:0;min-width:0}',\n ':where(html){text-size-adjust:none;-webkit-text-size-adjust:none;tab-size:4;font-synthesis:none;text-rendering:optimizeLegibility}',\n ':where(:is(img,picture,video,canvas,svg)){display:block;max-inline-size:100%;block-size:auto}',\n ':where(:is(input,button,textarea,select)){font:inherit;color:inherit}',\n ':where(textarea){field-sizing:content;min-block-size:2lh}',\n ':where(:is(h1,h2,h3,h4,h5,h6)){text-wrap:balance}',\n ':where(p){text-wrap:pretty;overflow-wrap:break-word}',\n `@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:0.01ms!important;transition-duration:0.01ms!important;scroll-behavior:auto!important}}`,\n ].join(''),\n)\n\n/** The page's font, color, background, and color scheme. */\nexport const body: StyleValue = global(\n // Scrollbars in the theme's line color, which keeps the page's hue, not the\n // browser's grey; inherited, so one rule reaches every scrolling panel.\n `:where(:root){scrollbar-color:${v('outline-overt', 'auto')} transparent}` +\n `:where(body){font-family:${v('font-body', 'system-ui, sans-serif')};font-size:${v('size-md', '1rem')};line-height:${v('leading-normal', '1.5')};font-weight:${v('weight-normal', '400')};color:${v('text-default', 'CanvasText')};background:${v('surface-base', 'Canvas')};-webkit-font-smoothing:antialiased}`,\n)\n\n/**\n * A type hierarchy for h1 to h6 from the size scale, in `text-overt`. A\n * container drawn in a color of its own, such as a band on the accent, sets\n * `--fk-heading: currentColor` (`Style.vars`) and its headings take its color.\n */\nexport const headings: StyleValue = global(\n [\n `:where(:is(h1,h2,h3,h4,h5,h6)){font-family:${v('font-heading', 'inherit')};font-weight:${v('weight-bold', '700')};line-height:${v('leading-tight', '1.2')};color:${v('heading', v('text-overt', 'inherit'))};letter-spacing:-0.01em}`,\n `:where(h1){font-size:${v('size-4xl', '2.25rem')}}`,\n `:where(h2){font-size:${v('size-3xl', '1.875rem')}}`,\n `:where(h3){font-size:${v('size-2xl', '1.5rem')}}`,\n `:where(h4){font-size:${v('size-xl', '1.25rem')}}`,\n `:where(h5){font-size:${v('size-lg', '1.125rem')}}`,\n `:where(h6){font-size:${v('size-md', '1rem')}}`,\n ].join(''),\n)\n\n/** Link color, hover, and a visible focus ring. */\nexport const links: StyleValue = global(\n [\n `:where(a){color:${v('text-link', 'LinkText')};text-decoration-thickness:from-font;text-underline-offset:0.15em}`,\n `:where(a:hover){color:${v('text-link-hover', 'LinkText')}}`,\n `:where(:is(a,button,input,select,textarea,summary,[tabindex]):focus-visible){outline:${v('border-thick', '2px')} solid ${v('outline-focus', 'Highlight')};outline-offset:2px}`,\n ].join(''),\n)\n\n/** Inline code and code blocks on the subtle surface. */\nexport const code: StyleValue = global(\n [\n `:where(:is(code,kbd,samp,pre)){font-family:${v('font-mono', 'ui-monospace, monospace')};font-size:${v('size-sm', '0.875rem')}}`,\n `:where(:not(pre)>code){padding:0.1em 0.35em;border-radius:${v('radius-sm', '3px')};background:${v('surface-
|
|
1
|
+
{"version":3,"file":"defaults.mjs","names":[],"sources":["../src/defaults.ts"],"sourcesContent":["/**\n * `foldkit-mixins/defaults`: the baseline plain HTML gets before any slot is\n * styled. Every member is element-selector CSS over `--fk-*` tokens with a\n * fallback, so it re-themes with the tokens and still reads without them.\n * The pieces are unlayered; a page puts `reset` in `reset` and the rest in\n * `defaults` with `Layers.standard.in`. Selectors use `:where()` so any\n * class rule beats them.\n */\nimport { compose, global } from './styleValue.js'\nimport type { StyleValue } from './styleValue.js'\n\nconst v = (name: string, fallback: string): string => `var(--fk-${name}, ${fallback})`\n\n/** Box model, margins, media, form-control fonts: what every page assumes. */\nexport const reset: StyleValue = global(\n [\n '*,*::before,*::after{box-sizing:border-box;margin:0;min-width:0}',\n ':where(html){text-size-adjust:none;-webkit-text-size-adjust:none;tab-size:4;font-synthesis:none;text-rendering:optimizeLegibility}',\n ':where(:is(img,picture,video,canvas,svg)){display:block;max-inline-size:100%;block-size:auto}',\n ':where(:is(input,button,textarea,select)){font:inherit;color:inherit}',\n ':where(textarea){field-sizing:content;min-block-size:2lh}',\n ':where(:is(h1,h2,h3,h4,h5,h6)){text-wrap:balance}',\n ':where(p){text-wrap:pretty;overflow-wrap:break-word}',\n `@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:0.01ms!important;transition-duration:0.01ms!important;scroll-behavior:auto!important}}`,\n ].join(''),\n)\n\n/** The page's font, color, background, and color scheme. */\nexport const body: StyleValue = global(\n // Scrollbars in the theme's line color, which keeps the page's hue, not the\n // browser's grey; inherited, so one rule reaches every scrolling panel.\n `:where(:root){scrollbar-color:${v('outline-overt', 'auto')} transparent;accent-color:${v('accent-default', 'auto')}}` +\n // Selected text in the accent's tint rather than the browser's own blue.\n `:where(::selection){background:color-mix(in oklab, ${v('accent-default', 'Highlight')} 28%, transparent)}` +\n `:where(body){font-family:${v('font-body', 'system-ui, sans-serif')};font-size:${v('size-md', '1rem')};line-height:${v('leading-normal', '1.5')};font-weight:${v('weight-normal', '400')};color:${v('text-default', 'CanvasText')};background:${v('surface-base', 'Canvas')};-webkit-font-smoothing:antialiased}`,\n)\n\n/**\n * A type hierarchy for h1 to h6 from the size scale, in `text-overt`. A\n * container drawn in a color of its own, such as a band on the accent, sets\n * `--fk-heading: currentColor` (`Style.vars`) and its headings take its color.\n */\nexport const headings: StyleValue = global(\n [\n `:where(:is(h1,h2,h3,h4,h5,h6)){font-family:${v('font-heading', 'inherit')};font-weight:${v('weight-bold', '700')};line-height:${v('leading-tight', '1.2')};color:${v('heading', v('text-overt', 'inherit'))};letter-spacing:-0.01em}`,\n `:where(h1){font-size:${v('size-4xl', '2.25rem')}}`,\n `:where(h2){font-size:${v('size-3xl', '1.875rem')}}`,\n `:where(h3){font-size:${v('size-2xl', '1.5rem')}}`,\n `:where(h4){font-size:${v('size-xl', '1.25rem')}}`,\n `:where(h5){font-size:${v('size-lg', '1.125rem')}}`,\n `:where(h6){font-size:${v('size-md', '1rem')}}`,\n ].join(''),\n)\n\n/** Link color, hover, and a visible focus ring. */\nexport const links: StyleValue = global(\n [\n `:where(a){color:${v('text-link', 'LinkText')};text-decoration-thickness:from-font;text-underline-offset:0.15em}`,\n `:where(a:hover){color:${v('text-link-hover', 'LinkText')}}`,\n `:where(:is(a,button,input,select,textarea,summary,[tabindex]):focus-visible){outline:${v('border-thick', '2px')} solid ${v('outline-focus', 'Highlight')};outline-offset:2px}`,\n ].join(''),\n)\n\n/** Inline code and code blocks on the subtle surface. */\nexport const code: StyleValue = global(\n [\n `:where(:is(code,kbd,samp,pre)){font-family:${v('font-mono', 'ui-monospace, monospace')};font-size:${v('size-sm', '0.875rem')}}`,\n `:where(:not(pre)>code){padding:0.1em 0.35em;border-radius:${v('radius-sm', '3px')};background:${v('surface-muted', 'transparent')};overflow-wrap:anywhere}`,\n `:where(kbd){padding:0.1em 0.4em;border:${v('border-thin', '1px')} solid ${v('outline-default', 'currentColor')};border-block-end-width:2px;border-radius:${v('radius-sm', '3px')};font-size:0.85em}`,\n `:where(hr){border:0;border-block-start:${v('border-thin', '1px')} solid ${v('outline-subtle', 'currentColor')}}`,\n `:where(pre){padding:${v('space-md', '1rem')};border:${v('border-thin', '1px')} solid ${v('outline-subtle', 'transparent')};border-radius:${v('radius-md', '6px')};background:${v('surface-subtle', 'transparent')};overflow-x:auto;line-height:${v('leading-snug', '1.375')}}`,\n ].join(''),\n)\n\n/** Text inputs, selects, textareas, and buttons: one radius, one border, one focus. */\nexport const controls: StyleValue = global(\n [\n `:where(:is(input:not([type=checkbox],[type=radio],[type=range],[type=color],[type=file]),select,textarea)){padding:${v('space-xs', '0.5rem')} ${v('space-sm', '0.75rem')};border:${v('border-thin', '1px')} solid ${v('outline-default', 'ButtonBorder')};border-radius:${v('radius-md', '6px')};background:${v('surface-base', 'Field')};color:${v('text-default', 'FieldText')};transition:border-color ${v('motion-fast', '150ms')} ${v('motion-ease', 'ease-out')}}`,\n `:where(:is(input,select,textarea):focus-visible){border-color:${v('accent-default', 'Highlight')}}`,\n `:where(:is(input,select,textarea)[aria-invalid=true]){border-color:${v('error-default', 'red')}}`,\n `:where(button,[type=button],[type=submit],[type=reset]){padding:${v('space-xs', '0.5rem')} ${v('space-md', '1rem')};border:${v('border-thin', '1px')} solid ${v('outline-default', 'ButtonBorder')};border-radius:${v('radius-md', '6px')};background:${v('surface-subtle', 'ButtonFace')};color:${v('text-default', 'ButtonText')};cursor:pointer;transition:background ${v('motion-fast', '150ms')} ${v('motion-ease', 'ease-out')}}`,\n `:where(button,[type=button],[type=submit],[type=reset]):hover{background:${v('surface-muted', 'ButtonFace')}}`,\n `:where(:is(button,input,select,textarea):disabled){opacity:0.5;cursor:not-allowed}`,\n `:where(:is(input,select,textarea,button)::placeholder){color:${v('text-muted', 'GrayText')}}`,\n ].join(''),\n)\n\n/** Every default except `reset`, which belongs in its own layer. */\nexport const all: StyleValue = compose(body, headings, links, code, controls)\n\nexport const Defaults = { reset, body, headings, links, code, controls, all } as const\n"],"mappings":";;;;;;;;;;AAWA,MAAM,KAAK,MAAc,aAA6B,YAAY,KAAK,IAAI,SAAS;;AAGpF,MAAa,QAAoB,OAC/B;CACE;CACA;CACA;CACA;C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,MAAkB,QAAQ,MAAM,UAAU,OAAO,MAAM,QAAQ;AAE5E,MAAa,WAAW;CAAE;CAAO;CAAM;CAAU;CAAO;CAAM;CAAU;AAAI"}
|
|
@@ -81,6 +81,7 @@ declare const oklch: (knobs: OklchKnobs) => Readonly<{
|
|
|
81
81
|
hover: string;
|
|
82
82
|
active: string;
|
|
83
83
|
subtle: string;
|
|
84
|
+
outline: string;
|
|
84
85
|
'on-fill': string;
|
|
85
86
|
ink: string;
|
|
86
87
|
};
|
|
@@ -89,6 +90,7 @@ declare const oklch: (knobs: OklchKnobs) => Readonly<{
|
|
|
89
90
|
hover: string;
|
|
90
91
|
active: string;
|
|
91
92
|
subtle: string;
|
|
93
|
+
outline: string;
|
|
92
94
|
'on-fill': string;
|
|
93
95
|
ink: string;
|
|
94
96
|
};
|
|
@@ -97,6 +99,7 @@ declare const oklch: (knobs: OklchKnobs) => Readonly<{
|
|
|
97
99
|
hover: string;
|
|
98
100
|
active: string;
|
|
99
101
|
subtle: string;
|
|
102
|
+
outline: string;
|
|
100
103
|
'on-fill': string;
|
|
101
104
|
ink: string;
|
|
102
105
|
};
|
|
@@ -105,34 +108,42 @@ declare const oklch: (knobs: OklchKnobs) => Readonly<{
|
|
|
105
108
|
};
|
|
106
109
|
success: {
|
|
107
110
|
default: string;
|
|
111
|
+
hover: string;
|
|
112
|
+
active: string;
|
|
108
113
|
subtle: string;
|
|
114
|
+
outline: string;
|
|
109
115
|
'on-fill': string;
|
|
110
116
|
ink: string;
|
|
111
|
-
outline: string;
|
|
112
117
|
};
|
|
113
118
|
warning: {
|
|
114
119
|
default: string;
|
|
120
|
+
hover: string;
|
|
121
|
+
active: string;
|
|
115
122
|
subtle: string;
|
|
123
|
+
outline: string;
|
|
116
124
|
'on-fill': string;
|
|
117
125
|
ink: string;
|
|
118
|
-
outline: string;
|
|
119
126
|
};
|
|
120
127
|
error: {
|
|
121
128
|
default: string;
|
|
129
|
+
hover: string;
|
|
130
|
+
active: string;
|
|
122
131
|
subtle: string;
|
|
132
|
+
outline: string;
|
|
123
133
|
'on-fill': string;
|
|
124
134
|
ink: string;
|
|
125
|
-
outline: string;
|
|
126
135
|
};
|
|
127
136
|
info: {
|
|
128
137
|
default: string;
|
|
138
|
+
hover: string;
|
|
139
|
+
active: string;
|
|
129
140
|
subtle: string;
|
|
141
|
+
outline: string;
|
|
130
142
|
'on-fill': string;
|
|
131
143
|
ink: string;
|
|
132
|
-
outline: string;
|
|
133
144
|
};
|
|
134
145
|
}>;
|
|
135
146
|
type OklchTheme = ReturnType<typeof oklch>;
|
|
136
147
|
//#endregion
|
|
137
148
|
export { OklchTheme as n, oklch as r, OklchKnobs as t };
|
|
138
|
-
//# sourceMappingURL=oklch-
|
|
149
|
+
//# sourceMappingURL=oklch-CLKxbFpD.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oklch-
|
|
1
|
+
{"version":3,"file":"oklch-CLKxbFpD.d.mts","names":[],"sources":["../src/theme/oklch.ts"],"mappings":";UAUiB;;WAEN;aACE;aACA;aACA;;aAEA;eAAkB;eAAqB;;;;WAGzC;WACA;;WAEA;;WAEA;;WAEA;;WAEA;aACE;aACA;aACA;aACA;;;cAiFA,QAAS,OAAO,eAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA6F3B,aAAa,kBAAkB"}
|
package/dist/theme.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { o as StyleValue } from "./styleValue-BavTe9MZ.mjs";
|
|
2
2
|
import { a as compose, c as lightDark, i as VAR_PREFIX, l as ref, n as Theme$1, o as core_d_exports, r as ThemeTokens, s as define, t as Refs, u as variables } from "./core-CUw_n1Nd.mjs";
|
|
3
3
|
import { i as scoped, n as RootOptions, r as root, t as Overrides } from "./root-xyWS6geK.mjs";
|
|
4
|
-
import { i as tokens, n as breakpointWidths, r as inContainer, t as Tokens } from "./tokens-
|
|
5
|
-
import { n as OklchTheme, r as oklch, t as OklchKnobs } from "./oklch-
|
|
4
|
+
import { i as tokens, n as breakpointWidths, r as inContainer, t as Tokens } from "./tokens-BaLmrfbp.mjs";
|
|
5
|
+
import { n as OklchTheme, r as oklch, t as OklchKnobs } from "./oklch-CLKxbFpD.mjs";
|
|
6
6
|
//#region src/theme.d.ts
|
|
7
7
|
export declare const Theme: {
|
|
8
8
|
readonly root: (theme: ThemeTokens, options?: RootOptions) => StyleValue;
|
|
@@ -11,6 +11,8 @@ export declare const Theme: {
|
|
|
11
11
|
knob: {
|
|
12
12
|
density: string;
|
|
13
13
|
'radius-factor': string;
|
|
14
|
+
motion: string;
|
|
15
|
+
'shadow-strength': string;
|
|
14
16
|
};
|
|
15
17
|
space: {
|
|
16
18
|
'3xs': string;
|
|
@@ -74,6 +76,7 @@ export declare const Theme: {
|
|
|
74
76
|
md: string;
|
|
75
77
|
lg: string;
|
|
76
78
|
xl: string;
|
|
79
|
+
'2xl': string;
|
|
77
80
|
inset: string;
|
|
78
81
|
};
|
|
79
82
|
breakpoint: {
|
|
@@ -142,6 +145,7 @@ export declare const Theme: {
|
|
|
142
145
|
hover: string;
|
|
143
146
|
active: string;
|
|
144
147
|
subtle: string;
|
|
148
|
+
outline: string;
|
|
145
149
|
'on-fill': string;
|
|
146
150
|
ink: string;
|
|
147
151
|
};
|
|
@@ -150,6 +154,7 @@ export declare const Theme: {
|
|
|
150
154
|
hover: string;
|
|
151
155
|
active: string;
|
|
152
156
|
subtle: string;
|
|
157
|
+
outline: string;
|
|
153
158
|
'on-fill': string;
|
|
154
159
|
ink: string;
|
|
155
160
|
};
|
|
@@ -158,6 +163,7 @@ export declare const Theme: {
|
|
|
158
163
|
hover: string;
|
|
159
164
|
active: string;
|
|
160
165
|
subtle: string;
|
|
166
|
+
outline: string;
|
|
161
167
|
'on-fill': string;
|
|
162
168
|
ink: string;
|
|
163
169
|
};
|
|
@@ -166,31 +172,39 @@ export declare const Theme: {
|
|
|
166
172
|
};
|
|
167
173
|
success: {
|
|
168
174
|
default: string;
|
|
175
|
+
hover: string;
|
|
176
|
+
active: string;
|
|
169
177
|
subtle: string;
|
|
178
|
+
outline: string;
|
|
170
179
|
'on-fill': string;
|
|
171
180
|
ink: string;
|
|
172
|
-
outline: string;
|
|
173
181
|
};
|
|
174
182
|
warning: {
|
|
175
183
|
default: string;
|
|
184
|
+
hover: string;
|
|
185
|
+
active: string;
|
|
176
186
|
subtle: string;
|
|
187
|
+
outline: string;
|
|
177
188
|
'on-fill': string;
|
|
178
189
|
ink: string;
|
|
179
|
-
outline: string;
|
|
180
190
|
};
|
|
181
191
|
error: {
|
|
182
192
|
default: string;
|
|
193
|
+
hover: string;
|
|
194
|
+
active: string;
|
|
183
195
|
subtle: string;
|
|
196
|
+
outline: string;
|
|
184
197
|
'on-fill': string;
|
|
185
198
|
ink: string;
|
|
186
|
-
outline: string;
|
|
187
199
|
};
|
|
188
200
|
info: {
|
|
189
201
|
default: string;
|
|
202
|
+
hover: string;
|
|
203
|
+
active: string;
|
|
190
204
|
subtle: string;
|
|
205
|
+
outline: string;
|
|
191
206
|
'on-fill': string;
|
|
192
207
|
ink: string;
|
|
193
|
-
outline: string;
|
|
194
208
|
};
|
|
195
209
|
}>;
|
|
196
210
|
readonly define: <T extends ThemeTokens>(tokens: T) => Readonly<T>;
|
package/dist/theme.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.mts","names":[],"sources":["../src/theme.ts"],"mappings":";;;;;;qBAoBa
|
|
1
|
+
{"version":3,"file":"theme.d.mts","names":[],"sources":["../src/theme.ts"],"mappings":";;;;;;qBAoBa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WASskH,cAAA,oBAAA,SAAA,yBAAA,cAAA,aAAA,4BAAS,WAAA;0BAAA"}
|
package/dist/theme.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as lightDark, i as define, n as VAR_PREFIX, o as ref, r as compose, s as variables, t as Theme$1 } from "./core-IMVYU8JN.mjs";
|
|
2
2
|
import { n as scoped, t as root } from "./root-BBi88KYx.mjs";
|
|
3
|
-
import { n as inContainer, r as tokens, t as breakpointWidths } from "./tokens-
|
|
3
|
+
import { n as inContainer, r as tokens, t as breakpointWidths } from "./tokens-B3i8bXZp.mjs";
|
|
4
4
|
//#region src/theme/oklch.ts
|
|
5
5
|
/**
|
|
6
6
|
* A whole palette from a few knobs, as css-tags derives it: every value
|
|
@@ -44,6 +44,12 @@ const surfaceStep = (light, dark) => {
|
|
|
44
44
|
};
|
|
45
45
|
/** A text color: fixed lightness, chroma scaled by surface saturation and the contrast factor. */
|
|
46
46
|
const text = (light, dark) => ld(`oklch(${light[0]}% calc(${surfaceC} * ${light[1]} * ${contrastFactor}) ${neutral})`, `oklch(${dark[0]}% calc(${surfaceCDark} * ${dark[1]} * ${contrastFactor}) ${neutral})`);
|
|
47
|
+
/**
|
|
48
|
+
* A color family, every one the same shape: its fill, the fill hovered and
|
|
49
|
+
* pressed, a tint of it on the base, a line in it that stands off the base
|
|
50
|
+
* (darker in a light scheme, lighter in a dark one), and text on the fill
|
|
51
|
+
* and in the family's color.
|
|
52
|
+
*/
|
|
47
53
|
const family = (name, defaultValue) => {
|
|
48
54
|
const color = v(name, "default");
|
|
49
55
|
return {
|
|
@@ -51,20 +57,13 @@ const family = (name, defaultValue) => {
|
|
|
51
57
|
hover: shift(color, -.06, 0),
|
|
52
58
|
active: shift(color, -.1, .05),
|
|
53
59
|
subtle: tint(color, 85),
|
|
60
|
+
outline: ld(shift(color, -.05, 0), shift(color, .05, 0)),
|
|
54
61
|
"on-fill": contrast(color),
|
|
55
62
|
ink: ink(color)
|
|
56
63
|
};
|
|
57
64
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
default: `oklch(${l}% ${c} ${v("knob", `${name}-h`)})`,
|
|
62
|
-
subtle: tint(color, 85),
|
|
63
|
-
"on-fill": contrast(color),
|
|
64
|
-
ink: ink(color),
|
|
65
|
-
outline: shift(color, -.05, 0)
|
|
66
|
-
};
|
|
67
|
-
};
|
|
65
|
+
/** A feedback family, lighter in a dark scheme so its fill reads on a dark page. */
|
|
66
|
+
const feedback = (name, l, c, dark) => family(name, ld(`oklch(${l}% ${c} ${v("knob", `${name}-h`)})`, `oklch(${dark}% ${c} ${v("knob", `${name}-h`)})`));
|
|
68
67
|
const oklch = (knobs) => {
|
|
69
68
|
const accent = v("accent", "default");
|
|
70
69
|
const surfaceSaturation = knobs.surfaceSaturation ?? .015;
|
|
@@ -100,7 +99,7 @@ const oklch = (knobs) => {
|
|
|
100
99
|
subtle: surfaceStep([-.025, 1.15], [-.015, 1.05]),
|
|
101
100
|
default: surfaceStep([-.055, 1.25], [.045, 1.1]),
|
|
102
101
|
overt: surfaceStep([-.31, 2.25], [.125, 1.2]),
|
|
103
|
-
bedrock: ld(`oklch(8% calc(${surfaceC} * 1.2) ${neutral})`, `oklch(
|
|
102
|
+
bedrock: ld(`oklch(8% calc(${surfaceC} * 1.2) ${neutral})`, `oklch(6% calc(${surfaceCDark} * 1.2) ${neutral})`)
|
|
104
103
|
},
|
|
105
104
|
text: {
|
|
106
105
|
default: text([20, 2], [88, .8]),
|
|
@@ -114,16 +113,16 @@ const oklch = (knobs) => {
|
|
|
114
113
|
subtle: ld(scale(base, -.07, 1.3), scale(base, .065, 1.25)),
|
|
115
114
|
default: ld(scale(base, -.13, 1.4), scale(base, .12, 1.35)),
|
|
116
115
|
overt: ld(scale(base, -.27, 1.6), scale(base, .23, 1.5)),
|
|
117
|
-
focus:
|
|
116
|
+
focus: accent
|
|
118
117
|
},
|
|
119
118
|
accent: family("accent", ld(`oklch(${v("knob", "accent-l")} ${v("knob", "accent-c")} ${v("hue", "accent")})`, `oklch(${v("knob", "accent-l-dark")} ${v("knob", "accent-c-dark")} ${v("hue", "accent")})`)),
|
|
120
119
|
secondary: family("secondary", rehue(accent, v("hue", "secondary"))),
|
|
121
120
|
tertiary: family("tertiary", rehue(accent, v("hue", "tertiary"))),
|
|
122
121
|
shadow: { color: ld(`oklch(25% calc(${surfaceC} * 2) ${neutral} / 0.14)`, `oklch(5% calc(${surfaceCDark} * 2) ${neutral} / 0.6)`) },
|
|
123
|
-
success: feedback("success", 55, .15),
|
|
124
|
-
warning: feedback("warning", 70, .15),
|
|
125
|
-
error: feedback("error", 60, .2),
|
|
126
|
-
info: feedback("info", 65, .15)
|
|
122
|
+
success: feedback("success", 55, .15, 64),
|
|
123
|
+
warning: feedback("warning", 70, .15, 76),
|
|
124
|
+
error: feedback("error", 60, .2, 64),
|
|
125
|
+
info: feedback("info", 65, .15, 70)
|
|
127
126
|
});
|
|
128
127
|
};
|
|
129
128
|
//#endregion
|
package/dist/theme.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.mjs","names":["Core.Theme"],"sources":["../src/theme/oklch.ts","../src/theme.ts"],"sourcesContent":["/**\n * A whole palette from a few knobs, as css-tags derives it: every value\n * except the knobs is a CSS expression over other tokens, so overriding a\n * knob anywhere (a scoped theme, a subtree, an inline style) re-derives the\n * rest in the browser. Where light and dark schemes need different numbers\n * the value is a `light-dark()` pair, so one theme serves both and a user's\n * choice is a `color-scheme` override.\n */\nimport { define } from './core.js'\n\nexport interface OklchKnobs {\n /** The brand color: hue in degrees, chroma 0–0.4, lightness as a percentage. */\n readonly accent: {\n readonly h: number\n readonly c: number\n readonly l: string\n /** Lighter and stronger on dark surfaces; defaults `70%` and `c + 0.03`. */\n readonly dark?: { readonly l?: string; readonly c?: number }\n }\n /** Degrees added to the accent hue for the secondary and tertiary families. */\n readonly secondaryHueShift?: number\n readonly tertiaryHueShift?: number\n /** Chroma of neutral surfaces; 0 is gray. */\n readonly surfaceSaturation?: number\n /** How far apart the surface steps are, 0–100%. */\n readonly surfaceContrast?: string\n /** Multiplies text chroma. */\n readonly contrastFactor?: number\n /** Hues of the feedback families. */\n readonly feedback?: {\n readonly success?: number\n readonly warning?: number\n readonly error?: number\n readonly info?: number\n }\n}\n\nconst v = (group: string, name: string) => `var(--fk-${group}-${name})`\n/** A computed knob without float noise: `0.02`, not `0.019999999999999997`. */\nconst num = (value: number) => String(Number(value.toFixed(4)))\nconst ld = (light: string, dark: string) => `light-dark(${light}, ${dark})`\nconst offset = (amount: number) => `${amount < 0 ? '-' : '+'} ${Math.abs(amount)}`\n/** `oklch(from <color> …)` with the hue kept. */\nconst from = (color: string, l: string, c: string) => `oklch(from ${color} ${l} ${c} h)`\nconst shift = (color: string, dl: number, dc: number) =>\n from(color, `calc(l ${offset(dl)})`, `calc(c ${offset(dc)})`)\nconst scale = (color: string, dl: number, cx: number) =>\n from(color, `calc(l ${offset(dl)})`, `calc(c * ${cx})`)\n/** The same lightness and chroma as `color` on another hue. */\nconst rehue = (color: string, hue: string) => `oklch(from ${color} l c ${hue})`\n/** Near-black or near-white text over `color`. */\nconst contrast = (color: string) =>\n `oklch(from ${color} clamp(0.1, (0.65 / l - 1) * 999, 0.98) min(c, 0.08) h)`\n/** `color` as text on the base surface: dark in a light scheme, light in a dark one. */\nconst ink = (color: string) => ld(from(color, '0.5', 'c'), from(color, '0.8', 'c'))\n/**\n * `color` tinted onto the base surface, the same in both schemes. Mixed in\n * OKLab, not OKLCH: OKLCH interpolates hue, so a mix mostly of the base keeps\n * the base's hue, and a green tinted onto a blue-grey base came out blue.\n */\nconst tint = (color: string, percent: number) =>\n `color-mix(in oklab, ${v('surface', 'base')} ${percent}%, ${color})`\n\nconst neutral = v('hue', 'neutral')\nconst base = v('surface', 'base')\nconst surfaceC = v('knob', 'surface-c')\nconst surfaceCDark = v('knob', 'surface-c-dark')\nconst contrastFactor = v('knob', 'contrast-factor')\n\ntype Step = readonly [lightness: number, chroma: number]\n\n/** A surface step: the base mixed toward a target by `surface-contrast`. */\nconst surfaceStep = (light: Step, dark: Step) => {\n const amount = v('knob', 'surface-contrast')\n const target = ld(scale(base, light[0], light[1]), scale(base, dark[0], dark[1]))\n return `color-mix(in oklch, ${base} calc(100% - ${amount}), ${target} ${amount})`\n}\n\n/** A text color: fixed lightness, chroma scaled by surface saturation and the contrast factor. */\nconst text = (light: Step, dark: Step) =>\n ld(\n `oklch(${light[0]}% calc(${surfaceC} * ${light[1]} * ${contrastFactor}) ${neutral})`,\n `oklch(${dark[0]}% calc(${surfaceCDark} * ${dark[1]} * ${contrastFactor}) ${neutral})`,\n )\n\nconst family = (name: string, defaultValue: string) => {\n const color = v(name, 'default')\n return {\n default: defaultValue,\n hover: shift(color, -0.06, 0),\n active: shift(color, -0.1, 0.05),\n subtle: tint(color, 85),\n 'on-fill': contrast(color),\n ink: ink(color),\n }\n}\n\nconst feedback = (name: string, l: number, c: number) => {\n const color = v(name, 'default')\n return {\n default: `oklch(${l}% ${c} ${v('knob', `${name}-h`)})`,\n subtle: tint(color, 85),\n 'on-fill': contrast(color),\n ink: ink(color),\n outline: shift(color, -0.05, 0),\n }\n}\n\nexport const oklch = (knobs: OklchKnobs) => {\n const accent = v('accent', 'default')\n const surfaceSaturation = knobs.surfaceSaturation ?? 0.015\n return define({\n knob: {\n 'accent-h': String(knobs.accent.h),\n 'accent-c': String(knobs.accent.c),\n 'accent-l': knobs.accent.l,\n 'accent-c-dark': num(knobs.accent.dark?.c ?? Math.min(0.4, knobs.accent.c + 0.03)),\n 'accent-l-dark': knobs.accent.dark?.l ?? '70%',\n 'secondary-shift': String(knobs.secondaryHueShift ?? 60),\n 'tertiary-shift': String(knobs.tertiaryHueShift ?? -90),\n 'surface-c': String(surfaceSaturation),\n 'surface-c-dark': num(surfaceSaturation * (4 / 3)),\n 'surface-contrast': knobs.surfaceContrast ?? '65%',\n 'contrast-factor': String(knobs.contrastFactor ?? 1),\n 'base-l': '97.5%',\n 'base-l-dark': '22%',\n 'success-h': String(knobs.feedback?.success ?? 145),\n 'warning-h': String(knobs.feedback?.warning ?? 75),\n 'error-h': String(knobs.feedback?.error ?? 25),\n 'info-h': String(knobs.feedback?.info ?? 245),\n },\n hue: {\n accent: v('knob', 'accent-h'),\n secondary: `calc(${v('knob', 'accent-h')} + ${v('knob', 'secondary-shift')})`,\n tertiary: `calc(${v('knob', 'accent-h')} + ${v('knob', 'tertiary-shift')})`,\n neutral: v('hue', 'accent'),\n },\n surface: {\n base: ld(\n `oklch(${v('knob', 'base-l')} calc(${surfaceC} * 0.9) ${neutral})`,\n `oklch(${v('knob', 'base-l-dark')} calc(${surfaceCDark} * 0.9) ${neutral})`,\n ),\n // Each step keeps about the base's chroma, so a sidebar, a panel and\n // the page read as one color at a few lightnesses: one with less reads\n // grey on the page, one with more reads as another, bluer color.\n muted: surfaceStep([-0.04, 1.2], [-0.03, 1.05]),\n subtle: surfaceStep([-0.025, 1.15], [-0.015, 1.05]),\n default: surfaceStep([-0.055, 1.25], [0.045, 1.1]),\n overt: surfaceStep([-0.31, 2.25], [0.125, 1.2]),\n bedrock: ld(\n `oklch(8% calc(${surfaceC} * 1.2) ${neutral})`,\n `oklch(98% calc(${surfaceCDark} * 0.7) ${neutral})`,\n ),\n },\n text: {\n default: text([20, 2], [88, 0.8]),\n muted: text([45, 1.5], [65, 1.2]),\n subtle: text([35, 1.8], [75, 1]),\n overt: text([10, 2.2], [95, 0.6]),\n link: shift(accent, 0.1, 0.05),\n 'link-hover': shift(v('text', 'link'), -0.1, 0),\n },\n // Steps from the base, as the surfaces are: darker in a light scheme,\n // lighter in a dark one, and in the base's own hue with a little more of\n // its chroma, which a thin line needs to read as the page's color. Text mixed into the base, as they were, came out grey on a\n // tinted page: the text is near-neutral, so the mix lost the tint.\n outline: {\n subtle: ld(scale(base, -0.07, 1.3), scale(base, 0.065, 1.25)),\n default: ld(scale(base, -0.13, 1.4), scale(base, 0.12, 1.35)),\n overt: ld(scale(base, -0.27, 1.6), scale(base, 0.23, 1.5)),\n focus: shift(accent, -0.1, 0.1),\n },\n accent: family(\n 'accent',\n ld(\n `oklch(${v('knob', 'accent-l')} ${v('knob', 'accent-c')} ${v('hue', 'accent')})`,\n `oklch(${v('knob', 'accent-l-dark')} ${v('knob', 'accent-c-dark')} ${v('hue', 'accent')})`,\n ),\n ),\n secondary: family('secondary', rehue(accent, v('hue', 'secondary'))),\n tertiary: family('tertiary', rehue(accent, v('hue', 'tertiary'))),\n // A near-black of the neutral hue: faint on a light surface, and denser\n // on a dark one, where a light shadow would read as a glow.\n shadow: {\n color: ld(\n `oklch(25% calc(${surfaceC} * 2) ${neutral} / 0.14)`,\n `oklch(5% calc(${surfaceCDark} * 2) ${neutral} / 0.6)`,\n ),\n },\n success: feedback('success', 55, 0.15),\n warning: feedback('warning', 70, 0.15),\n error: feedback('error', 60, 0.2),\n info: feedback('info', 65, 0.15),\n })\n}\n\nexport type OklchTheme = ReturnType<typeof oklch>\n","/**\n * `foldkit-mixins/theme`: the root export's `Theme` plus the page-level\n * pieces. `root` and `scoped` turn tokens into unlayered `:root` and\n * selector rules for `Style.stylesheet`; `tokens` is the shipped set of\n * non-color scales; `oklch` derives a whole palette from a few knobs.\n */\nimport * as Core from './theme/core.js'\nimport { oklch } from './theme/oklch.js'\nimport { root, scoped } from './theme/root.js'\nimport { breakpointWidths, inContainer, tokens } from './theme/tokens.js'\n\nexport { compose, define, lightDark, ref, variables, VAR_PREFIX } from './theme/core.js'\nexport type { Refs, Theme as ThemeValue, ThemeTokens } from './theme/core.js'\nexport { root, scoped } from './theme/root.js'\nexport type { Overrides, RootOptions } from './theme/root.js'\nexport { breakpointWidths, inContainer, tokens } from './theme/tokens.js'\nexport type { Tokens } from './theme/tokens.js'\nexport { oklch } from './theme/oklch.js'\nexport type { OklchKnobs, OklchTheme } from './theme/oklch.js'\n\nexport const Theme = {\n ...Core.Theme,\n root,\n scoped,\n tokens,\n breakpointWidths,\n inContainer,\n oklch,\n} as const\n"],"mappings":";;;;;;;;;;;;AAqCA,MAAM,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
1
|
+
{"version":3,"file":"theme.mjs","names":["Core.Theme"],"sources":["../src/theme/oklch.ts","../src/theme.ts"],"sourcesContent":["/**\n * A whole palette from a few knobs, as css-tags derives it: every value\n * except the knobs is a CSS expression over other tokens, so overriding a\n * knob anywhere (a scoped theme, a subtree, an inline style) re-derives the\n * rest in the browser. Where light and dark schemes need different numbers\n * the value is a `light-dark()` pair, so one theme serves both and a user's\n * choice is a `color-scheme` override.\n */\nimport { define } from './core.js'\n\nexport interface OklchKnobs {\n /** The brand color: hue in degrees, chroma 0–0.4, lightness as a percentage. */\n readonly accent: {\n readonly h: number\n readonly c: number\n readonly l: string\n /** Lighter and stronger on dark surfaces; defaults `70%` and `c + 0.03`. */\n readonly dark?: { readonly l?: string; readonly c?: number }\n }\n /** Degrees added to the accent hue for the secondary and tertiary families. */\n readonly secondaryHueShift?: number\n readonly tertiaryHueShift?: number\n /** Chroma of neutral surfaces; 0 is gray. */\n readonly surfaceSaturation?: number\n /** How far apart the surface steps are, 0–100%. */\n readonly surfaceContrast?: string\n /** Multiplies text chroma. */\n readonly contrastFactor?: number\n /** Hues of the feedback families. */\n readonly feedback?: {\n readonly success?: number\n readonly warning?: number\n readonly error?: number\n readonly info?: number\n }\n}\n\nconst v = (group: string, name: string) => `var(--fk-${group}-${name})`\n/** A computed knob without float noise: `0.02`, not `0.019999999999999997`. */\nconst num = (value: number) => String(Number(value.toFixed(4)))\nconst ld = (light: string, dark: string) => `light-dark(${light}, ${dark})`\nconst offset = (amount: number) => `${amount < 0 ? '-' : '+'} ${Math.abs(amount)}`\n/** `oklch(from <color> …)` with the hue kept. */\nconst from = (color: string, l: string, c: string) => `oklch(from ${color} ${l} ${c} h)`\nconst shift = (color: string, dl: number, dc: number) =>\n from(color, `calc(l ${offset(dl)})`, `calc(c ${offset(dc)})`)\nconst scale = (color: string, dl: number, cx: number) =>\n from(color, `calc(l ${offset(dl)})`, `calc(c * ${cx})`)\n/** The same lightness and chroma as `color` on another hue. */\nconst rehue = (color: string, hue: string) => `oklch(from ${color} l c ${hue})`\n/** Near-black or near-white text over `color`. */\nconst contrast = (color: string) =>\n `oklch(from ${color} clamp(0.1, (0.65 / l - 1) * 999, 0.98) min(c, 0.08) h)`\n/** `color` as text on the base surface: dark in a light scheme, light in a dark one. */\nconst ink = (color: string) => ld(from(color, '0.5', 'c'), from(color, '0.8', 'c'))\n/**\n * `color` tinted onto the base surface, the same in both schemes. Mixed in\n * OKLab, not OKLCH: OKLCH interpolates hue, so a mix mostly of the base keeps\n * the base's hue, and a green tinted onto a blue-grey base came out blue.\n */\nconst tint = (color: string, percent: number) =>\n `color-mix(in oklab, ${v('surface', 'base')} ${percent}%, ${color})`\n\nconst neutral = v('hue', 'neutral')\nconst base = v('surface', 'base')\nconst surfaceC = v('knob', 'surface-c')\nconst surfaceCDark = v('knob', 'surface-c-dark')\nconst contrastFactor = v('knob', 'contrast-factor')\n\ntype Step = readonly [lightness: number, chroma: number]\n\n/** A surface step: the base mixed toward a target by `surface-contrast`. */\nconst surfaceStep = (light: Step, dark: Step) => {\n const amount = v('knob', 'surface-contrast')\n const target = ld(scale(base, light[0], light[1]), scale(base, dark[0], dark[1]))\n return `color-mix(in oklch, ${base} calc(100% - ${amount}), ${target} ${amount})`\n}\n\n/** A text color: fixed lightness, chroma scaled by surface saturation and the contrast factor. */\nconst text = (light: Step, dark: Step) =>\n ld(\n `oklch(${light[0]}% calc(${surfaceC} * ${light[1]} * ${contrastFactor}) ${neutral})`,\n `oklch(${dark[0]}% calc(${surfaceCDark} * ${dark[1]} * ${contrastFactor}) ${neutral})`,\n )\n\n/**\n * A color family, every one the same shape: its fill, the fill hovered and\n * pressed, a tint of it on the base, a line in it that stands off the base\n * (darker in a light scheme, lighter in a dark one), and text on the fill\n * and in the family's color.\n */\nconst family = (name: string, defaultValue: string) => {\n const color = v(name, 'default')\n return {\n default: defaultValue,\n hover: shift(color, -0.06, 0),\n active: shift(color, -0.1, 0.05),\n subtle: tint(color, 85),\n outline: ld(shift(color, -0.05, 0), shift(color, 0.05, 0)),\n 'on-fill': contrast(color),\n ink: ink(color),\n }\n}\n\n/** A feedback family, lighter in a dark scheme so its fill reads on a dark page. */\nconst feedback = (name: string, l: number, c: number, dark: number) =>\n family(\n name,\n ld(\n `oklch(${l}% ${c} ${v('knob', `${name}-h`)})`,\n `oklch(${dark}% ${c} ${v('knob', `${name}-h`)})`,\n ),\n )\n\nexport const oklch = (knobs: OklchKnobs) => {\n const accent = v('accent', 'default')\n const surfaceSaturation = knobs.surfaceSaturation ?? 0.015\n return define({\n knob: {\n 'accent-h': String(knobs.accent.h),\n 'accent-c': String(knobs.accent.c),\n 'accent-l': knobs.accent.l,\n 'accent-c-dark': num(knobs.accent.dark?.c ?? Math.min(0.4, knobs.accent.c + 0.03)),\n 'accent-l-dark': knobs.accent.dark?.l ?? '70%',\n 'secondary-shift': String(knobs.secondaryHueShift ?? 60),\n 'tertiary-shift': String(knobs.tertiaryHueShift ?? -90),\n 'surface-c': String(surfaceSaturation),\n 'surface-c-dark': num(surfaceSaturation * (4 / 3)),\n 'surface-contrast': knobs.surfaceContrast ?? '65%',\n 'contrast-factor': String(knobs.contrastFactor ?? 1),\n 'base-l': '97.5%',\n 'base-l-dark': '22%',\n 'success-h': String(knobs.feedback?.success ?? 145),\n 'warning-h': String(knobs.feedback?.warning ?? 75),\n 'error-h': String(knobs.feedback?.error ?? 25),\n 'info-h': String(knobs.feedback?.info ?? 245),\n },\n hue: {\n accent: v('knob', 'accent-h'),\n secondary: `calc(${v('knob', 'accent-h')} + ${v('knob', 'secondary-shift')})`,\n tertiary: `calc(${v('knob', 'accent-h')} + ${v('knob', 'tertiary-shift')})`,\n neutral: v('hue', 'accent'),\n },\n surface: {\n base: ld(\n `oklch(${v('knob', 'base-l')} calc(${surfaceC} * 0.9) ${neutral})`,\n `oklch(${v('knob', 'base-l-dark')} calc(${surfaceCDark} * 0.9) ${neutral})`,\n ),\n // Each step keeps about the base's chroma, so a sidebar, a panel and\n // the page read as one color at a few lightnesses: one with less reads\n // grey on the page, one with more reads as another, bluer color.\n muted: surfaceStep([-0.04, 1.2], [-0.03, 1.05]),\n subtle: surfaceStep([-0.025, 1.15], [-0.015, 1.05]),\n default: surfaceStep([-0.055, 1.25], [0.045, 1.1]),\n overt: surfaceStep([-0.31, 2.25], [0.125, 1.2]),\n // The deepest of the page's color in both schemes: under a dialog's\n // backdrop, a veil of it darkens the page; it was near-white in a dark one.\n bedrock: ld(\n `oklch(8% calc(${surfaceC} * 1.2) ${neutral})`,\n `oklch(6% calc(${surfaceCDark} * 1.2) ${neutral})`,\n ),\n },\n text: {\n default: text([20, 2], [88, 0.8]),\n muted: text([45, 1.5], [65, 1.2]),\n subtle: text([35, 1.8], [75, 1]),\n overt: text([10, 2.2], [95, 0.6]),\n link: shift(accent, 0.1, 0.05),\n 'link-hover': shift(v('text', 'link'), -0.1, 0),\n },\n // Steps from the base, as the surfaces are: darker in a light scheme,\n // lighter in a dark one, and in the base's own hue with a little more of\n // its chroma, which a thin line needs to read as the page's color. Text mixed into the base, as they were, came out grey on a\n // tinted page: the text is near-neutral, so the mix lost the tint.\n outline: {\n subtle: ld(scale(base, -0.07, 1.3), scale(base, 0.065, 1.25)),\n default: ld(scale(base, -0.13, 1.4), scale(base, 0.12, 1.35)),\n overt: ld(scale(base, -0.27, 1.6), scale(base, 0.23, 1.5)),\n // The accent as it is: darker and more saturated, the ring was the\n // harshest color on the page.\n focus: accent,\n },\n accent: family(\n 'accent',\n ld(\n `oklch(${v('knob', 'accent-l')} ${v('knob', 'accent-c')} ${v('hue', 'accent')})`,\n `oklch(${v('knob', 'accent-l-dark')} ${v('knob', 'accent-c-dark')} ${v('hue', 'accent')})`,\n ),\n ),\n secondary: family('secondary', rehue(accent, v('hue', 'secondary'))),\n tertiary: family('tertiary', rehue(accent, v('hue', 'tertiary'))),\n // A near-black of the neutral hue: faint on a light surface, and denser\n // on a dark one, where a light shadow would read as a glow.\n shadow: {\n color: ld(\n `oklch(25% calc(${surfaceC} * 2) ${neutral} / 0.14)`,\n `oklch(5% calc(${surfaceCDark} * 2) ${neutral} / 0.6)`,\n ),\n },\n success: feedback('success', 55, 0.15, 64),\n warning: feedback('warning', 70, 0.15, 76),\n // Under 65% in the dark, where the text on a fill turns dark: on red that reads muddy.\n error: feedback('error', 60, 0.2, 64),\n info: feedback('info', 65, 0.15, 70),\n })\n}\n\nexport type OklchTheme = ReturnType<typeof oklch>\n","/**\n * `foldkit-mixins/theme`: the root export's `Theme` plus the page-level\n * pieces. `root` and `scoped` turn tokens into unlayered `:root` and\n * selector rules for `Style.stylesheet`; `tokens` is the shipped set of\n * non-color scales; `oklch` derives a whole palette from a few knobs.\n */\nimport * as Core from './theme/core.js'\nimport { oklch } from './theme/oklch.js'\nimport { root, scoped } from './theme/root.js'\nimport { breakpointWidths, inContainer, tokens } from './theme/tokens.js'\n\nexport { compose, define, lightDark, ref, variables, VAR_PREFIX } from './theme/core.js'\nexport type { Refs, Theme as ThemeValue, ThemeTokens } from './theme/core.js'\nexport { root, scoped } from './theme/root.js'\nexport type { Overrides, RootOptions } from './theme/root.js'\nexport { breakpointWidths, inContainer, tokens } from './theme/tokens.js'\nexport type { Tokens } from './theme/tokens.js'\nexport { oklch } from './theme/oklch.js'\nexport type { OklchKnobs, OklchTheme } from './theme/oklch.js'\n\nexport const Theme = {\n ...Core.Theme,\n root,\n scoped,\n tokens,\n breakpointWidths,\n inContainer,\n oklch,\n} as const\n"],"mappings":";;;;;;;;;;;;AAqCA,MAAM,KAAK,OAAe,SAAiB,YAAY,MAAM,GAAG,KAAK;;AAErE,MAAM,OAAO,UAAkB,OAAO,OAAO,MAAM,QAAQ,CAAC,CAAC,CAAC;AAC9D,MAAM,MAAM,OAAe,SAAiB,cAAc,MAAM,IAAI,KAAK;AACzE,MAAM,UAAU,WAAmB,GAAG,SAAS,IAAI,MAAM,IAAI,GAAG,KAAK,IAAI,MAAM;;AAE/E,MAAM,QAAQ,OAAe,GAAW,MAAc,cAAc,MAAM,GAAG,EAAE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,CAAC;GAC5D,SAAS,GAAG,MAAM,MAAM,MAAO,GAAG,GAAG,MAAM,MAAM,KAAM,IAAI,CAAC;GAC5D,OAAO,GAAG,MAAM,MAAM,MAAO,GAAG,GAAG,MAAM,MAAM,KAAM,GAAG,CAAC;GAGzD,OAAO;EACT;EACA,QAAQ,OACN,UACA,GACE,SAAS,EAAE,QAAQ,UAAU,EAAE,GAAG,EAAE,QAAQ,UAAU,EAAE,GAAG,EAAE,OAAO,QAAQ,EAAE,IAC9E,SAAS,EAAE,QAAQ,eAAe,EAAE,GAAG,EAAE,QAAQ,eAAe,EAAE,GAAG,EAAE,OAAO,QAAQ,EAAE,EAC1F,CACF;EACA,WAAW,OAAO,aAAa,MAAM,QAAQ,EAAE,OAAO,WAAW,CAAC,CAAC;EACnE,UAAU,OAAO,YAAY,MAAM,QAAQ,EAAE,OAAO,UAAU,CAAC,CAAC;EAGhE,QAAQ,EACN,OAAO,GACL,kBAAkB,SAAS,QAAQ,QAAQ,WAC3C,iBAAiB,aAAa,QAAQ,QAAQ,QAChD,EACF;EACA,SAAS,SAAS,WAAW,IAAI,KAAM,EAAE;EACzC,SAAS,SAAS,WAAW,IAAI,KAAM,EAAE;EAEzC,OAAO,SAAS,SAAS,IAAI,IAAK,EAAE;EACpC,MAAM,SAAS,QAAQ,IAAI,KAAM,EAAE;CACrC,CAAC;AACH;;;;;;;;;ACzLA,MAAa,QAAQ;CACnB,GAAGA;CACH;CACA;CACA;CACA;CACA;CACA;AACF"}
|
|
@@ -2,22 +2,31 @@ import { T as DiagnosticError } from "./styleValue-Cj4YjgVB.mjs";
|
|
|
2
2
|
import { i as define } from "./core-IMVYU8JN.mjs";
|
|
3
3
|
//#region src/theme/tokens.ts
|
|
4
4
|
/**
|
|
5
|
-
* The non-color scales a design system shares across themes. Space
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* The non-color scales a design system shares across themes. Space, radius,
|
|
6
|
+
* and durations multiply by the `density`, `radius-factor`, and `motion`
|
|
7
|
+
* knobs, so a compact, a rounder, or a stiller theme is one override
|
|
8
|
+
* (`motion: '0'` stills every recipe transition; `prefers-reduced-motion`
|
|
9
|
+
* still wins through the reset). `shadow` is drawn in `shadow.color`,
|
|
8
10
|
* which a palette sets (`Theme.oklch` does, stronger in a dark scheme, where
|
|
9
|
-
* a shadow mixed from the text would glow); alone it falls back to black.
|
|
11
|
+
* a shadow mixed from the text would glow); alone it falls back to black.
|
|
12
|
+
* Every layer is mixed toward transparent by the `shadow-strength` knob, so
|
|
13
|
+
* one override dims the whole elevation system without touching its shapes.
|
|
14
|
+
* `breakpoint` is the record
|
|
10
15
|
* `Style.responsive` takes; `breakpointWidths` gives the same names as pixel
|
|
11
16
|
* thresholds for `foldkit-primitives/media` Breakpoints.
|
|
12
17
|
*/
|
|
13
18
|
const space = (rem) => `calc(${rem}rem * var(--fk-knob-density))`;
|
|
14
19
|
const radius = (px) => `calc(${px}px * var(--fk-knob-radius-factor))`;
|
|
20
|
+
const duration = (ms) => `calc(${ms}ms * var(--fk-knob-motion))`;
|
|
15
21
|
const shade = "var(--fk-shadow-color, oklch(0% 0 0 / 0.12))";
|
|
16
|
-
const
|
|
22
|
+
const strength = "var(--fk-knob-shadow-strength, 100%)";
|
|
23
|
+
const shadow = (...layers) => layers.map((layer) => `${layer} color-mix(in oklch, ${shade} ${strength}, transparent)`).join(", ");
|
|
17
24
|
const tokens = define({
|
|
18
25
|
knob: {
|
|
19
26
|
density: "1",
|
|
20
|
-
"radius-factor": "1"
|
|
27
|
+
"radius-factor": "1",
|
|
28
|
+
motion: "1",
|
|
29
|
+
"shadow-strength": "100%"
|
|
21
30
|
},
|
|
22
31
|
space: {
|
|
23
32
|
"3xs": space(.125),
|
|
@@ -66,8 +75,8 @@ const tokens = define({
|
|
|
66
75
|
bold: "700"
|
|
67
76
|
},
|
|
68
77
|
motion: {
|
|
69
|
-
fast:
|
|
70
|
-
normal:
|
|
78
|
+
fast: duration(150),
|
|
79
|
+
normal: duration(250),
|
|
71
80
|
ease: "ease-out"
|
|
72
81
|
},
|
|
73
82
|
border: {
|
|
@@ -79,8 +88,9 @@ const tokens = define({
|
|
|
79
88
|
xs: shadow("0 1px 2px 0"),
|
|
80
89
|
sm: shadow("0 1px 3px 0", "0 1px 2px -1px"),
|
|
81
90
|
md: shadow("0 4px 6px -1px", "0 2px 4px -2px"),
|
|
82
|
-
lg: shadow("0
|
|
83
|
-
xl: shadow("0
|
|
91
|
+
lg: shadow("0 12px 28px -8px", "0 4px 8px -4px"),
|
|
92
|
+
xl: shadow("0 24px 48px -12px", "0 8px 16px -8px"),
|
|
93
|
+
"2xl": shadow("0 32px 64px -16px", "0 12px 24px -12px"),
|
|
84
94
|
inset: shadow("inset 0 2px 4px 0")
|
|
85
95
|
},
|
|
86
96
|
breakpoint: {
|
|
@@ -126,4 +136,4 @@ const inContainer = (name, breakpoints) => Object.freeze(Object.fromEntries(Obje
|
|
|
126
136
|
//#endregion
|
|
127
137
|
export { inContainer as n, tokens as r, breakpointWidths as t };
|
|
128
138
|
|
|
129
|
-
//# sourceMappingURL=tokens-
|
|
139
|
+
//# sourceMappingURL=tokens-B3i8bXZp.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens-B3i8bXZp.mjs","names":[],"sources":["../src/theme/tokens.ts"],"sourcesContent":["/**\n * The non-color scales a design system shares across themes. Space, radius,\n * and durations multiply by the `density`, `radius-factor`, and `motion`\n * knobs, so a compact, a rounder, or a stiller theme is one override\n * (`motion: '0'` stills every recipe transition; `prefers-reduced-motion`\n * still wins through the reset). `shadow` is drawn in `shadow.color`,\n * which a palette sets (`Theme.oklch` does, stronger in a dark scheme, where\n * a shadow mixed from the text would glow); alone it falls back to black.\n * Every layer is mixed toward transparent by the `shadow-strength` knob, so\n * one override dims the whole elevation system without touching its shapes.\n * `breakpoint` is the record\n * `Style.responsive` takes; `breakpointWidths` gives the same names as pixel\n * thresholds for `foldkit-primitives/media` Breakpoints.\n */\nimport { DiagnosticError } from '../diagnostics.js'\nimport { define } from './core.js'\n\nconst space = (rem: number) => `calc(${rem}rem * var(--fk-knob-density))`\nconst radius = (px: number) => `calc(${px}px * var(--fk-knob-radius-factor))`\nconst duration = (ms: number) => `calc(${ms}ms * var(--fk-knob-motion))`\nconst shade = 'var(--fk-shadow-color, oklch(0% 0 0 / 0.12))'\nconst strength = 'var(--fk-knob-shadow-strength, 100%)'\nconst shadow = (...layers: ReadonlyArray<string>) =>\n layers.map(layer => `${layer} color-mix(in oklch, ${shade} ${strength}, transparent)`).join(', ')\n\nexport const tokens = define({\n knob: { density: '1', 'radius-factor': '1', motion: '1', 'shadow-strength': '100%' },\n space: {\n '3xs': space(0.125),\n '2xs': space(0.25),\n xs: space(0.5),\n sm: space(0.75),\n md: space(1),\n lg: space(1.5),\n xl: space(2),\n '2xl': space(3),\n '3xl': space(4),\n },\n radius: {\n xs: radius(2),\n sm: radius(3),\n md: radius(6),\n lg: radius(8),\n xl: radius(12),\n full: '9999px',\n },\n font: { body: 'system-ui, sans-serif', heading: 'inherit', mono: 'ui-monospace, monospace' },\n size: {\n xs: '0.75rem',\n sm: '0.875rem',\n md: '1rem',\n lg: '1.125rem',\n xl: '1.25rem',\n '2xl': '1.5rem',\n '3xl': '1.875rem',\n '4xl': '2.25rem',\n },\n leading: { tight: '1.2', snug: '1.375', normal: '1.5', relaxed: '1.6' },\n weight: { normal: '400', medium: '500', semibold: '600', bold: '700' },\n motion: { fast: duration(150), normal: duration(250), ease: 'ease-out' },\n border: { thin: '1px', thick: '2px', heavy: '3px' },\n // Raised a little to a lot: a pressed control, a lifted cell, a menu, a\n // dialog. Each step is a tight contact layer plus a wide ambient one, so\n // large surfaces diffuse instead of ringing; `2xl` is the modal step.\n shadow: {\n xs: shadow('0 1px 2px 0'),\n sm: shadow('0 1px 3px 0', '0 1px 2px -1px'),\n md: shadow('0 4px 6px -1px', '0 2px 4px -2px'),\n lg: shadow('0 12px 28px -8px', '0 4px 8px -4px'),\n xl: shadow('0 24px 48px -12px', '0 8px 16px -8px'),\n '2xl': shadow('0 32px 64px -16px', '0 12px 24px -12px'),\n inset: shadow('inset 0 2px 4px 0'),\n },\n breakpoint: {\n sm: '(min-width: 40rem)',\n md: '(min-width: 48rem)',\n lg: '(min-width: 64rem)',\n xl: '(min-width: 80rem)',\n },\n})\n\nexport type Tokens = typeof tokens\n\n// A plain `min-width`, of the window or of a named container.\nconst MIN_WIDTH = /^(?:@container\\s+[\\w-]+\\s+)?\\(min-width:\\s*(\\d+(?:\\.\\d+)?)(rem|px)\\)$/\n\n/**\n * Each breakpoint query's `min-width` in pixels (rem at 16), so CSS and the\n * Model agree on what `md` means. A query that is not a plain `min-width`\n * is refused: it has no single threshold. A container's is its container's.\n */\nexport const breakpointWidths = (theme: {\n readonly breakpoint: { readonly [name: string]: string }\n}): Readonly<Record<string, number>> => {\n const widths: Record<string, number> = {}\n for (const [name, query] of Object.entries(theme.breakpoint)) {\n const match = MIN_WIDTH.exec(query)\n if (match === null) {\n throw new DiagnosticError({\n source: 'theme',\n code: 'theme:unparseable-breakpoint',\n severity: 'error',\n message: `Breakpoint \"${name}\" is \"${query}\", not a \"(min-width: <rem|px>)\" query`,\n details: { name, query },\n })\n }\n const amount = Number(match[1])\n widths[name] = match[2] === 'rem' ? amount * 16 : amount\n }\n return Object.freeze(widths)\n}\n\n/**\n * The same breakpoints measured on a named container rather than the window:\n * `Theme.inContainer('page', Theme.tokens.breakpoint)` gives `md` as\n * `'@container page (min-width: 48rem)'`, for `Style.responsive` and a\n * responsive look. An element must be that container (`container: page /\n * inline-size`) for them to match.\n */\nexport const inContainer = <Breakpoints extends Readonly<Record<string, string>>>(\n name: string,\n breakpoints: Breakpoints,\n): { readonly [K in keyof Breakpoints]: string } =>\n Object.freeze(\n Object.fromEntries(\n Object.entries(breakpoints).map(([at, query]) => [at, `@container ${name} ${query}`]),\n ),\n ) as { readonly [K in keyof Breakpoints]: string }\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAM,S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gB;EAC1C,IAAI,OAAO,kBAAkB,gBAAgB;EAC7C,IAAI,OAAO,oBAAoB,gBAAgB;EAC/C,IAAI,OAAO,qBAAqB,iBAAiB;EACjD,OAAO,OAAO,qBAAqB,mBAAmB;EACtD,OAAO,OAAO,mBAAmB;CACnC;CACA,YAAY;EACV,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;CACN;AACF,CAAC;AAKD,MAAM,YAAY;;;;;;AAOlB,MAAa,oBAAoB,UAEO;CACtC,MAAM,SAAiC,CAAC;CACxC,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,MAAM,UAAU,GAAG;EAC5D,MAAM,QAAQ,UAAU,KAAK,KAAK;EAClC,IAAI,UAAU,MACZ,MAAM,IAAI,gBAAgB;GACxB,QAAQ;GACR,MAAM;GACN,UAAU;GACV,SAAS,eAAe,KAAK,QAAQ,MAAM;GAC3C,SAAS;IAAE;IAAM;GAAM;EACzB,CAAC;EAEH,MAAM,SAAS,OAAO,MAAM,EAAE;EAC9B,OAAO,QAAQ,MAAM,OAAO,QAAQ,SAAS,KAAK;CACpD;CACA,OAAO,OAAO,OAAO,MAAM;AAC7B;;;;;;;;AASA,MAAa,eACX,MACA,gBAEA,OAAO,OACL,OAAO,YACL,OAAO,QAAQ,WAAW,CAAC,CAAC,KAAK,CAAC,IAAI,WAAW,CAAC,IAAI,cAAc,KAAK,GAAG,OAAO,CAAC,CACtF,CACF"}
|
|
@@ -3,6 +3,8 @@ declare const tokens: Readonly<{
|
|
|
3
3
|
knob: {
|
|
4
4
|
density: string;
|
|
5
5
|
'radius-factor': string;
|
|
6
|
+
motion: string;
|
|
7
|
+
'shadow-strength': string;
|
|
6
8
|
};
|
|
7
9
|
space: {
|
|
8
10
|
'3xs': string;
|
|
@@ -66,6 +68,7 @@ declare const tokens: Readonly<{
|
|
|
66
68
|
md: string;
|
|
67
69
|
lg: string;
|
|
68
70
|
xl: string;
|
|
71
|
+
'2xl': string;
|
|
69
72
|
inset: string;
|
|
70
73
|
};
|
|
71
74
|
breakpoint: {
|
|
@@ -96,4 +99,4 @@ declare const breakpointWidths: (theme: {
|
|
|
96
99
|
declare const inContainer: <Breakpoints extends Readonly<Record<string, string>>>(name: string, breakpoints: Breakpoints) => { readonly [K in keyof Breakpoints]: string; };
|
|
97
100
|
//#endregion
|
|
98
101
|
export { tokens as i, breakpointWidths as n, inContainer as r, Tokens as t };
|
|
99
|
-
//# sourceMappingURL=tokens-
|
|
102
|
+
//# sourceMappingURL=tokens-BaLmrfbp.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens-BaLmrfbp.d.mts","names":[],"sources":["../src/theme/tokens.ts"],"mappings":";cAyBa,QAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAwDP,gBAAgB;;;;;;cAUf,mBAAoB;WACtB;cAAwB;;MAC/B,SAAS;;;;;;;;cA0BA,cAAe,oBAAoB,SAAS,yBACvD,cACA,aAAa,4BACA,WAAW"}
|
package/dist/utilities.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { o as StyleValue } from "./styleValue-BavTe9MZ.mjs";
|
|
2
|
-
import { t as Tokens } from "./tokens-
|
|
3
|
-
import { n as OklchTheme } from "./oklch-
|
|
2
|
+
import { t as Tokens } from "./tokens-BaLmrfbp.mjs";
|
|
3
|
+
import { n as OklchTheme } from "./oklch-CLKxbFpD.mjs";
|
|
4
4
|
//#region src/utilities.d.ts
|
|
5
5
|
/** A space step, or none. */
|
|
6
6
|
export type Space = (keyof Tokens['space'] & string) | '0';
|
|
@@ -66,6 +66,8 @@ export declare const Utilities: {
|
|
|
66
66
|
readonly uppercase: StyleValue;
|
|
67
67
|
/** One line, cut with an ellipsis. */
|
|
68
68
|
readonly truncate: StyleValue;
|
|
69
|
+
/** Visually hidden but announced: screen-reader-only content. */
|
|
70
|
+
readonly srOnly: StyleValue;
|
|
69
71
|
readonly pointer: StyleValue;
|
|
70
72
|
readonly selectNone: StyleValue;
|
|
71
73
|
};
|
package/dist/utilities.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ as self } from "./styleValue-Cj4YjgVB.mjs";
|
|
2
2
|
import { n as VAR_PREFIX, o as ref } from "./core-IMVYU8JN.mjs";
|
|
3
|
-
import { r as tokens } from "./tokens-
|
|
3
|
+
import { r as tokens } from "./tokens-B3i8bXZp.mjs";
|
|
4
4
|
//#region src/utilities.ts
|
|
5
5
|
/**
|
|
6
6
|
* `foldkit-mixins/utilities`: one-idea pieces over the shipped scales, so
|
|
@@ -81,6 +81,18 @@ const Utilities = {
|
|
|
81
81
|
textOverflow: "ellipsis",
|
|
82
82
|
whiteSpace: "nowrap"
|
|
83
83
|
}),
|
|
84
|
+
/** Visually hidden but announced: screen-reader-only content. */
|
|
85
|
+
srOnly: self({
|
|
86
|
+
position: "absolute",
|
|
87
|
+
width: "1px",
|
|
88
|
+
height: "1px",
|
|
89
|
+
padding: "0",
|
|
90
|
+
margin: "-1px",
|
|
91
|
+
overflow: "hidden",
|
|
92
|
+
clip: "rect(0, 0, 0, 0)",
|
|
93
|
+
whiteSpace: "nowrap",
|
|
94
|
+
border: "0"
|
|
95
|
+
}),
|
|
84
96
|
pointer: self({ cursor: "pointer" }),
|
|
85
97
|
selectNone: self({ userSelect: "none" })
|
|
86
98
|
};
|
package/dist/utilities.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.mjs","names":[],"sources":["../src/utilities.ts"],"sourcesContent":["/**\n * `foldkit-mixins/utilities`: one-idea pieces over the shipped scales, so\n * `Utilities.p('md')` is `padding: var(--fk-space-md)`. A step is a token name\n * of `Theme.tokens` (and a color a token name of `Theme.oklch`), so a step the\n * scale lacks is a type error and the value still follows the `density` knob\n * and a theme's overrides: the theme stays the one source of truth for sizes.\n *\n * Each is a rule on the element (`Style.self`), unlayered like the other\n * subpaths' pieces, so it takes the layer of the style it is composed into and\n * a plain declaration beside it wins per property. Compose them like any piece:\n * `[U.flex, U.gap('sm'), { color: t.text.muted }]`.\n */\nimport { self, type StyleValue } from './styleValue.js'\nimport { ref, VAR_PREFIX } from './theme/core.js'\nimport type { OklchTheme } from './theme/oklch.js'\nimport { tokens, type Tokens } from './theme/tokens.js'\n\nconst t = ref(tokens)\n\n/** A space step, or none. */\nexport type Space = (keyof Tokens['space'] & string) | '0'\n/** A margin step: a space step, or `auto`. */\nexport type Margin = Space | 'auto'\n\ntype Palette = Omit<OklchTheme, 'knob' | 'hue'>\n/** A `Theme.oklch` color as `group.name`: `'surface.base'`, `'text.muted'`, `'accent.on-fill'`. */\nexport type ColorName = {\n readonly [G in keyof Palette & string]: `${G}.${keyof Palette[G] & string}`\n}[keyof Palette & string]\n\nconst space = (step: Margin): string => (step === '0' || step === 'auto' ? step : t.space[step])\n\nconst colorRef = (name: ColorName): string => `var(${VAR_PREFIX}-${name.replace('.', '-')})`\n\nconst alignments = {\n start: 'flex-start',\n center: 'center',\n end: 'flex-end',\n stretch: 'stretch',\n baseline: 'baseline',\n} as const\n\nconst justifications = {\n start: 'flex-start',\n center: 'center',\n end: 'flex-end',\n between: 'space-between',\n around: 'space-around',\n evenly: 'space-evenly',\n} as const\n\nexport const Utilities = {\n /** `padding` on every side. */\n p: (step: Space): StyleValue => self({ padding: space(step) }),\n /** `padding-inline`. */\n px: (step: Space): StyleValue => self({ paddingInline: space(step) }),\n /** `padding-block`. */\n py: (step: Space): StyleValue => self({ paddingBlock: space(step) }),\n /** `margin` on every side. */\n m: (step: Margin): StyleValue => self({ margin: space(step) }),\n /** `margin-inline`; `mx('auto')` centers a block. */\n mx: (step: Margin): StyleValue => self({ marginInline: space(step) }),\n /** `margin-block`. */\n my: (step: Margin): StyleValue => self({ marginBlock: space(step) }),\n /** `gap` between flex or grid children. */\n gap: (step: Space): StyleValue => self({ gap: space(step) }),\n /** `font-size` from the size scale. */\n text: (size: keyof Tokens['size'] & string): StyleValue => self({ fontSize: t.size[size] }),\n /** `font-weight` from the weight scale. */\n font: (weight: keyof Tokens['weight'] & string): StyleValue =>\n self({ fontWeight: t.weight[weight] }),\n /** `line-height` from the leading scale. */\n leading: (name: keyof Tokens['leading'] & string): StyleValue =>\n self({ lineHeight: t.leading[name] }),\n /** `border-radius` from the radius scale. */\n rounded: (radius: keyof Tokens['radius'] & string): StyleValue =>\n self({ borderRadius: t.radius[radius] }),\n /** Text `color` from the palette. */\n color: (name: ColorName): StyleValue => self({ color: colorRef(name) }),\n /** `background` from the palette. */\n bg: (name: ColorName): StyleValue => self({ background: colorRef(name) }),\n /** `align-items` of a flex or grid container. */\n items: (align: keyof typeof alignments): StyleValue => self({ alignItems: alignments[align] }),\n /** `justify-content` of a flex or grid container. */\n justify: (justify: keyof typeof justifications): StyleValue =>\n self({ justifyContent: justifications[justify] }),\n flex: self({ display: 'flex' }),\n /** A flex column. */\n column: self({ display: 'flex', flexDirection: 'column' }),\n grid: self({ display: 'grid' }),\n block: self({ display: 'block' }),\n hidden: self({ display: 'none' }),\n wFull: self({ width: '100%' }),\n textCenter: self({ textAlign: 'center' }),\n uppercase: self({ textTransform: 'uppercase' }),\n /** One line, cut with an ellipsis. */\n truncate: self({ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }),\n pointer: self({ cursor: 'pointer' }),\n selectNone: self({ userSelect: 'none' }),\n} as const\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,MAAM,IAAI,IAAI,MAAM;AAapB,MAAM,SAAS,SAA0B,SAAS,OAAO,SAAS,SAAS,OAAO,EAAE,MAAM;AAE1F,MAAM,YAAY,SAA4B,OAAO,WAAW,GAAG,KAAK,QAAQ,KAAK,GAAG,EAAE;AAE1F,MAAM,aAAa;CACjB,OAAO;CACP,QAAQ;CACR,KAAK;CACL,SAAS;CACT,UAAU;AACZ;AAEA,MAAM,iBAAiB;CACrB,OAAO;CACP,QAAQ;CACR,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CAAC;CAChC,OAAO,KAAK,EAAE,OAAO,OAAO,CAAC;CAC7B,YAAY,KAAK,EAAE,WAAW,SAAS,CAAC;CACxC,WAAW,KAAK,EAAE,eAAe,YAAY,CAAC;;CAE9C,UAAU,KAAK;EAAE,UAAU;EAAU,cAAc;EAAY,YAAY;CAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"utilities.mjs","names":[],"sources":["../src/utilities.ts"],"sourcesContent":["/**\n * `foldkit-mixins/utilities`: one-idea pieces over the shipped scales, so\n * `Utilities.p('md')` is `padding: var(--fk-space-md)`. A step is a token name\n * of `Theme.tokens` (and a color a token name of `Theme.oklch`), so a step the\n * scale lacks is a type error and the value still follows the `density` knob\n * and a theme's overrides: the theme stays the one source of truth for sizes.\n *\n * Each is a rule on the element (`Style.self`), unlayered like the other\n * subpaths' pieces, so it takes the layer of the style it is composed into and\n * a plain declaration beside it wins per property. Compose them like any piece:\n * `[U.flex, U.gap('sm'), { color: t.text.muted }]`.\n */\nimport { self, type StyleValue } from './styleValue.js'\nimport { ref, VAR_PREFIX } from './theme/core.js'\nimport type { OklchTheme } from './theme/oklch.js'\nimport { tokens, type Tokens } from './theme/tokens.js'\n\nconst t = ref(tokens)\n\n/** A space step, or none. */\nexport type Space = (keyof Tokens['space'] & string) | '0'\n/** A margin step: a space step, or `auto`. */\nexport type Margin = Space | 'auto'\n\ntype Palette = Omit<OklchTheme, 'knob' | 'hue'>\n/** A `Theme.oklch` color as `group.name`: `'surface.base'`, `'text.muted'`, `'accent.on-fill'`. */\nexport type ColorName = {\n readonly [G in keyof Palette & string]: `${G}.${keyof Palette[G] & string}`\n}[keyof Palette & string]\n\nconst space = (step: Margin): string => (step === '0' || step === 'auto' ? step : t.space[step])\n\nconst colorRef = (name: ColorName): string => `var(${VAR_PREFIX}-${name.replace('.', '-')})`\n\nconst alignments = {\n start: 'flex-start',\n center: 'center',\n end: 'flex-end',\n stretch: 'stretch',\n baseline: 'baseline',\n} as const\n\nconst justifications = {\n start: 'flex-start',\n center: 'center',\n end: 'flex-end',\n between: 'space-between',\n around: 'space-around',\n evenly: 'space-evenly',\n} as const\n\nexport const Utilities = {\n /** `padding` on every side. */\n p: (step: Space): StyleValue => self({ padding: space(step) }),\n /** `padding-inline`. */\n px: (step: Space): StyleValue => self({ paddingInline: space(step) }),\n /** `padding-block`. */\n py: (step: Space): StyleValue => self({ paddingBlock: space(step) }),\n /** `margin` on every side. */\n m: (step: Margin): StyleValue => self({ margin: space(step) }),\n /** `margin-inline`; `mx('auto')` centers a block. */\n mx: (step: Margin): StyleValue => self({ marginInline: space(step) }),\n /** `margin-block`. */\n my: (step: Margin): StyleValue => self({ marginBlock: space(step) }),\n /** `gap` between flex or grid children. */\n gap: (step: Space): StyleValue => self({ gap: space(step) }),\n /** `font-size` from the size scale. */\n text: (size: keyof Tokens['size'] & string): StyleValue => self({ fontSize: t.size[size] }),\n /** `font-weight` from the weight scale. */\n font: (weight: keyof Tokens['weight'] & string): StyleValue =>\n self({ fontWeight: t.weight[weight] }),\n /** `line-height` from the leading scale. */\n leading: (name: keyof Tokens['leading'] & string): StyleValue =>\n self({ lineHeight: t.leading[name] }),\n /** `border-radius` from the radius scale. */\n rounded: (radius: keyof Tokens['radius'] & string): StyleValue =>\n self({ borderRadius: t.radius[radius] }),\n /** Text `color` from the palette. */\n color: (name: ColorName): StyleValue => self({ color: colorRef(name) }),\n /** `background` from the palette. */\n bg: (name: ColorName): StyleValue => self({ background: colorRef(name) }),\n /** `align-items` of a flex or grid container. */\n items: (align: keyof typeof alignments): StyleValue => self({ alignItems: alignments[align] }),\n /** `justify-content` of a flex or grid container. */\n justify: (justify: keyof typeof justifications): StyleValue =>\n self({ justifyContent: justifications[justify] }),\n flex: self({ display: 'flex' }),\n /** A flex column. */\n column: self({ display: 'flex', flexDirection: 'column' }),\n grid: self({ display: 'grid' }),\n block: self({ display: 'block' }),\n hidden: self({ display: 'none' }),\n wFull: self({ width: '100%' }),\n textCenter: self({ textAlign: 'center' }),\n uppercase: self({ textTransform: 'uppercase' }),\n /** One line, cut with an ellipsis. */\n truncate: self({ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }),\n /** Visually hidden but announced: screen-reader-only content. */\n srOnly: self({\n position: 'absolute',\n width: '1px',\n height: '1px',\n padding: '0',\n margin: '-1px',\n overflow: 'hidden',\n clip: 'rect(0, 0, 0, 0)',\n whiteSpace: 'nowrap',\n border: '0',\n }),\n pointer: self({ cursor: 'pointer' }),\n selectNone: self({ userSelect: 'none' }),\n} as const\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,MAAM,IAAI,IAAI,MAAM;AAapB,MAAM,SAAS,SAA0B,SAAS,OAAO,SAAS,SAAS,OAAO,EAAE,MAAM;AAE1F,MAAM,YAAY,SAA4B,OAAO,WAAW,GAAG,KAAK,QAAQ,KAAK,GAAG,EAAE;AAE1F,MAAM,aAAa;CACjB,OAAO;CACP,QAAQ;CACR,KAAK;CACL,SAAS;CACT,UAAU;AACZ;AAEA,MAAM,iBAAiB;CACrB,OAAO;CACP,QAAQ;CACR,KAAK;CACL,SAAS;CACT,QAAQ;CACR,QAAQ;AACV;AAEA,MAAa,YAAY;;CAEvB,IAAI,SAA4B,KAAK,EAAE,SAAS,MAAM,IAAI,EAAE,CAAC;;CAE7D,KAAK,SAA4B,KAAK,EAAE,eAAe,MAAM,IAAI,EAAE,CAAC;;CAEpE,KAAK,SAA4B,KAAK,EAAE,cAAc,MAAM,IAAI,EAAE,CAAC;;CAEnE,IAAI,SAA6B,KAAK,EAAE,QAAQ,MAAM,IAAI,EAAE,CAAC;;CAE7D,KAAK,SAA6B,KAAK,EAAE,cAAc,MAAM,IAAI,EAAE,CAAC;;CAEpE,KAAK,SAA6B,KAAK,EAAE,aAAa,MAAM,IAAI,EAAE,CAAC;;CAEnE,MAAM,SAA4B,KAAK,EAAE,KAAK,MAAM,IAAI,EAAE,CAAC;;CAE3D,OAAO,SAAoD,KAAK,EAAE,UAAU,EAAE,KAAK,MAAM,CAAC;;CAE1F,OAAO,WACL,KAAK,EAAE,YAAY,EAAE,OAAO,QAAQ,CAAC;;CAEvC,UAAU,SACR,KAAK,EAAE,YAAY,EAAE,QAAQ,MAAM,CAAC;;CAEtC,UAAU,WACR,KAAK,EAAE,cAAc,EAAE,OAAO,QAAQ,CAAC;;CAEzC,QAAQ,SAAgC,KAAK,EAAE,OAAO,SAAS,IAAI,EAAE,CAAC;;CAEtE,KAAK,SAAgC,KAAK,EAAE,YAAY,SAAS,IAAI,EAAE,CAAC;;CAExE,QAAQ,UAA+C,KAAK,EAAE,YAAY,WAAW,OAAO,CAAC;;CAE7F,UAAU,YACR,KAAK,EAAE,gBAAgB,eAAe,SAAS,CAAC;CAClD,MAAM,KAAK,EAAE,SAAS,OAAO,CAAC;;CAE9B,QAAQ,KAAK;EAAE,SAAS;EAAQ,eAAe;CAAS,CAAC;CACzD,MAAM,KAAK,EAAE,SAAS,OAAO,CAAC;CAC9B,OAAO,KAAK,EAAE,SAAS,QAAQ,CAAC;CAChC,QAAQ,KAAK,EAAE,SAAS,OAAO,CAAC;CAChC,OAAO,KAAK,EAAE,OAAO,OAAO,CAAC;CAC7B,YAAY,KAAK,EAAE,WAAW,SAAS,CAAC;CACxC,WAAW,KAAK,EAAE,eAAe,YAAY,CAAC;;CAE9C,UAAU,KAAK;EAAE,UAAU;EAAU,cAAc;EAAY,YAAY;CAAS,CAAC;;CAErF,QAAQ,KAAK;EACX,UAAU;EACV,OAAO;EACP,QAAQ;EACR,SAAS;EACT,QAAQ;EACR,UAAU;EACV,MAAM;EACN,YAAY;EACZ,QAAQ;CACV,CAAC;CACD,SAAS,KAAK,EAAE,QAAQ,UAAU,CAAC;CACnC,YAAY,KAAK,EAAE,YAAY,OAAO,CAAC;AACzC"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tokens-BkWHtxjY.mjs","names":[],"sources":["../src/theme/tokens.ts"],"sourcesContent":["/**\n * The non-color scales a design system shares across themes. Space and\n * radius multiply by the `density` and `radius-factor` knobs, so a compact\n * or a rounder theme is one override. `shadow` is drawn in `shadow.color`,\n * which a palette sets (`Theme.oklch` does, stronger in a dark scheme, where\n * a shadow mixed from the text would glow); alone it falls back to black. `breakpoint` is the record\n * `Style.responsive` takes; `breakpointWidths` gives the same names as pixel\n * thresholds for `foldkit-primitives/media` Breakpoints.\n */\nimport { DiagnosticError } from '../diagnostics.js'\nimport { define } from './core.js'\n\nconst space = (rem: number) => `calc(${rem}rem * var(--fk-knob-density))`\nconst radius = (px: number) => `calc(${px}px * var(--fk-knob-radius-factor))`\nconst shade = 'var(--fk-shadow-color, oklch(0% 0 0 / 0.12))'\nconst shadow = (...layers: ReadonlyArray<string>) =>\n layers.map(layer => `${layer} ${shade}`).join(', ')\n\nexport const tokens = define({\n knob: { density: '1', 'radius-factor': '1' },\n space: {\n '3xs': space(0.125),\n '2xs': space(0.25),\n xs: space(0.5),\n sm: space(0.75),\n md: space(1),\n lg: space(1.5),\n xl: space(2),\n '2xl': space(3),\n '3xl': space(4),\n },\n radius: {\n xs: radius(2),\n sm: radius(3),\n md: radius(6),\n lg: radius(8),\n xl: radius(12),\n full: '9999px',\n },\n font: { body: 'system-ui, sans-serif', heading: 'inherit', mono: 'ui-monospace, monospace' },\n size: {\n xs: '0.75rem',\n sm: '0.875rem',\n md: '1rem',\n lg: '1.125rem',\n xl: '1.25rem',\n '2xl': '1.5rem',\n '3xl': '1.875rem',\n '4xl': '2.25rem',\n },\n leading: { tight: '1.2', snug: '1.375', normal: '1.5', relaxed: '1.6' },\n weight: { normal: '400', medium: '500', semibold: '600', bold: '700' },\n motion: { fast: '150ms', normal: '250ms', ease: 'ease-out' },\n border: { thin: '1px', thick: '2px', heavy: '3px' },\n // Raised a little to a lot: a pressed control, a lifted cell, a menu, a dialog.\n shadow: {\n xs: shadow('0 1px 2px 0'),\n sm: shadow('0 1px 3px 0', '0 1px 2px -1px'),\n md: shadow('0 4px 6px -1px', '0 2px 4px -2px'),\n lg: shadow('0 10px 15px -3px', '0 4px 6px -4px'),\n xl: shadow('0 20px 25px -5px', '0 8px 10px -6px'),\n inset: shadow('inset 0 2px 4px 0'),\n },\n breakpoint: {\n sm: '(min-width: 40rem)',\n md: '(min-width: 48rem)',\n lg: '(min-width: 64rem)',\n xl: '(min-width: 80rem)',\n },\n})\n\nexport type Tokens = typeof tokens\n\n// A plain `min-width`, of the window or of a named container.\nconst MIN_WIDTH = /^(?:@container\\s+[\\w-]+\\s+)?\\(min-width:\\s*(\\d+(?:\\.\\d+)?)(rem|px)\\)$/\n\n/**\n * Each breakpoint query's `min-width` in pixels (rem at 16), so CSS and the\n * Model agree on what `md` means. A query that is not a plain `min-width`\n * is refused: it has no single threshold. A container's is its container's.\n */\nexport const breakpointWidths = (theme: {\n readonly breakpoint: { readonly [name: string]: string }\n}): Readonly<Record<string, number>> => {\n const widths: Record<string, number> = {}\n for (const [name, query] of Object.entries(theme.breakpoint)) {\n const match = MIN_WIDTH.exec(query)\n if (match === null) {\n throw new DiagnosticError({\n source: 'theme',\n code: 'theme:unparseable-breakpoint',\n severity: 'error',\n message: `Breakpoint \"${name}\" is \"${query}\", not a \"(min-width: <rem|px>)\" query`,\n details: { name, query },\n })\n }\n const amount = Number(match[1])\n widths[name] = match[2] === 'rem' ? amount * 16 : amount\n }\n return Object.freeze(widths)\n}\n\n/**\n * The same breakpoints measured on a named container rather than the window:\n * `Theme.inContainer('page', Theme.tokens.breakpoint)` gives `md` as\n * `'@container page (min-width: 48rem)'`, for `Style.responsive` and a\n * responsive look. An element must be that container (`container: page /\n * inline-size`) for them to match.\n */\nexport const inContainer = <Breakpoints extends Readonly<Record<string, string>>>(\n name: string,\n breakpoints: Breakpoints,\n): { readonly [K in keyof Breakpoints]: string } =>\n Object.freeze(\n Object.fromEntries(\n Object.entries(breakpoints).map(([at, query]) => [at, `@container ${name} ${query}`]),\n ),\n ) as { readonly [K in keyof Breakpoints]: string }\n"],"mappings":";;;;;;;;;;;;AAYA,MAAM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