foldkit-mixins 0.16.0 → 0.18.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 +53 -10
- package/dist/app.d.mts +1 -1
- package/dist/app.mjs +1 -1
- package/dist/{root-D_gJPXBw.mjs → root-CT_iUZvD.mjs} +34 -5
- package/dist/root-CT_iUZvD.mjs.map +1 -0
- package/dist/theme.d.mts +79 -4
- package/dist/theme.d.mts.map +1 -1
- package/dist/theme.mjs +78 -8
- package/dist/theme.mjs.map +1 -1
- package/dist/{themes-DKzh-mwX.d.mts → themes-DF2Spo6_.d.mts} +26 -3
- package/dist/themes-DF2Spo6_.d.mts.map +1 -0
- package/dist/{tokens-P-zBWN9o.d.mts → tokens-C4tC1NFW.d.mts} +23 -2
- package/dist/tokens-C4tC1NFW.d.mts.map +1 -0
- package/dist/{tokens-BpnLFiKE.mjs → tokens-CkTT9DNd.mjs} +60 -3
- package/dist/tokens-CkTT9DNd.mjs.map +1 -0
- package/dist/utilities.d.mts +1 -1
- package/dist/utilities.mjs +1 -1
- package/package.json +1 -1
- package/dist/root-D_gJPXBw.mjs.map +0 -1
- package/dist/themes-DKzh-mwX.d.mts.map +0 -1
- package/dist/tokens-BpnLFiKE.mjs.map +0 -1
- package/dist/tokens-P-zBWN9o.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -276,8 +276,9 @@ one.
|
|
|
276
276
|
| `Theme.lightDark(light, dark)` / `Theme.compose(base, over)` | a token that follows the color scheme with CSS `light-dark()`; themes merged at definition time |
|
|
277
277
|
| `Theme.root(theme, { omit?, colorScheme? })` / `Theme.scoped(theme, selector, overrides)` | from `foldkit-mixins/theme`: tokens as `:root` custom properties, or as overrides under a selector; unlayered global pieces for `Style.stylesheet` |
|
|
278
278
|
| `Theme.schemeScript(key?)` / `Theme.chooseScheme(scheme, key?)` / `Theme.currentScheme()` | from `foldkit-mixins/theme`: a head script applying a kept `light` or `dark` before the first paint; a Command's Effect that applies and keeps a choice; the scheme applied now |
|
|
279
|
+
| `Theme.knobScript({ key?, selector? })` / `Theme.chooseKnobs(theme, { base, key?, selector? })` | from `foldkit-mixins/theme`: a head script applying kept knob variables before the first paint; a Command's Effect that applies `theme`'s knobs that differ from `base` and keeps them |
|
|
279
280
|
| `Theme.make(values)` / `Theme.standard(theme?)` | from `foldkit-mixins/theme`: a theme, the typed knob values it changes (`Knobs.standard`); every shipped token with a theme's knobs, for `Theme.root` |
|
|
280
|
-
| `Theme.tokens` / `Theme.breakpointWidths(theme)` | from `foldkit-mixins/theme`: the shipped spacing, type, radius, motion, width, border, shadow and breakpoint scales, and `safe` (what a notch or the home indicator takes from each screen edge, `env(safe-area-inset-*)`, 0 unless the viewport meta says `viewport-fit=cover`); the breakpoints as pixel widths for `foldkit-primitives/media` |
|
|
281
|
+
| `Theme.tokens` / `Theme.breakpointWidths(theme)` | from `foldkit-mixins/theme`: the shipped spacing, type, radius, motion, width, border, shadow and breakpoint scales, `icon` (the masks the components draw their own icons with, Lucide's by default; an application's pack is `foldkit-mixins-ui`'s `Icons.tokens(pack)`, passed as its own tokens), and `safe` (what a notch or the home indicator takes from each screen edge, `env(safe-area-inset-*)`, 0 unless the viewport meta says `viewport-fit=cover`); the breakpoints as pixel widths for `foldkit-primitives/media` |
|
|
281
282
|
| `Layers.define(names)` / `Layers.standard` | cascade layers as a value: `names`, `declare` (the `@layer …;` statement as a global piece), `in(name, piece)` (a piece's unlayered rules and global CSS inside that layer; what is already layered keeps its layer; a piece wholly in another layer is `style:relayered`) and `layer(name)` (the placement `Style.forSlots(S)(pieces, { layer })` takes, so a slot style is compiled in that layer). A name outside the order is a type error. `standard` is `reset, tokens, theme, defaults, components, layouts, variants, utilities, app`; also under `foldkit-mixins/layers` |
|
|
282
283
|
| `Style.stylesheet(...)` | one `<style>` block from `NamedStyle`s and bare `StyleValue`s: the layer order hoisted first (two different orders is `style:conflicting-layer-order`), then global chunks, then scoped classes, deduplicated. Once an order is declared, a rule outside it is `style:unlayered-rule`, since it would beat every layer; keyframes, font faces and `@property` pass |
|
|
283
284
|
|
|
@@ -337,7 +338,8 @@ Beyond `self`, `pseudo`, `media`, `supports`, `container` and `nest`, the rule p
|
|
|
337
338
|
`foldkit-mixins/theme` extends the root `Theme` with the pieces a page ships. A theme is a typed
|
|
338
339
|
set of knob values: only what it changes, every other knob at its default.
|
|
339
340
|
`Theme.make` checks each value against its knob (`Knobs.standard`, grouped by concern: `accent`,
|
|
340
|
-
`surface`, `shape`, `type`, `motion`, `shadow`, `menu`, `feedback`, `code`,
|
|
341
|
+
`surface`, `state`, `shape`, `type`, `icon`, `motion`, `shadow`, `menu`, `feedback`, `code`,
|
|
342
|
+
`chart`, `scales`),
|
|
341
343
|
so a misspelt knob or a choice outside its options is a type error and a number out of its range
|
|
342
344
|
throws where the theme is made. A theme is `pipe`able: `Theme.set` changes some knobs, and
|
|
343
345
|
`Theme.describe` gives it a title and a description for a list of themes.
|
|
@@ -388,7 +390,13 @@ const Model = Schema.Struct({ theme: themes.Name })
|
|
|
388
390
|
The root declares the palette's derivations with the initial theme's knobs, and each other theme
|
|
389
391
|
writes only its knobs under `:root[data-theme="name"]`, the same element, where every token
|
|
390
392
|
re-derives from them. Which theme shows is the Model's fact (`themes.Name` decodes the field),
|
|
391
|
-
and `Themes.apply(themes, name)` is the Command's effect that shows it.
|
|
393
|
+
and `Themes.apply(themes, name)` is the Command's effect that shows it. To keep a reader's choice,
|
|
394
|
+
`Themes.choose(themes, name, key?)` shows it and keeps the name in `localStorage` (the initial
|
|
395
|
+
theme keeps nothing), and `Themes.script(themes, key?)` is the text of a head `<script>` that shows
|
|
396
|
+
the kept one before the first paint, on the attribute `apply` writes: a name no theme has, and
|
|
397
|
+
storage that throws, leave the initial theme. The Model's field still starts at the initial theme
|
|
398
|
+
on a static page, so restore it from the same key (`Mirror.kv`); on a page rendered per request,
|
|
399
|
+
read it from a cookie into the Model instead (see `foldkit-ssr`). A token resolves where it
|
|
392
400
|
is declared, so knobs set below the root change nothing derived from them there:
|
|
393
401
|
`Theme.scope(theme, '.marketing')` declares the derivations again under the selector, which
|
|
394
402
|
`Theme.scoped`'s token overrides do not. `AppStyle.make({ theme })` takes one theme, and its
|
|
@@ -426,14 +434,18 @@ at both ends, where a vivid near-white or near-black falls out of gamut; `wash-1
|
|
|
426
434
|
mix step 6 into `surface.base` at 8, 16, 28 and 44%, so a tinted ground follows the scheme and
|
|
427
435
|
the surface knobs. Each hue is a knob (`red-h`), and `scale-c` scales every step's chroma
|
|
428
436
|
(`--fk-blue-wash-2`, `ref.blue['6']`). The `popup` group is a menu's
|
|
429
|
-
panel (`surface`, `ink`, `blur`) and its lit row (`highlight`, `highlight-ink`):
|
|
430
|
-
'bold'` lights the row in the accent's fill, and `menu.panel` draws the panel
|
|
431
|
-
(the other scheme's surface and text) or `translucent` over a blur, as shadcn's menu
|
|
437
|
+
panel (`surface`, `ink`, `blur`) and its lit row (`highlight`, `press`, `highlight-ink`):
|
|
438
|
+
`menu.highlight: 'bold'` lights the row in the accent's fill, and `menu.panel` draws the panel
|
|
439
|
+
`inverted` (the other scheme's surface and text) or `translucent` over a blur, as shadcn's menu
|
|
440
|
+
options do.
|
|
432
441
|
Each is a 0-or-1 knob (`popup-bold`, `popup-invert`) blended by `color-mix`, so an override
|
|
433
442
|
switches it live. The `state` group is what a state lays over the surface under it, a mix of the
|
|
434
|
-
element's own text color (`hover
|
|
435
|
-
inside an image), so it reads at any elevation and on any
|
|
436
|
-
(`state-hover`, `state-tint`, `state-tint-dark`,
|
|
443
|
+
element's own text color (`hover`, and `press` at 1.75 of it; `tint` and `tint-hover`, a
|
|
444
|
+
see-through fill; `edge`, a hairline inside an image), so it reads at any elevation and on any
|
|
445
|
+
band; its amounts are knob variables (`state-hover`, `state-tint`, `state-tint-dark`,
|
|
446
|
+
`image-edge`), and a theme sets the hover's, and the press's with it, with
|
|
447
|
+
`surface.hoverStrength` (4% to 24%, 12% by default); a disabled control fades by
|
|
448
|
+
`state.disabledOpacity` (`Disabled`, 0.3 to 0.7, half by default). `Theme.nested(outer, inset,
|
|
437
449
|
border?)` is the radius of a surface inset in another, so their corners are concentric. A
|
|
438
450
|
container that pads its children can publish that instead: spread `Theme.nests(radius, inset,
|
|
439
451
|
border?)` beside its own radius and padding, and `Theme.nested()` with no arguments on any
|
|
@@ -495,7 +507,19 @@ who chose dark sees one light frame: `Theme.schemeScript(key?)` is the text of a
|
|
|
495
507
|
that applies the one kept in `localStorage`, `Theme.chooseScheme(scheme, key?)` (`'light'`,
|
|
496
508
|
`'dark'` or `'system'`) is a Command's Effect that applies and keeps a choice, and
|
|
497
509
|
`Theme.currentScheme()` reads back what is applied, for the Model once the browser takes the page
|
|
498
|
-
over (the docs site does it in its SSR plan's `boot`).
|
|
510
|
+
over (the docs site does it in its SSR plan's `boot`).
|
|
511
|
+
|
|
512
|
+
Knob values a reader set, as on a theme-making page, need the same: `Theme.knobScript({ key?,
|
|
513
|
+
selector? })` is the text of a head `<script>` that applies the knob variables kept in
|
|
514
|
+
`localStorage` to `selector` (`:root` by default), and `Theme.chooseKnobs(theme, { base, key?,
|
|
515
|
+
selector? })` is a Command's Effect that applies `theme`'s and keeps them. Both write one
|
|
516
|
+
unlayered rule in one `<style>` element, so it beats the layered theme, an inline style still
|
|
517
|
+
beats it, and the Command replaces what the script wrote rather than handing over from it. What is
|
|
518
|
+
kept is the variables that differ from `base`, with `KNOBS_FORMAT`: an entry of another format, a
|
|
519
|
+
property that is not a knob, and storage that throws are ignored, and the base theme keeps
|
|
520
|
+
nothing. A token derives where it is declared, so a selector other than `:root` must declare the
|
|
521
|
+
tokens too (`Theme.scope`). On a page rendered per request, put the theme in the Model from a
|
|
522
|
+
cookie instead (see `foldkit-ssr`). The palette
|
|
499
523
|
needs relative color syntax and `light-dark()` (Chrome 123, Firefox 128, Safari 17.5).
|
|
500
524
|
|
|
501
525
|
`Style.responsive(Theme.tokens.breakpoint, { md: { … } })` and
|
|
@@ -506,6 +530,25 @@ container named `page` rather than the window: an editor's preview frame, narrow
|
|
|
506
530
|
window, then draws a look as a narrow screen would. An element must be that container
|
|
507
531
|
(`containerType: 'inline-size', containerName: 'page'`).
|
|
508
532
|
|
|
533
|
+
### States
|
|
534
|
+
|
|
535
|
+
One owner per interactive state, so every component on a page agrees and a theme moves them
|
|
536
|
+
together:
|
|
537
|
+
|
|
538
|
+
| State | Drawn by | Chosen by |
|
|
539
|
+
| --- | --- | --- |
|
|
540
|
+
| hover | the hover ink as a film over what is under it | `surface.hover` (the ink), `surface.hoverStrength` (how much) |
|
|
541
|
+
| press | the same ink at 1.75 of the hover's strength | `surface.hoverStrength` |
|
|
542
|
+
| selected / current | `accent.subtle`; a popup's lit row by `menu.highlight` | `accent.*`, `menu.highlight` |
|
|
543
|
+
| focus | one outline token, one offset | `accent.hue` |
|
|
544
|
+
| disabled | one fade, and nothing else changes | `state.disabledOpacity` |
|
|
545
|
+
|
|
546
|
+
A fluid highlight — one highlight that glides from item to item — is the hover: it lays the
|
|
547
|
+
same film from the same ink, so a fluid list and a plain one on a page hover alike, and it
|
|
548
|
+
deepens to the press while its item is held. Popups keep their own highlight, and a Card
|
|
549
|
+
lightens a dark page as it darkens a light one, both by design. `foldkit-mixins-ui` names the
|
|
550
|
+
pieces: `unfilledHover`, `pressedHover`, `hover()`, `focusRing` and `disabled`.
|
|
551
|
+
|
|
509
552
|
### Layout
|
|
510
553
|
|
|
511
554
|
`foldkit-mixins/layout` ships the common arrangements as pieces: `Layout.stack`, `cluster`,
|
package/dist/app.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { i as StyleValue } from "./styleValue-DEsUAC4v.mjs";
|
|
|
2
2
|
import { standard } from "./layers.mjs";
|
|
3
3
|
import { a as NamedStyle, l as StyleOptions, n as Declared, r as DeclaredPieces, u as StylePieces } from "./style-Cs-aMa_a.mjs";
|
|
4
4
|
import { a as compose, r as ThemeTokens, t as Refs } from "./core-Cq9PThXv.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { d as RootOptions, g as KnobTheme, r as Themes, t as StandardTokens, v as Standard } from "./themes-DF2Spo6_.mjs";
|
|
6
6
|
//#region src/app.d.ts
|
|
7
7
|
interface Common<Own extends ThemeTokens> {
|
|
8
8
|
/**
|
package/dist/app.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { i as stylesheet, n as forSlots, r as slots } from "./style-COMT0F2e.mjs
|
|
|
2
2
|
import { i as compose } from "./styleValue-6hpAYYfg.mjs";
|
|
3
3
|
import { r as standard } from "./layers-DxWvuCJL.mjs";
|
|
4
4
|
import { o as ref, r as compose$1 } from "./core-BrR6UPbk.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { l as standardOf, t as root } from "./root-CT_iUZvD.mjs";
|
|
6
6
|
import { body, reset } from "./defaults.mjs";
|
|
7
7
|
//#region src/app.ts
|
|
8
8
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { c as global } from "./styleValue-6hpAYYfg.mjs";
|
|
2
2
|
import { i as define, n as VAR_PREFIX, r as compose } from "./core-BrR6UPbk.mjs";
|
|
3
|
-
import { _ as tokensOf, b as variables, c as tokens, d as make$1, g as standard, v as unsetOf } from "./tokens-
|
|
3
|
+
import { _ as tokensOf, b as variables, c as tokens, d as make$1, g as standard, v as unsetOf } from "./tokens-CkTT9DNd.mjs";
|
|
4
4
|
import { Effect, Schema } from "effect";
|
|
5
5
|
//#region src/theme/oklch.ts
|
|
6
6
|
/**
|
|
@@ -161,7 +161,6 @@ const accent = v("accent", "default");
|
|
|
161
161
|
const palette = define({
|
|
162
162
|
knob: {
|
|
163
163
|
...unsetOf(standard),
|
|
164
|
-
"state-hover": "12%",
|
|
165
164
|
"state-tint": "8%",
|
|
166
165
|
"state-tint-dark": "25%",
|
|
167
166
|
"image-edge": "10%",
|
|
@@ -203,6 +202,7 @@ const palette = define({
|
|
|
203
202
|
shadow: { color: ld(`oklch(25% ${v("knob", "shadow-c")} ${v("knob", "shadow-h")} / 0.14)`, `oklch(5% calc(${v("knob", "shadow-c")} * 4 / 3) ${v("knob", "shadow-h")} / 0.6)`) },
|
|
204
203
|
state: {
|
|
205
204
|
hover: `color-mix(in oklab, currentColor ${v("knob", "state-hover")}, transparent)`,
|
|
205
|
+
press: `color-mix(in oklab, currentColor calc(${v("knob", "state-hover")} * 1.75), transparent)`,
|
|
206
206
|
tint: ld(`color-mix(in oklab, currentColor ${v("knob", "state-tint")}, transparent)`, `color-mix(in oklab, currentColor ${v("knob", "state-tint-dark")}, transparent)`),
|
|
207
207
|
"tint-hover": ld(`color-mix(in oklab, currentColor calc(${v("knob", "state-tint")} * 0.8), transparent)`, `color-mix(in oklab, currentColor calc(${v("knob", "state-tint-dark")} * 0.8), transparent)`),
|
|
208
208
|
edge: `color-mix(in oklab, ${v("text", "overt")} ${v("knob", "image-edge")}, transparent)`,
|
|
@@ -213,6 +213,7 @@ const palette = define({
|
|
|
213
213
|
inverted: ld(`oklch(${v("knob", "base-l-dark")} calc(${surfaceCDark} * 0.9) ${neutral})`, `oklch(${v("knob", "base-l")} calc(${surfaceC} * 0.9) ${neutral})`),
|
|
214
214
|
ink: share(text([88, .8], [20, 2]), "popup-invert", v("text", "default")),
|
|
215
215
|
highlight: share(v("accent", "default"), "popup-bold", `color-mix(in oklab, ${v("popup", "ink")} 8%, transparent)`),
|
|
216
|
+
press: share(v("accent", "active"), "popup-bold", `color-mix(in oklab, ${v("popup", "ink")} 14%, transparent)`),
|
|
216
217
|
"highlight-ink": share(v("accent", "on-fill"), "popup-bold", v("popup", "ink")),
|
|
217
218
|
blur: v("knob", "popup-blur")
|
|
218
219
|
},
|
|
@@ -247,6 +248,13 @@ const palette = define({
|
|
|
247
248
|
}
|
|
248
249
|
});
|
|
249
250
|
//#endregion
|
|
251
|
+
//#region src/theme/scriptLiteral.ts
|
|
252
|
+
/**
|
|
253
|
+
* `value` as a literal in a head script's text: `<` escaped, so a key or a
|
|
254
|
+
* name cannot close the script it is written into.
|
|
255
|
+
*/
|
|
256
|
+
const scriptLiteral = (value) => JSON.stringify(value).replaceAll("<", `${String.fromCharCode(92)}u003c`);
|
|
257
|
+
//#endregion
|
|
250
258
|
//#region src/theme/themes.ts
|
|
251
259
|
/**
|
|
252
260
|
* Themes installed by name. A theme of typed knobs (`Theme.make`) holds only
|
|
@@ -255,7 +263,8 @@ const palette = define({
|
|
|
255
263
|
* theme's knobs, and each other theme writes its knobs under
|
|
256
264
|
* `:root[data-theme="name"]`, the same element, where the derivations resolve
|
|
257
265
|
* them. Which theme is active is the application's Model's fact; `apply` is
|
|
258
|
-
* the Command's effect that shows it
|
|
266
|
+
* the Command's effect that shows it, and `choose` shows it and keeps it,
|
|
267
|
+
* for `script` to show in the head of the next page before the first paint.
|
|
259
268
|
*/
|
|
260
269
|
const shipped = compose(tokens, palette);
|
|
261
270
|
/**
|
|
@@ -294,6 +303,26 @@ const apply = (themes, name) => Effect.sync(() => {
|
|
|
294
303
|
if (name === themes.initial) root.removeAttribute(themes.attribute);
|
|
295
304
|
else root.setAttribute(themes.attribute, name);
|
|
296
305
|
});
|
|
306
|
+
/** The storage key a chosen theme's name is kept under, unless one is given. */
|
|
307
|
+
const THEME_KEY = "foldkit:theme";
|
|
308
|
+
/**
|
|
309
|
+
* The text of a `<script>` for the document's head: it shows the theme whose
|
|
310
|
+
* name is kept under `key`, so a reader who chose one never sees the initial
|
|
311
|
+
* theme for a frame. A kept name that is not one of `themes` (a theme a later
|
|
312
|
+
* build removed), and storage that throws, leave the initial theme.
|
|
313
|
+
*/
|
|
314
|
+
const script = (themes, key = THEME_KEY) => `(function(){try{var n=localStorage.getItem(${scriptLiteral(key)});if(${scriptLiteral(themes.names.filter((name) => name !== themes.initial))}.indexOf(n)!==-1)document.documentElement.setAttribute(${scriptLiteral(themes.attribute)},n)}catch(e){}})()`;
|
|
315
|
+
/**
|
|
316
|
+
* Shows `name`, as `apply` does, and keeps it under `key` for the next visit,
|
|
317
|
+
* as a Command's effect: the initial theme keeps nothing. Storage that throws
|
|
318
|
+
* still shows it on this page.
|
|
319
|
+
*/
|
|
320
|
+
const choose = (themes, name, key = THEME_KEY) => apply(themes, name).pipe(Effect.andThen(Effect.sync(() => {
|
|
321
|
+
try {
|
|
322
|
+
if (name === themes.initial) localStorage.removeItem(key);
|
|
323
|
+
else localStorage.setItem(key, name);
|
|
324
|
+
} catch {}
|
|
325
|
+
})));
|
|
297
326
|
/**
|
|
298
327
|
* `theme` on the elements `selector` matches, below the root: its knobs and
|
|
299
328
|
* every derivation again. A token resolves where it is declared, so knobs
|
|
@@ -340,6 +369,6 @@ const scoped = (_theme, selector, overrides) => {
|
|
|
340
369
|
return global(`${selector}{${declarations(tokens).join(";")}}`);
|
|
341
370
|
};
|
|
342
371
|
//#endregion
|
|
343
|
-
export {
|
|
372
|
+
export { choose as a, script as c, apply as i, standardOf as l, scoped as n, make as o, THEME_KEY as r, scope as s, root as t, scriptLiteral as u };
|
|
344
373
|
|
|
345
|
-
//# sourceMappingURL=root-
|
|
374
|
+
//# sourceMappingURL=root-CT_iUZvD.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root-CT_iUZvD.mjs","names":["makeTheme","declarations"],"sources":["../src/theme/oklch.ts","../src/theme/scriptLiteral.ts","../src/theme/themes.ts","../src/theme/root.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 on the element that declares the tokens (`:root`, or a scoped theme's\n * selector) re-derives the rest in the browser. A custom property resolves\n * where it is declared, so a knob overridden on a subtree below `:root`\n * changes nothing: `Theme.scope` declares the derivations there too. Where\n * light and dark schemes need different numbers 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'\nimport { standard, unsetOf } from './knobs.js'\n\nconst v = (group: string, name: string) => `var(--fk-${group}-${name})`\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/**\n * How far a step's target lies past the offset it names: at the default\n * contrast (26%) a step sits where its offset says, and the whole knob spans\n * 2.5 times that, so its range is one a reader sees. At a reach of 1 the knob\n * at its top moved the muted surface four points of lightness.\n */\nconst REACH = 2.5\nconst reach = ([lightness, chroma]: Step): Step => [\n Number((lightness * REACH).toFixed(4)),\n Number((1 + (chroma - 1) * REACH).toFixed(4)),\n]\n\n/** A surface step: the base mixed toward a target by `surface-contrast`. */\nconst surfaceStep = (lightStep: Step, darkStep: Step) => {\n const amount = v('knob', 'surface-contrast')\n const [light, dark] = [reach(lightStep), reach(darkStep)]\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` where the 0-or-1 knob `name` is 1, `b` where it is 0. */\nconst share = (a: string, name: string, b: string) =>\n `color-mix(in oklab, ${a} calc(${v('knob', name)} * 100%), ${b})`\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/**\n * A code color in `hue`: the same lightness for every kind, so no kind shouts,\n * dark enough to read on a light surface and light enough on a dark one.\n */\nconst syntaxInk = (hue: string) =>\n ld(`oklch(48% ${v('knob', 'syntax-c')} ${hue})`, `oklch(80% ${v('knob', 'syntax-c')} ${hue})`)\n\n/**\n * A chart's series color: a hue a fixed turn from the first, at a lightness\n * and chroma chosen for that hue in each scheme (a yellow sits lighter than a\n * blue to read as strong). The five are the dataviz reference palette's first\n * slots, in its order, which keeps neighbors apart under protan and deutan\n * vision; moving `chart-h` turns them all and keeps the order.\n */\nconst chartInk = (turn: number, light: Step, dark: Step) => {\n const hue = `calc(${v('knob', 'chart-h')} ${offset(turn)})`\n return ld(`oklch(${light[0]} ${light[1]} ${hue})`, `oklch(${dark[0]} ${dark[1]} ${hue})`)\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\n/** The color scales, each named for its hue (a knob, `red-h`). */\ntype ScaleName = 'red' | 'orange' | 'yellow' | 'green' | 'teal' | 'blue' | 'purple'\n\n/**\n * One lightness ladder for every scale, near white to near black in even\n * steps, so step 6 of red is as light as step 6 of blue: a step number\n * means the same contrast in any hue (after css-tags' palette).\n */\nconst scaleL = [97, 88.5, 80, 71.5, 63, 54.5, 46, 37.5, 29, 20.5]\n// Chroma swells toward the middle, where a screen can show most of it, and\n// thins at both ends, where a vivid near-white or near-black falls out of gamut.\nconst scaleC = [0.02, 0.05, 0.09, 0.13, 0.16, 0.17, 0.155, 0.125, 0.09, 0.055]\n\n/**\n * A color's ten steps, `1` the lightest, and four `wash`es: step 6 mixed\n * into the page, so a tinted ground follows the scheme and the surface\n * knobs as the page does.\n */\nconst colorScale = (name: ScaleName) => {\n const hue = v('knob', `${name}-h`)\n const step = (index: number) =>\n `oklch(${scaleL[index]}% calc(${scaleC[index]} * ${v('knob', 'scale-c')}) ${hue})`\n const wash = (share: number) =>\n `color-mix(in oklab, ${v(name, '6')} ${share}%, ${v('surface', 'base')})`\n return {\n '1': step(0),\n '2': step(1),\n '3': step(2),\n '4': step(3),\n '5': step(4),\n '6': step(5),\n '7': step(6),\n '8': step(7),\n '9': step(8),\n '10': step(9),\n 'wash-1': wash(8),\n 'wash-2': wash(16),\n 'wash-3': wash(28),\n 'wash-4': wash(44),\n }\n}\n\n/**\n * An outline, the palette's line until the `shape.outlines` knob gives it the\n * text's own ink: `outline-ink` 0 is the line itself, 1 the ink at its strength.\n */\nconst inked = (line: string, strength: 'subtle' | 'default' | 'overt') =>\n `color-mix(in oklch, ${line}, color-mix(in oklch, ${v('text', 'overt')} ${v('knob', `outline-ink-${strength}`)}, transparent) calc(${v('knob', 'outline-ink')} * 100%))`\n\nconst accent = v('accent', 'default')\n\n/**\n * The palette: every color a CSS expression over the knobs' variables. The\n * knobs stand at their defaults here; a theme declares its own values over\n * them (`Theme.standard`).\n */\nexport const palette = define({\n knob: {\n ...unsetOf(standard),\n // How much of the text a state lays over its surface; a hover's is a knob.\n 'state-tint': '8%',\n 'state-tint-dark': '25%',\n 'image-edge': '10%',\n // How much lighter each raised level is in a dark scheme.\n 'raise-dark': '0.027',\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('knob', 'neutral-h'),\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 // A control's resting ground, separate from a neutral surface step so a\n // field can keep its contrast if the steps move: filled fields read it,\n // the page reads base.\n field: v('surface', 'default'),\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: inked(ld(scale(base, -0.07, 1.3), scale(base, 0.065, 1.25)), 'subtle'),\n // Between two parts of one surface (groups of a list, a panel's\n // header): a step past `subtle`, which a dark page all but hides.\n divider: inked(ld(scale(base, -0.1, 1.35), scale(base, 0.095, 1.3)), 'subtle'),\n default: inked(ld(scale(base, -0.13, 1.4), scale(base, 0.12, 1.35)), 'default'),\n overt: inked(ld(scale(base, -0.27, 1.6), scale(base, 0.23, 1.5)), 'overt'),\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 shadow's 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% ${v('knob', 'shadow-c')} ${v('knob', 'shadow-h')} / 0.14)`,\n // A third more chroma, as the dark surfaces have.\n `oklch(5% calc(${v('knob', 'shadow-c')} * 4 / 3) ${v('knob', 'shadow-h')} / 0.6)`,\n ),\n },\n // What a state lays over the surface under it, after Fluid Functionalism's\n // overlays. `hover`, `tint` and `tint-hover` mix the element's own text\n // color: `currentColor` resolves where the film is drawn, so a hover reads\n // at any elevation, on a tinted band, and on an inverted panel alike. A\n // film that must take its surface's hue instead reads a property on the\n // element (`unfilledHover` reads a surface's `--_fk-state-ink`, falling\n // back to this `ink`): a `var()` substitutes where the token is declared,\n // so a token cannot carry a per-surface ink. `tint` is a see-through fill, which\n // takes on whatever it sits on (lighter when hovered, as Fluid's: the\n // press is what darkens). `edge` is a hairline inside an image, so a pale\n // edge keeps its shape. `ink` is the state ink where no surface set one:\n // the text (`surface`), the accent's ink (`accent`), or the text with the\n // films reading it directly (`neutral`, as before).\n state: {\n hover: `color-mix(in oklab, currentColor ${v('knob', 'state-hover')}, transparent)`,\n // The same ink held down: a press is the hover at 1.75, one strength the\n // `hoverStrength` knob moves for both. `pressedHover` is its twin, and\n // takes the surface's ink where this one takes the text's.\n press: `color-mix(in oklab, currentColor calc(${v('knob', 'state-hover')} * 1.75), transparent)`,\n tint: ld(\n `color-mix(in oklab, currentColor ${v('knob', 'state-tint')}, transparent)`,\n `color-mix(in oklab, currentColor ${v('knob', 'state-tint-dark')}, transparent)`,\n ),\n 'tint-hover': ld(\n `color-mix(in oklab, currentColor calc(${v('knob', 'state-tint')} * 0.8), transparent)`,\n `color-mix(in oklab, currentColor calc(${v('knob', 'state-tint-dark')} * 0.8), transparent)`,\n ),\n edge: `color-mix(in oklab, ${v('text', 'overt')} ${v('knob', 'image-edge')}, transparent)`,\n ink: v('knob', 'state-ink'),\n },\n // A menu's panel and its lit row, which the popup recipes read.\n popup: {\n surface: `color-mix(in oklab, ${share(\n ld(\n `oklch(${v('knob', 'base-l-dark')} calc(${surfaceCDark} * 0.9) ${neutral})`,\n `oklch(${v('knob', 'base-l')} calc(${surfaceC} * 0.9) ${neutral})`,\n ),\n 'popup-invert',\n base,\n )} calc(${v('knob', 'popup-alpha')} * 100%), transparent)`,\n // The other scheme's base, which an inverted panel takes wherever it is raised to.\n inverted: ld(\n `oklch(${v('knob', 'base-l-dark')} calc(${surfaceCDark} * 0.9) ${neutral})`,\n `oklch(${v('knob', 'base-l')} calc(${surfaceC} * 0.9) ${neutral})`,\n ),\n // The text of the opposite scheme: light on an inverted panel in a light one.\n ink: share(text([88, 0.8], [20, 2]), 'popup-invert', v('text', 'default')),\n highlight: share(\n v('accent', 'default'),\n 'popup-bold',\n `color-mix(in oklab, ${v('popup', 'ink')} 8%, transparent)`,\n ),\n // Held down, as a row's hover deepens to its press: the accent darker, the\n // panel's own ink denser.\n press: share(\n v('accent', 'active'),\n 'popup-bold',\n `color-mix(in oklab, ${v('popup', 'ink')} 14%, transparent)`,\n ),\n 'highlight-ink': share(v('accent', 'on-fill'), 'popup-bold', v('popup', 'ink')),\n blur: v('knob', 'popup-blur'),\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 // Series colors, `chart-1` to `chart-5` as shadcn names them: a chart\n // assigns them in order, never by rank, so a series keeps its color.\n chart: {\n '1': chartInk(0, [0.575, 0.163], [0.622, 0.161]),\n '2': chartInk(145, [0.671, 0.175], [0.622, 0.173]),\n '3': chartInk(-93, [0.669, 0.141], [0.621, 0.128]),\n '4': chartInk(180, [0.764, 0.161], [0.67, 0.143]),\n '5': chartInk(102, [0.716, 0.141], [0.622, 0.171]),\n },\n // Color scales of ten even steps, for what is not a role: a tag's\n // color, an illustration, a status of the application's own.\n red: colorScale('red'),\n orange: colorScale('orange'),\n yellow: colorScale('yellow'),\n green: colorScale('green'),\n teal: colorScale('teal'),\n blue: colorScale('blue'),\n purple: colorScale('purple'),\n // Code, by the kinds a tokenizer names (`syntax-keyword` is\n // `--fk-syntax-keyword`): each kind in a hue the palette already has, so\n // code follows the brand, and the quiet kinds in the text's own grey.\n syntax: {\n keyword: syntaxInk(v('hue', 'accent')),\n function: syntaxInk(v('hue', 'secondary')),\n type: syntaxInk(v('hue', 'tertiary')),\n string: syntaxInk(v('knob', 'success-h')),\n number: syntaxInk(v('knob', 'warning-h')),\n property: syntaxInk(v('knob', 'info-h')),\n operator: v('text', 'default'),\n punctuation: v('text', 'muted'),\n comment: text([52, 1], [62, 1]),\n },\n})\n\nexport type Palette = typeof palette\n","/**\n * `value` as a literal in a head script's text: `<` escaped, so a key or a\n * name cannot close the script it is written into.\n */\nexport const scriptLiteral = (value: unknown): string =>\n JSON.stringify(value).replaceAll('<', `${String.fromCharCode(92)}u003c`)\n","/**\n * Themes installed by name. A theme of typed knobs (`Theme.make`) holds only\n * knob values, and every token derives from knob variables, so one set of\n * derivations serves every theme: the root declares them with the initial\n * theme's knobs, and each other theme writes its knobs under\n * `:root[data-theme=\"name\"]`, the same element, where the derivations resolve\n * them. Which theme is active is the application's Model's fact; `apply` is\n * the Command's effect that shows it, and `choose` shows it and keeps it,\n * for `script` to show in the head of the next page before the first paint.\n */\nimport { Effect, Schema } from 'effect'\nimport { global, type StyleValue } from '../styleValue.js'\nimport { compose, VAR_PREFIX, type ThemeTokens } from './core.js'\nimport {\n make as makeTheme,\n tokensOf,\n variables,\n type KnobSet,\n type KnobTheme,\n type Standard,\n} from './knobs.js'\nimport { palette, type Palette } from './oklch.js'\nimport { scriptLiteral } from './scriptLiteral.js'\nimport { tokens, type Tokens } from './tokens.js'\n\n/** Every shipped token: the scales, the palette, and the knobs they read. */\nexport type StandardTokens = ReturnType<typeof compose<Tokens, Palette>>\n\nconst shipped = compose(tokens, palette)\n\n/**\n * Every shipped token with `theme`'s knob values, for a page's root: the\n * derivations are the same for every theme, so only the knobs differ. With\n * no theme, every knob at its default.\n */\nexport const standardOf = (theme: KnobTheme<Standard> = makeTheme({})): StandardTokens =>\n compose(shipped, tokensOf(theme))\n\nconst declarations = (theme: ThemeTokens) =>\n Object.entries(theme)\n .flatMap(([group, names]) =>\n Object.entries(names).map(([name, value]) => `${VAR_PREFIX}-${group}-${name}:${value}`),\n )\n .join(';')\n\nconst knobRule = (selector: string, theme: KnobTheme<KnobSet>) =>\n `${selector}{${Object.entries(variables(theme))\n .map(([name, value]) => `${VAR_PREFIX}-knob-${name}:${value}`)\n .join(';')}}`\n\n/** A set of named themes, one of them shown until the Model chooses another. */\nexport interface Themes<Name extends string> {\n /** The names, as a Schema for the Model field that holds the active one. */\n readonly Name: Schema.Literals<ReadonlyArray<Name>>\n readonly names: ReadonlyArray<Name>\n readonly initial: Name\n /** The root element's attribute that names the active theme. */\n readonly attribute: string\n readonly theme: (name: Name) => KnobTheme<Standard>\n /** Every token with the initial theme's knobs: what the root declares, and what `t` reads. */\n readonly root: StandardTokens\n /** Each other theme's knobs, under its attribute on the root element, for the `theme` layer. */\n readonly scoped: StyleValue\n}\n\n/**\n * `themes` installed by their keys, `initial` shown until the Model chooses\n * another. A name is a key, so it is unique, and `Name` is the Schema of the\n * Model field that holds the active one.\n */\nexport const make = <const Record extends { readonly [name: string]: KnobTheme<Standard> }>(\n themes: Record,\n options: { readonly initial: keyof Record & string; readonly attribute?: string },\n): Themes<keyof Record & string> => {\n const names = Object.keys(themes) as ReadonlyArray<keyof Record & string>\n const attribute = options.attribute ?? 'data-theme'\n const theme = (name: keyof Record & string) => themes[name]!\n return {\n Name: Schema.Literals(names),\n names,\n initial: options.initial,\n attribute,\n theme,\n root: standardOf(theme(options.initial)),\n scoped: global(\n names\n .filter(name => name !== options.initial)\n .map(name => knobRule(`:root[${attribute}=\"${name}\"]`, theme(name)))\n .join(''),\n ),\n }\n}\n\n/**\n * Shows `name` on the root element, as a Command's effect: the initial theme\n * removes the attribute, so the root's own declarations apply.\n */\nexport const apply = <Name extends string>(themes: Themes<Name>, name: Name): Effect.Effect<void> =>\n Effect.sync(() => {\n const root = document.documentElement\n if (name === themes.initial) root.removeAttribute(themes.attribute)\n else root.setAttribute(themes.attribute, name)\n })\n\n/** The storage key a chosen theme's name is kept under, unless one is given. */\nexport const THEME_KEY = 'foldkit:theme'\n\n/**\n * The text of a `<script>` for the document's head: it shows the theme whose\n * name is kept under `key`, so a reader who chose one never sees the initial\n * theme for a frame. A kept name that is not one of `themes` (a theme a later\n * build removed), and storage that throws, leave the initial theme.\n */\nexport const script = <Name extends string>(\n themes: Themes<Name>,\n key: string = THEME_KEY,\n): string =>\n `(function(){try{var n=localStorage.getItem(${scriptLiteral(key)});` +\n `if(${scriptLiteral(themes.names.filter(name => name !== themes.initial))}.indexOf(n)!==-1)` +\n `document.documentElement.setAttribute(${scriptLiteral(themes.attribute)},n)}catch(e){}})()`\n\n/**\n * Shows `name`, as `apply` does, and keeps it under `key` for the next visit,\n * as a Command's effect: the initial theme keeps nothing. Storage that throws\n * still shows it on this page.\n */\nexport const choose = <Name extends string>(\n themes: Themes<Name>,\n name: Name,\n key: string = THEME_KEY,\n): Effect.Effect<void> =>\n apply(themes, name).pipe(\n Effect.andThen(\n Effect.sync(() => {\n try {\n if (name === themes.initial) localStorage.removeItem(key)\n else localStorage.setItem(key, name)\n } catch {\n // Storage refused (a private window, a full quota): this visit keeps it.\n }\n }),\n ),\n )\n\n/**\n * `theme` on the elements `selector` matches, below the root: its knobs and\n * every derivation again. A token resolves where it is declared, so knobs\n * alone under a subtree would change nothing derived from them there.\n */\nexport const scope = (theme: KnobTheme<Standard>, selector: string): StyleValue => {\n const { knob: _knob, ...derived } = shipped\n return global(`${selector}{${declarations(derived)}}${knobRule(selector, theme)}`)\n}\n","/**\n * A theme's tokens as `:root` custom properties, for the page stylesheet.\n * Unlayered: the page decides which layer with `Layers.in`.\n */\nimport { global, type StyleValue } from '../styleValue.js'\nimport { VAR_PREFIX, type ThemeTokens } from './core.js'\n\nexport interface RootOptions {\n /** Tokens present in this theme are left out, so a scale shipped in another layer goes out once. */\n readonly omit?: ThemeTokens\n /** Default `'light dark'`, so `lightDark` tokens resolve. */\n readonly colorScheme?: 'light dark' | 'light' | 'dark'\n}\n\n/**\n * Every token as `--fk-group-name:value`, in authored order. `omit` is\n * matched token by token, not group by group: two themes can both carry a\n * `knob` group (the scales' density beside a palette's hues) and only the\n * names `omit` has are skipped.\n */\nconst declarations = (theme: ThemeTokens, omit?: ThemeTokens): ReadonlyArray<string> =>\n Object.entries(theme).flatMap(([group, names]) =>\n Object.entries(names).flatMap(([name, value]) =>\n omit !== undefined && Object.hasOwn(omit[group] ?? {}, name)\n ? []\n : [`${VAR_PREFIX}-${group}-${name}:${value}`],\n ),\n )\n\nexport const root = (theme: ThemeTokens, options?: RootOptions): StyleValue =>\n global(\n `:root{${[...declarations(theme, options?.omit), `color-scheme:${options?.colorScheme ?? 'light dark'}`].join(';')}}`,\n )\n\n/** Some of a theme's tokens, by the theme's own group and token names. */\nexport type Overrides<T extends ThemeTokens> = {\n readonly [G in keyof T]?: { readonly [N in keyof T[G]]?: string }\n}\n\n/**\n * Token overrides under `selector`: a named theme the Model selects with a\n * root attribute (`:root[data-theme=\"ocean\"]`), or a scheme the user chose\n * (`:root[data-color-scheme=\"dark\"]`). Which one is active is the Model's\n * fact; this only says what it means. On the root element an overridden knob\n * re-derives every token; under a subtree it changes only the tokens it\n * overrides itself, since a token resolves where it is declared: scope a\n * theme to a subtree with `Theme.scope`, which declares the derivations there\n * too.\n *\n * `theme` is the theme being overridden and is read only for its type, so a\n * group or token it lacks is a type error rather than a variable nothing reads.\n */\nexport const scoped = <T extends ThemeTokens>(\n _theme: T,\n selector: string,\n overrides: Overrides<T>,\n): StyleValue => {\n const tokens: Record<string, Record<string, string>> = {}\n for (const [group, names] of Object.entries(overrides)) {\n const defined: Record<string, string> = {}\n for (const [name, value] of Object.entries(names ?? {})) {\n if (typeof value === 'string') defined[name] = value\n }\n tokens[group] = defined\n }\n return global(`${selector}{${declarations(tokens).join(';')}}`)\n}\n"],"mappings":";;;;;;;;;;;;;;;AAaA,MAAM,KAAK,OAAe,SAAiB,YAAY,MAAM,GAAG,KAAK;AACrE,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,GAAG,EAAE;AACpF,MAAM,SAAS,OAAe,IAAY,OACxC,KAAK,OAAO,UAAU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;;;;;;;;;;;;;ACpIA,MAAM,gBAAgB,OAAoB,SACxC,OAAO,QAAQ,KAAK,CAAC,CAAC,SAAS,CAAC,OAAO,WACrC,OAAO,QAAQ,KAAK,CAAC,CAAC,SAAS,CAAC,MAAM,WACpC,SAAS,KAAA,KAAa,OAAO,OAAO,KAAK,UAAU,CAAC,GAAG,IAAI,IACvD,CAAC,IACD,CAAC,GAAG,WAAW,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,CAChD,CACF;AAEF,MAAa,QAAQ,OAAoB,YACvC,OACE,SAAS,CAAC,GAAG,aAAa,OAAO,SAAS,IAAI,GAAG,gBAAgB,SAAS,eAAe,cAAc,CAAC,CAAC,KAAK,GAAG,EAAE,EACrH;;;;;;;;;;;;;;AAoBF,MAAa,UACX,QACA,UACA,cACe;CACf,MAAM,SAAiD,CAAC;CACxD,KAAK,MAAM,CAAC,OAAO,UAAU,OAAO,QAAQ,SAAS,GAAG;EACtD,MAAM,UAAkC,CAAC;EACzC,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,SAAS,CAAC,CAAC,GACpD,IAAI,OAAO,UAAU,UAAU,QAAQ,QAAQ;EAEjD,OAAO,SAAS;CAClB;CACA,OAAO,OAAO,GAAG,SAAS,GAAG,aAAa,MAAM,CAAC,CAAC,KAAK,GAAG,EAAE,EAAE;AAChE"}
|
package/dist/theme.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as StyleValue } from "./styleValue-DEsUAC4v.mjs";
|
|
2
2
|
import { a as compose, c as ref, i as VAR_PREFIX, l as variables, n as Theme$1, o as define, r as ThemeTokens, s as lightDark, t as Refs } from "./core-Cq9PThXv.mjs";
|
|
3
|
-
import { A as
|
|
4
|
-
import { a as concentric, c as nested, d as tokens, f as Palette, i as breakpointWidths, l as nests, n as Rung, o as inContainer, r as Tokens, s as ladder, t as Role, u as role } from "./tokens-
|
|
3
|
+
import { A as variables$1, C as make$1, D as set, E as schemaOf, F as Schemed, I as Variables, L as knob_d_exports, M as Choice, N as Control, O as tokensOf, P as Knob, S as describe, T as print, _ as PathOf, a as choose, b as Values, c as script, d as RootOptions, f as root, g as KnobTheme, h as KnobSet, i as apply, j as withValue, k as valueAt, l as standardOf, m as KnobAt, n as THEME_KEY, o as make, p as scoped, r as Themes$1, s as scope, t as StandardTokens, u as Overrides, v as Standard, w as paths, x as at, y as ValueOf } from "./themes-DF2Spo6_.mjs";
|
|
4
|
+
import { a as concentric, c as nested, d as tokens, f as Palette, i as breakpointWidths, l as nests, n as Rung, o as inContainer, r as Tokens, s as ladder, t as Role, u as role } from "./tokens-C4tC1NFW.mjs";
|
|
5
5
|
import { Effect } from "effect";
|
|
6
6
|
//#region src/theme/scheme.d.ts
|
|
7
7
|
/** What a reader may choose: a scheme, or the operating system's. */
|
|
@@ -24,6 +24,46 @@ export declare const currentScheme: () => Scheme;
|
|
|
24
24
|
*/
|
|
25
25
|
export declare const chooseScheme: (scheme: Scheme, key?: string) => Effect.Effect<void>;
|
|
26
26
|
//#endregion
|
|
27
|
+
//#region src/theme/knobsKept.d.ts
|
|
28
|
+
/** The storage key kept knobs live under, unless one is given. */
|
|
29
|
+
export declare const KNOBS_KEY = "foldkit:knobs";
|
|
30
|
+
/**
|
|
31
|
+
* The kept entry's format. Raise it when a knob is renamed or its variable
|
|
32
|
+
* changes meaning, and an entry kept by an older build is ignored rather than
|
|
33
|
+
* applied wrongly.
|
|
34
|
+
*/
|
|
35
|
+
export declare const KNOBS_FORMAT = 1;
|
|
36
|
+
/** Where kept knobs are kept, and the elements they apply to. */
|
|
37
|
+
interface KnobsPlace {
|
|
38
|
+
/** The storage key. Default `KNOBS_KEY`. */
|
|
39
|
+
readonly key?: string | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* The elements whose knobs the rule sets. Default `:root`. A token derives
|
|
42
|
+
* from the knobs where it is declared, so elements other than the root must
|
|
43
|
+
* declare the tokens too (`Theme.scope`), or they inherit the root's.
|
|
44
|
+
*/
|
|
45
|
+
readonly selector?: string | undefined;
|
|
46
|
+
}
|
|
47
|
+
/** A theme's knobs to apply, and the theme the page's stylesheet already declares. */
|
|
48
|
+
interface KnobsChoice<S extends KnobSet> extends KnobsPlace {
|
|
49
|
+
/** What the stylesheet declares on `selector`: only knobs that differ from it are written. */
|
|
50
|
+
readonly base: KnobTheme<S>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The text of a `<script>` for the document's head: it applies the knobs kept
|
|
54
|
+
* under `key` to `selector`, so a reader who made a theme never sees the
|
|
55
|
+
* default for a frame. Storage that throws, an entry of another format, and
|
|
56
|
+
* anything that is not a knob variable are left out.
|
|
57
|
+
*/
|
|
58
|
+
export declare const knobScript: ({ key, selector }?: KnobsPlace) => string;
|
|
59
|
+
/**
|
|
60
|
+
* Applies `theme`'s knobs to `selector` and keeps them under `key` for the
|
|
61
|
+
* next visit, as a Command's effect: the knobs that differ from `base`, so the
|
|
62
|
+
* base theme writes and keeps nothing. Storage that throws still applies them
|
|
63
|
+
* to this page.
|
|
64
|
+
*/
|
|
65
|
+
export declare const chooseKnobs: <S extends KnobSet>(theme: KnobTheme<S>, { base, key, selector }: KnobsChoice<S>) => Effect.Effect<void>;
|
|
66
|
+
//#endregion
|
|
27
67
|
//#region src/theme/raise.d.ts
|
|
28
68
|
/**
|
|
29
69
|
* An element `offset` levels above the raised element holding it, or the
|
|
@@ -40,6 +80,9 @@ export declare const raise: (offset: number) => StyleValue;
|
|
|
40
80
|
*/
|
|
41
81
|
export declare const raisedSurface: () => string;
|
|
42
82
|
//#endregion
|
|
83
|
+
//#region src/theme/iconMasks.d.ts
|
|
84
|
+
type IconName = 'search' | 'eye' | 'eye-off' | 'pipette' | 'rotate-ccw' | 'rotate-cw' | 'success' | 'warning' | 'error' | 'info' | 'lock' | 'close';
|
|
85
|
+
//#endregion
|
|
43
86
|
//#region src/theme.d.ts
|
|
44
87
|
/** The knobs a theme sets: `Knobs.standard`, every knob the shipped tokens read. */
|
|
45
88
|
export declare const Knobs: {
|
|
@@ -71,6 +114,10 @@ export declare const Knobs: {
|
|
|
71
114
|
readonly 'state-ink': string;
|
|
72
115
|
};
|
|
73
116
|
}>;
|
|
117
|
+
readonly hoverStrength: Knob<number, "state-hover">;
|
|
118
|
+
};
|
|
119
|
+
readonly state: {
|
|
120
|
+
readonly disabledOpacity: Knob<number, "state-disabled">;
|
|
74
121
|
};
|
|
75
122
|
readonly shape: {
|
|
76
123
|
readonly radius: Knob<number, "radius-factor">;
|
|
@@ -122,6 +169,10 @@ export declare const Knobs: {
|
|
|
122
169
|
readonly headingScale: Knob<number, "heading-scale">;
|
|
123
170
|
readonly leading: Knob<number, "leading">;
|
|
124
171
|
};
|
|
172
|
+
readonly icon: {
|
|
173
|
+
readonly size: Knob<number, "icon-scale">;
|
|
174
|
+
readonly stroke: Knob<number, "glyph-width">;
|
|
175
|
+
};
|
|
125
176
|
readonly motion: {
|
|
126
177
|
readonly scale: Knob<number, "motion">;
|
|
127
178
|
readonly easing: Choice<{
|
|
@@ -241,10 +292,16 @@ export declare const Knobs: {
|
|
|
241
292
|
readonly valueAt: typeof valueAt;
|
|
242
293
|
readonly withValue: typeof withValue;
|
|
243
294
|
};
|
|
244
|
-
/**
|
|
295
|
+
/**
|
|
296
|
+
* Themes installed by name: `Themes.make({ iris, cobalt }, { initial: 'iris' })`; `Themes.apply`
|
|
297
|
+
* shows one, `Themes.choose` shows and keeps it, and `Themes.script` shows the kept one before
|
|
298
|
+
* the first paint.
|
|
299
|
+
*/
|
|
245
300
|
export declare const Themes: {
|
|
246
301
|
readonly make: typeof make;
|
|
247
302
|
readonly apply: typeof apply;
|
|
303
|
+
readonly choose: typeof choose;
|
|
304
|
+
readonly script: typeof script;
|
|
248
305
|
};
|
|
249
306
|
export declare const Theme: {
|
|
250
307
|
readonly define: typeof define;
|
|
@@ -269,8 +326,10 @@ export declare const Theme: {
|
|
|
269
326
|
ease: string;
|
|
270
327
|
"font-body": string;
|
|
271
328
|
"font-heading": string;
|
|
329
|
+
"glyph-width": string;
|
|
272
330
|
"heading-tracking": string;
|
|
273
331
|
"heading-weight": string;
|
|
332
|
+
"icon-scale": string;
|
|
274
333
|
"relief-field": string;
|
|
275
334
|
"relief-pressed": string;
|
|
276
335
|
"relief-raised": string;
|
|
@@ -391,6 +450,20 @@ export declare const Theme: {
|
|
|
391
450
|
'column-md': string;
|
|
392
451
|
'column-lg': string;
|
|
393
452
|
};
|
|
453
|
+
icon: {
|
|
454
|
+
readonly close: string;
|
|
455
|
+
readonly error: string;
|
|
456
|
+
readonly eye: string;
|
|
457
|
+
readonly "eye-off": string;
|
|
458
|
+
readonly info: string;
|
|
459
|
+
readonly lock: string;
|
|
460
|
+
readonly pipette: string;
|
|
461
|
+
readonly "rotate-ccw": string;
|
|
462
|
+
readonly "rotate-cw": string;
|
|
463
|
+
readonly search: string;
|
|
464
|
+
readonly success: string;
|
|
465
|
+
readonly warning: string;
|
|
466
|
+
};
|
|
394
467
|
border: {
|
|
395
468
|
thin: string;
|
|
396
469
|
thick: string;
|
|
@@ -451,7 +524,9 @@ export declare const Theme: {
|
|
|
451
524
|
readonly schemeScript: typeof schemeScript;
|
|
452
525
|
readonly chooseScheme: typeof chooseScheme;
|
|
453
526
|
readonly currentScheme: typeof currentScheme;
|
|
527
|
+
readonly knobScript: typeof knobScript;
|
|
528
|
+
readonly chooseKnobs: typeof chooseKnobs;
|
|
454
529
|
};
|
|
455
530
|
//#endregion
|
|
456
|
-
export { type Choice, type Control, knob_d_exports as Knob, type KnobAt, type Knob as KnobOf, type KnobSet, type KnobTheme, type Overrides, type Palette, type PathOf, type Refs, type Role, type RootOptions, type Rung, type Scheme, type Schemed, type Standard, type StandardTokens, type ThemeTokens, type Theme$1 as ThemeValue, type Themes$1 as ThemesOf, type Tokens, VAR_PREFIX, type ValueOf, type Values, type Variables, breakpointWidths, compose, concentric, define, inContainer, ladder, lightDark, nested, nests, ref, role, root, scoped, tokens, variables };
|
|
531
|
+
export { type Choice, type IconName as ChromeIcon, type Control, knob_d_exports as Knob, type KnobAt, type Knob as KnobOf, type KnobSet, type KnobTheme, type KnobsChoice, type KnobsPlace, type Overrides, type Palette, type PathOf, type Refs, type Role, type RootOptions, type Rung, type Scheme, type Schemed, type Standard, type StandardTokens, THEME_KEY, type ThemeTokens, type Theme$1 as ThemeValue, type Themes$1 as ThemesOf, type Tokens, VAR_PREFIX, type ValueOf, type Values, type Variables, breakpointWidths, compose, concentric, define, inContainer, ladder, lightDark, nested, nests, ref, role, root, scoped, tokens, variables };
|
|
457
532
|
//# sourceMappingURL=theme.d.mts.map
|
package/dist/theme.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.mts","names":["Knob.Knob","Knob.Schemed","Knob.Choice","ThemeSet.make","ThemeSet.apply","Core.define","Core.ref","Core.lightDark","Core.compose","ThemeSet.standardOf","make","variables","ThemeSet.scope"],"sources":["../src/theme/scheme.ts","../src/theme/raise.ts","../src/theme.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"theme.d.mts","names":["Knob.Knob","Knob.Schemed","Knob.Choice","ThemeSet.make","ThemeSet.apply","ThemeSet.choose","ThemeSet.script","Core.define","Core.ref","Core.lightDark","Core.compose","ThemeSet.standardOf","make","variables","ThemeSet.scope"],"sources":["../src/theme/scheme.ts","../src/theme/knobsKept.ts","../src/theme/raise.ts","../src/theme/iconMasks.ts","../src/theme.ts"],"mappings":";;;;;;;KAUY;;qBAGC;;;;;;;qBAWA,eAAY;;qBAIZ,qBAAoB;;;;;;qBAWpB,eAAY,QAAY,QAAM,iBAA6B,OAAO;;;;qBCtBlE;;;;;;qBAOA;;UAGI;;WAEN;;;;;;WAMA;;;UAIM,YAAY,UAAU,iBAAiB;;WAE7C,MAAM,UAAU;;;;;;;;qBAcd,eAAU,KAAA,aAA6C;;;;;;;qBAkCvD,cAAe,UAAU,SAAO,OACpC,UAAU,MAAE,MAAA,KAAA,YAC4B,YAAY,OAC1D,OAAO;;;;;;;qBClDG,QAAK,mBAAqB;;;;;;;;;qBAW1B;;;KCnDD;;;;qBCqEC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAOA;WACX,aAAIG;WACJ,cAAKC;WACL,eAAMC;WACN,eAAMC;;qBAWK"}
|
package/dist/theme.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as self, c as global, i as compose$1, r as classPiece } from "./styleValue-6hpAYYfg.mjs";
|
|
2
2
|
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-BrR6UPbk.mjs";
|
|
3
|
-
import { S as knob_exports, _ as tokensOf, a as nested, b as variables$1, c as tokens, d as make, f as paths, g as standard, h as set, i as ladder, l as at, m as schemaOf, n as concentric, o as nests, p as print, r as inContainer, s as role, t as breakpointWidths, u as describe, x as withValue, y as valueAt } from "./tokens-
|
|
4
|
-
import { a as
|
|
3
|
+
import { S as knob_exports, _ as tokensOf, a as nested, b as variables$1, c as tokens, d as make, f as paths, g as standard, h as set, i as ladder, l as at, m as schemaOf, n as concentric, o as nests, p as print, r as inContainer, s as role, t as breakpointWidths, u as describe, x as withValue, y as valueAt } from "./tokens-CkTT9DNd.mjs";
|
|
4
|
+
import { a as choose, c as script, i as apply, l as standardOf, n as scoped, o as make$1, r as THEME_KEY, s as scope, t as root, u as scriptLiteral } from "./root-CT_iUZvD.mjs";
|
|
5
5
|
import { Effect } from "effect";
|
|
6
6
|
//#region src/theme/fonts.ts
|
|
7
7
|
/**
|
|
@@ -35,7 +35,7 @@ const stored = (value) => value === "light" || value === "dark";
|
|
|
35
35
|
* never sees one light frame. Storage that throws (a private window) or holds
|
|
36
36
|
* anything else leaves the stylesheet's choice.
|
|
37
37
|
*/
|
|
38
|
-
const schemeScript = (key = SCHEME_KEY) => `(function(){try{var s=localStorage.getItem(${
|
|
38
|
+
const schemeScript = (key = SCHEME_KEY) => `(function(){try{var s=localStorage.getItem(${scriptLiteral(key)});if(s==='light'||s==='dark')document.documentElement.style.colorScheme=s}catch(e){}})()`;
|
|
39
39
|
/** The scheme the root element shows now: what `schemeScript` or `chooseScheme` applied. */
|
|
40
40
|
const currentScheme = () => {
|
|
41
41
|
if (typeof document === "undefined") return "system";
|
|
@@ -57,6 +57,67 @@ const chooseScheme = (scheme, key = SCHEME_KEY) => Effect.sync(() => {
|
|
|
57
57
|
} catch {}
|
|
58
58
|
});
|
|
59
59
|
//#endregion
|
|
60
|
+
//#region src/theme/knobsKept.ts
|
|
61
|
+
/**
|
|
62
|
+
* A reader's knob values, kept across visits and applied before the first
|
|
63
|
+
* paint, as `schemeScript` and `chooseScheme` do for the scheme. What is kept
|
|
64
|
+
* is the knob variables a theme writes, not its values: the head script then
|
|
65
|
+
* holds no theme logic to drift from `Theme.make`, and only applies them.
|
|
66
|
+
*
|
|
67
|
+
* Both write one rule, `selector { }`, in one `<style>` element in the head,
|
|
68
|
+
* unlayered so it beats every layer `Style.stylesheet` writes: the script once
|
|
69
|
+
* from storage, then `chooseKnobs` on each change. So when the application
|
|
70
|
+
* takes over there is nothing to hand over.
|
|
71
|
+
*/
|
|
72
|
+
/** The storage key kept knobs live under, unless one is given. */
|
|
73
|
+
const KNOBS_KEY = "foldkit:knobs";
|
|
74
|
+
/**
|
|
75
|
+
* The kept entry's format. Raise it when a knob is renamed or its variable
|
|
76
|
+
* changes meaning, and an entry kept by an older build is ignored rather than
|
|
77
|
+
* applied wrongly.
|
|
78
|
+
*/
|
|
79
|
+
const KNOBS_FORMAT = 1;
|
|
80
|
+
const KNOB_PREFIX = `${VAR_PREFIX}-knob-`;
|
|
81
|
+
const ELEMENT_ATTRIBUTE = "data-fk-knobs";
|
|
82
|
+
/**
|
|
83
|
+
* The text of a `<script>` for the document's head: it applies the knobs kept
|
|
84
|
+
* under `key` to `selector`, so a reader who made a theme never sees the
|
|
85
|
+
* default for a frame. Storage that throws, an entry of another format, and
|
|
86
|
+
* anything that is not a knob variable are left out.
|
|
87
|
+
*/
|
|
88
|
+
const knobScript = ({ key = KNOBS_KEY, selector = ":root" } = {}) => `(function(){try{var e=JSON.parse(localStorage.getItem(${scriptLiteral(key)})||'null');if(!e||e.v!==1||!Array.isArray(e.d))return;var s=document.createElement('style');s.setAttribute(${scriptLiteral(ELEMENT_ATTRIBUTE)},${scriptLiteral(key)});s.textContent=${scriptLiteral(`${selector}{}`)};document.head.appendChild(s);var r=s.sheet.cssRules[0].style;e.d.forEach(function(p){if(Array.isArray(p)&&typeof p[0]==='string'&&typeof p[1]==='string'&&p[0].indexOf(${scriptLiteral(KNOB_PREFIX)})===0)r.setProperty(p[0],p[1])})}catch(x){}})()`;
|
|
89
|
+
/** The knob variables `theme` writes that `base` does not, as properties. */
|
|
90
|
+
const differences = (theme, base) => {
|
|
91
|
+
const declared = variables$1(base);
|
|
92
|
+
return Object.entries(variables$1(theme)).filter(([name, value]) => declared[name] !== value).map(([name, value]) => [`${KNOB_PREFIX}${name}`, value]);
|
|
93
|
+
};
|
|
94
|
+
/** The element the script made for `key`, or a new one. */
|
|
95
|
+
const elementFor = (key) => {
|
|
96
|
+
const made = Array.from(document.head.querySelectorAll(`style[${ELEMENT_ATTRIBUTE}]`)).find((element) => element.getAttribute(ELEMENT_ATTRIBUTE) === key);
|
|
97
|
+
if (made !== void 0) return made;
|
|
98
|
+
const element = document.createElement("style");
|
|
99
|
+
element.setAttribute(ELEMENT_ATTRIBUTE, key);
|
|
100
|
+
document.head.appendChild(element);
|
|
101
|
+
return element;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Applies `theme`'s knobs to `selector` and keeps them under `key` for the
|
|
105
|
+
* next visit, as a Command's effect: the knobs that differ from `base`, so the
|
|
106
|
+
* base theme writes and keeps nothing. Storage that throws still applies them
|
|
107
|
+
* to this page.
|
|
108
|
+
*/
|
|
109
|
+
const chooseKnobs = (theme, { base, key = KNOBS_KEY, selector = ":root" }) => Effect.sync(() => {
|
|
110
|
+
const declarations = differences(theme, base);
|
|
111
|
+
elementFor(key).textContent = `${selector}{${declarations.map(([name, value]) => `${name}:${value}`).join(";")}}`;
|
|
112
|
+
try {
|
|
113
|
+
if (declarations.length === 0) localStorage.removeItem(key);
|
|
114
|
+
else localStorage.setItem(key, JSON.stringify({
|
|
115
|
+
v: 1,
|
|
116
|
+
d: declarations
|
|
117
|
+
}));
|
|
118
|
+
} catch {}
|
|
119
|
+
});
|
|
120
|
+
//#endregion
|
|
60
121
|
//#region src/theme/raise.ts
|
|
61
122
|
/**
|
|
62
123
|
* Elevation that nests by itself, after Fluid Functionalism's surface ladder:
|
|
@@ -110,7 +171,8 @@ const raisedSurface = () => {
|
|
|
110
171
|
* pieces. `root` and `scoped` turn tokens into unlayered `:root` and
|
|
111
172
|
* selector rules for `Style.stylesheet`; `make` is a theme of typed knob
|
|
112
173
|
* values, and `standard` every shipped token with a theme's knobs;
|
|
113
|
-
* `schemeScript` and `chooseScheme` keep a reader's light or dark choice
|
|
174
|
+
* `schemeScript` and `chooseScheme` keep a reader's light or dark choice, and
|
|
175
|
+
* `knobScript` and `chooseKnobs` the knob values of a theme they made.
|
|
114
176
|
*/
|
|
115
177
|
/** The knobs a theme sets: `Knobs.standard`, every knob the shipped tokens read. */
|
|
116
178
|
const Knobs = {
|
|
@@ -121,10 +183,16 @@ const Knobs = {
|
|
|
121
183
|
valueAt,
|
|
122
184
|
withValue
|
|
123
185
|
};
|
|
124
|
-
/**
|
|
186
|
+
/**
|
|
187
|
+
* Themes installed by name: `Themes.make({ iris, cobalt }, { initial: 'iris' })`; `Themes.apply`
|
|
188
|
+
* shows one, `Themes.choose` shows and keeps it, and `Themes.script` shows the kept one before
|
|
189
|
+
* the first paint.
|
|
190
|
+
*/
|
|
125
191
|
const Themes = {
|
|
126
192
|
make: make$1,
|
|
127
|
-
apply
|
|
193
|
+
apply,
|
|
194
|
+
choose,
|
|
195
|
+
script
|
|
128
196
|
};
|
|
129
197
|
const Theme = {
|
|
130
198
|
...Theme$1,
|
|
@@ -151,9 +219,11 @@ const Theme = {
|
|
|
151
219
|
scope,
|
|
152
220
|
schemeScript,
|
|
153
221
|
chooseScheme,
|
|
154
|
-
currentScheme
|
|
222
|
+
currentScheme,
|
|
223
|
+
knobScript,
|
|
224
|
+
chooseKnobs
|
|
155
225
|
};
|
|
156
226
|
//#endregion
|
|
157
|
-
export { knob_exports as Knob, Knobs, SCHEME_KEY, Theme, Themes, VAR_PREFIX, breakpointWidths, chooseScheme, compose, concentric, currentScheme, define, inContainer, ladder, lightDark, nested, nests, raise, raisedSurface, ref, role, root, schemeScript, scoped, tokens, variables };
|
|
227
|
+
export { KNOBS_FORMAT, KNOBS_KEY, knob_exports as Knob, Knobs, SCHEME_KEY, THEME_KEY, Theme, Themes, VAR_PREFIX, breakpointWidths, chooseKnobs, chooseScheme, compose, concentric, currentScheme, define, inContainer, knobScript, ladder, lightDark, nested, nests, raise, raisedSurface, ref, role, root, schemeScript, scoped, tokens, variables };
|
|
158
228
|
|
|
159
229
|
//# sourceMappingURL=theme.mjs.map
|