@xtyle/core 0.6.0 → 0.7.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 +15 -6
- package/dist/algorithms/factory.d.ts +24 -1
- package/dist/algorithms/factory.d.ts.map +1 -1
- package/dist/algorithms/factory.js +373 -59
- package/dist/algorithms/factory.js.map +1 -1
- package/dist/audit.d.ts +36 -0
- package/dist/audit.d.ts.map +1 -1
- package/dist/audit.js +22 -0
- package/dist/audit.js.map +1 -1
- package/dist/authoring.d.ts +10 -1
- package/dist/authoring.d.ts.map +1 -1
- package/dist/authoring.js +6 -1
- package/dist/authoring.js.map +1 -1
- package/dist/cli.js +19 -7
- package/dist/cli.js.map +1 -1
- package/dist/color.d.ts +6 -0
- package/dist/color.d.ts.map +1 -1
- package/dist/color.js +20 -0
- package/dist/color.js.map +1 -1
- package/dist/css/components/app-shell.d.ts.map +1 -1
- package/dist/css/components/app-shell.js +10 -0
- package/dist/css/components/app-shell.js.map +1 -1
- package/dist/css/components/avatar.d.ts.map +1 -1
- package/dist/css/components/avatar.js +8 -19
- package/dist/css/components/avatar.js.map +1 -1
- package/dist/css/components/badge.d.ts.map +1 -1
- package/dist/css/components/badge.js +3 -87
- package/dist/css/components/badge.js.map +1 -1
- package/dist/css/components/bottom-nav.d.ts +2 -0
- package/dist/css/components/bottom-nav.d.ts.map +1 -0
- package/dist/css/components/bottom-nav.js +72 -0
- package/dist/css/components/bottom-nav.js.map +1 -0
- package/dist/css/components/carousel.d.ts.map +1 -1
- package/dist/css/components/carousel.js +144 -1
- package/dist/css/components/carousel.js.map +1 -1
- package/dist/css/components/dialog.d.ts.map +1 -1
- package/dist/css/components/dialog.js +10 -4
- package/dist/css/components/dialog.js.map +1 -1
- package/dist/css/components/dot.d.ts +2 -0
- package/dist/css/components/dot.d.ts.map +1 -0
- package/dist/css/components/dot.js +72 -0
- package/dist/css/components/dot.js.map +1 -0
- package/dist/css/components/heatmap.d.ts.map +1 -1
- package/dist/css/components/heatmap.js +23 -0
- package/dist/css/components/heatmap.js.map +1 -1
- package/dist/css/components/image.d.ts.map +1 -1
- package/dist/css/components/image.js +41 -0
- package/dist/css/components/image.js.map +1 -1
- package/dist/css/components/mobile-shell.d.ts +2 -0
- package/dist/css/components/mobile-shell.d.ts.map +1 -0
- package/dist/css/components/mobile-shell.js +63 -0
- package/dist/css/components/mobile-shell.js.map +1 -0
- package/dist/css/components/panel.js +1 -1
- package/dist/css/components/qr.d.ts +2 -0
- package/dist/css/components/qr.d.ts.map +1 -0
- package/dist/css/components/qr.js +134 -0
- package/dist/css/components/qr.js.map +1 -0
- package/dist/css/components/radio.d.ts.map +1 -1
- package/dist/css/components/radio.js +49 -0
- package/dist/css/components/radio.js.map +1 -1
- package/dist/css/components/ribbon.d.ts +2 -0
- package/dist/css/components/ribbon.d.ts.map +1 -0
- package/dist/css/components/ribbon.js +65 -0
- package/dist/css/components/ribbon.js.map +1 -0
- package/dist/css/components/tree.d.ts.map +1 -1
- package/dist/css/components/tree.js +4 -1
- package/dist/css/components/tree.js.map +1 -1
- package/dist/css/components.d.ts.map +1 -1
- package/dist/css/components.js +14 -1
- package/dist/css/components.js.map +1 -1
- package/dist/css/index.d.ts +2 -0
- package/dist/css/index.d.ts.map +1 -1
- package/dist/css/index.js +2 -0
- package/dist/css/index.js.map +1 -1
- package/dist/elements/avatar.d.ts +18 -3
- package/dist/elements/avatar.d.ts.map +1 -1
- package/dist/elements/avatar.js +35 -6
- package/dist/elements/avatar.js.map +1 -1
- package/dist/elements/bottom-nav.d.ts +30 -0
- package/dist/elements/bottom-nav.d.ts.map +1 -0
- package/dist/elements/bottom-nav.js +114 -0
- package/dist/elements/bottom-nav.js.map +1 -0
- package/dist/elements/carousel.d.ts +61 -0
- package/dist/elements/carousel.d.ts.map +1 -1
- package/dist/elements/carousel.js +282 -22
- package/dist/elements/carousel.js.map +1 -1
- package/dist/elements/dialog.d.ts +3 -3
- package/dist/elements/dialog.d.ts.map +1 -1
- package/dist/elements/dialog.js.map +1 -1
- package/dist/elements/dot.d.ts +37 -0
- package/dist/elements/dot.d.ts.map +1 -0
- package/dist/elements/dot.js +104 -0
- package/dist/elements/dot.js.map +1 -0
- package/dist/elements/fragment-ssr.d.ts.map +1 -1
- package/dist/elements/fragment-ssr.js +10 -0
- package/dist/elements/fragment-ssr.js.map +1 -1
- package/dist/elements/fragments/avatar/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/avatar/source.generated.js +1 -1
- package/dist/elements/fragments/avatar/source.generated.js.map +1 -1
- package/dist/elements/fragments/badge/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/badge/source.generated.js +1 -1
- package/dist/elements/fragments/badge/source.generated.js.map +1 -1
- package/dist/elements/fragments/bottom-nav/source.generated.d.ts +25 -0
- package/dist/elements/fragments/bottom-nav/source.generated.d.ts.map +1 -0
- package/dist/elements/fragments/bottom-nav/source.generated.js +4 -0
- package/dist/elements/fragments/bottom-nav/source.generated.js.map +1 -0
- package/dist/elements/fragments/component-host.json +147 -77
- package/dist/elements/fragments/dot/source.generated.d.ts +25 -0
- package/dist/elements/fragments/dot/source.generated.d.ts.map +1 -0
- package/dist/elements/fragments/dot/source.generated.js +4 -0
- package/dist/elements/fragments/dot/source.generated.js.map +1 -0
- package/dist/elements/fragments/heatmap/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/heatmap/source.generated.js +1 -1
- package/dist/elements/fragments/heatmap/source.generated.js.map +1 -1
- package/dist/elements/fragments/icon/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/icon/source.generated.js +1 -1
- package/dist/elements/fragments/icon/source.generated.js.map +1 -1
- package/dist/elements/fragments/image/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/image/source.generated.js +1 -1
- package/dist/elements/fragments/image/source.generated.js.map +1 -1
- package/dist/elements/fragments/mobile-shell/source.generated.d.ts +25 -0
- package/dist/elements/fragments/mobile-shell/source.generated.d.ts.map +1 -0
- package/dist/elements/fragments/mobile-shell/source.generated.js +4 -0
- package/dist/elements/fragments/mobile-shell/source.generated.js.map +1 -0
- package/dist/elements/fragments/qr/source.generated.d.ts +25 -0
- package/dist/elements/fragments/qr/source.generated.d.ts.map +1 -0
- package/dist/elements/fragments/qr/source.generated.js +4 -0
- package/dist/elements/fragments/qr/source.generated.js.map +1 -0
- package/dist/elements/fragments/radio/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/radio/source.generated.js +1 -1
- package/dist/elements/fragments/radio/source.generated.js.map +1 -1
- package/dist/elements/fragments/ribbon/source.generated.d.ts +25 -0
- package/dist/elements/fragments/ribbon/source.generated.d.ts.map +1 -0
- package/dist/elements/fragments/ribbon/source.generated.js +4 -0
- package/dist/elements/fragments/ribbon/source.generated.js.map +1 -0
- package/dist/elements/fragments/segmented/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/segmented/source.generated.js +1 -1
- package/dist/elements/fragments/segmented/source.generated.js.map +1 -1
- package/dist/elements/fragments/slider/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/slider/source.generated.js +1 -1
- package/dist/elements/fragments/slider/source.generated.js.map +1 -1
- package/dist/elements/fragments/tree/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/tree/source.generated.js +1 -1
- package/dist/elements/fragments/tree/source.generated.js.map +1 -1
- package/dist/elements/heatmap.d.ts +14 -3
- package/dist/elements/heatmap.d.ts.map +1 -1
- package/dist/elements/heatmap.js +49 -18
- package/dist/elements/heatmap.js.map +1 -1
- package/dist/elements/image.d.ts +20 -1
- package/dist/elements/image.d.ts.map +1 -1
- package/dist/elements/image.js +171 -1
- package/dist/elements/image.js.map +1 -1
- package/dist/elements/index.d.ts +10 -0
- package/dist/elements/index.d.ts.map +1 -1
- package/dist/elements/index.js +10 -0
- package/dist/elements/index.js.map +1 -1
- package/dist/elements/mobile-shell.d.ts +24 -0
- package/dist/elements/mobile-shell.d.ts.map +1 -0
- package/dist/elements/mobile-shell.js +53 -0
- package/dist/elements/mobile-shell.js.map +1 -0
- package/dist/elements/qr.d.ts +65 -0
- package/dist/elements/qr.d.ts.map +1 -0
- package/dist/elements/qr.js +0 -0
- package/dist/elements/qr.js.map +1 -0
- package/dist/elements/radio.d.ts +1 -0
- package/dist/elements/radio.d.ts.map +1 -1
- package/dist/elements/radio.js +7 -1
- package/dist/elements/radio.js.map +1 -1
- package/dist/elements/ribbon.d.ts +36 -0
- package/dist/elements/ribbon.d.ts.map +1 -0
- package/dist/elements/ribbon.js +91 -0
- package/dist/elements/ribbon.js.map +1 -0
- package/dist/elements/segmented.d.ts.map +1 -1
- package/dist/elements/segmented.js +3 -0
- package/dist/elements/segmented.js.map +1 -1
- package/dist/elements/slider.d.ts +25 -1
- package/dist/elements/slider.d.ts.map +1 -1
- package/dist/elements/slider.js +122 -16
- package/dist/elements/slider.js.map +1 -1
- package/dist/elements/sparkline.d.ts +3 -1
- package/dist/elements/sparkline.d.ts.map +1 -1
- package/dist/elements/sparkline.js +13 -3
- package/dist/elements/sparkline.js.map +1 -1
- package/dist/emit/css.d.ts.map +1 -1
- package/dist/emit/css.js +5 -1
- package/dist/emit/css.js.map +1 -1
- package/dist/emit/index.d.ts +2 -1
- package/dist/emit/index.d.ts.map +1 -1
- package/dist/emit/index.js +3 -1
- package/dist/emit/index.js.map +1 -1
- package/dist/emit/monaco.d.ts.map +1 -1
- package/dist/emit/monaco.js +2 -18
- package/dist/emit/monaco.js.map +1 -1
- package/dist/emit/terminal.d.ts +9 -0
- package/dist/emit/terminal.d.ts.map +1 -0
- package/dist/emit/terminal.js +32 -0
- package/dist/emit/terminal.js.map +1 -0
- package/dist/gauntlet.d.ts.map +1 -1
- package/dist/gauntlet.js +26 -0
- package/dist/gauntlet.js.map +1 -1
- package/dist/host/algorithms-bundle.generated.d.ts.map +1 -1
- package/dist/host/algorithms-bundle.generated.js +1 -1
- package/dist/host/algorithms-bundle.generated.js.map +1 -1
- package/dist/host/authoring-prelude.generated.d.ts +1 -1
- package/dist/host/authoring-prelude.generated.d.ts.map +1 -1
- package/dist/host/authoring-prelude.generated.js +1 -1
- package/dist/host/authoring-prelude.generated.js.map +1 -1
- package/dist/host/index.d.ts.map +1 -1
- package/dist/host/index.js +4 -0
- package/dist/host/index.js.map +1 -1
- package/dist/icon-builder.d.ts +41 -0
- package/dist/icon-builder.d.ts.map +1 -1
- package/dist/icon-builder.js +129 -8
- package/dist/icon-builder.js.map +1 -1
- package/dist/icons.d.ts +1 -1
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js +2 -0
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +11 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/dist/manifest/avatar.manifest.d.ts.map +1 -1
- package/dist/manifest/avatar.manifest.js +37 -17
- package/dist/manifest/avatar.manifest.js.map +1 -1
- package/dist/manifest/badge.manifest.js +1 -1
- package/dist/manifest/badge.manifest.js.map +1 -1
- package/dist/manifest/bottom-nav.manifest.d.ts +3 -0
- package/dist/manifest/bottom-nav.manifest.d.ts.map +1 -0
- package/dist/manifest/bottom-nav.manifest.js +149 -0
- package/dist/manifest/bottom-nav.manifest.js.map +1 -0
- package/dist/manifest/carousel.manifest.d.ts.map +1 -1
- package/dist/manifest/carousel.manifest.js +58 -4
- package/dist/manifest/carousel.manifest.js.map +1 -1
- package/dist/manifest/dialog.manifest.d.ts.map +1 -1
- package/dist/manifest/dialog.manifest.js +7 -4
- package/dist/manifest/dialog.manifest.js.map +1 -1
- package/dist/manifest/dot.manifest.d.ts +3 -0
- package/dist/manifest/dot.manifest.d.ts.map +1 -0
- package/dist/manifest/dot.manifest.js +172 -0
- package/dist/manifest/dot.manifest.js.map +1 -0
- package/dist/manifest/heatmap.manifest.d.ts.map +1 -1
- package/dist/manifest/heatmap.manifest.js +60 -2
- package/dist/manifest/heatmap.manifest.js.map +1 -1
- package/dist/manifest/icon.manifest.d.ts.map +1 -1
- package/dist/manifest/icon.manifest.js +28 -1
- package/dist/manifest/icon.manifest.js.map +1 -1
- package/dist/manifest/image.manifest.d.ts.map +1 -1
- package/dist/manifest/image.manifest.js +100 -1
- package/dist/manifest/image.manifest.js.map +1 -1
- package/dist/manifest/mobile-shell.manifest.d.ts +3 -0
- package/dist/manifest/mobile-shell.manifest.d.ts.map +1 -0
- package/dist/manifest/mobile-shell.manifest.js +177 -0
- package/dist/manifest/mobile-shell.manifest.js.map +1 -0
- package/dist/manifest/panel.manifest.d.ts.map +1 -1
- package/dist/manifest/panel.manifest.js +2 -1
- package/dist/manifest/panel.manifest.js.map +1 -1
- package/dist/manifest/qr.manifest.d.ts +3 -0
- package/dist/manifest/qr.manifest.d.ts.map +1 -0
- package/dist/manifest/qr.manifest.js +314 -0
- package/dist/manifest/qr.manifest.js.map +1 -0
- package/dist/manifest/radio.manifest.d.ts.map +1 -1
- package/dist/manifest/radio.manifest.js +54 -1
- package/dist/manifest/radio.manifest.js.map +1 -1
- package/dist/manifest/registry.d.ts.map +1 -1
- package/dist/manifest/registry.js +10 -0
- package/dist/manifest/registry.js.map +1 -1
- package/dist/manifest/ribbon.manifest.d.ts +3 -0
- package/dist/manifest/ribbon.manifest.d.ts.map +1 -0
- package/dist/manifest/ribbon.manifest.js +173 -0
- package/dist/manifest/ribbon.manifest.js.map +1 -0
- package/dist/manifest/segmented.manifest.js +5 -5
- package/dist/manifest/segmented.manifest.js.map +1 -1
- package/dist/manifest/slider.manifest.d.ts.map +1 -1
- package/dist/manifest/slider.manifest.js +62 -4
- package/dist/manifest/slider.manifest.js.map +1 -1
- package/dist/manifest/sparkline.manifest.d.ts.map +1 -1
- package/dist/manifest/sparkline.manifest.js +27 -1
- package/dist/manifest/sparkline.manifest.js.map +1 -1
- package/dist/manifest/tree.manifest.d.ts.map +1 -1
- package/dist/manifest/tree.manifest.js +24 -10
- package/dist/manifest/tree.manifest.js.map +1 -1
- package/dist/markup/avatar.d.ts +33 -0
- package/dist/markup/avatar.d.ts.map +1 -1
- package/dist/markup/avatar.js +55 -5
- package/dist/markup/avatar.js.map +1 -1
- package/dist/markup/bottom-nav.d.ts +11 -0
- package/dist/markup/bottom-nav.d.ts.map +1 -0
- package/dist/markup/bottom-nav.js +3 -0
- package/dist/markup/bottom-nav.js.map +1 -0
- package/dist/markup/dialog.d.ts +3 -0
- package/dist/markup/dialog.d.ts.map +1 -1
- package/dist/markup/dialog.js.map +1 -1
- package/dist/markup/dot.d.ts +27 -0
- package/dist/markup/dot.d.ts.map +1 -0
- package/dist/markup/dot.js +27 -0
- package/dist/markup/dot.js.map +1 -0
- package/dist/markup/heatmap.d.ts +2 -2
- package/dist/markup/heatmap.d.ts.map +1 -1
- package/dist/markup/heatmap.js.map +1 -1
- package/dist/markup/image.d.ts +9 -0
- package/dist/markup/image.d.ts.map +1 -1
- package/dist/markup/image.js +24 -0
- package/dist/markup/image.js.map +1 -1
- package/dist/markup/index.d.ts +17 -7
- package/dist/markup/index.d.ts.map +1 -1
- package/dist/markup/index.js +9 -4
- package/dist/markup/index.js.map +1 -1
- package/dist/markup/mobile-shell.d.ts +3 -0
- package/dist/markup/mobile-shell.d.ts.map +1 -0
- package/dist/markup/mobile-shell.js +3 -0
- package/dist/markup/mobile-shell.js.map +1 -0
- package/dist/markup/qr.d.ts +77 -0
- package/dist/markup/qr.d.ts.map +1 -0
- package/dist/markup/qr.js +37 -0
- package/dist/markup/qr.js.map +1 -0
- package/dist/markup/radio.d.ts +1 -1
- package/dist/markup/radio.d.ts.map +1 -1
- package/dist/markup/radio.js +1 -1
- package/dist/markup/radio.js.map +1 -1
- package/dist/markup/ribbon.d.ts +23 -0
- package/dist/markup/ribbon.d.ts.map +1 -0
- package/dist/markup/ribbon.js +23 -0
- package/dist/markup/ribbon.js.map +1 -0
- package/dist/markup/segmented.d.ts +2 -0
- package/dist/markup/segmented.d.ts.map +1 -1
- package/dist/markup/segmented.js +2 -0
- package/dist/markup/segmented.js.map +1 -1
- package/dist/markup/sparkline.d.ts +8 -0
- package/dist/markup/sparkline.d.ts.map +1 -1
- package/dist/markup/sparkline.js +37 -0
- package/dist/markup/sparkline.js.map +1 -1
- package/dist/markup/tree.d.ts +15 -4
- package/dist/markup/tree.d.ts.map +1 -1
- package/dist/markup/tree.js +16 -4
- package/dist/markup/tree.js.map +1 -1
- package/dist/qr.d.ts +84 -0
- package/dist/qr.d.ts.map +1 -0
- package/dist/qr.js +596 -0
- package/dist/qr.js.map +1 -0
- package/dist/series.d.ts +29 -0
- package/dist/series.d.ts.map +1 -1
- package/dist/series.js +36 -0
- package/dist/series.js.map +1 -1
- package/dist/theme-file.d.ts +13 -0
- package/dist/theme-file.d.ts.map +1 -1
- package/dist/theme-file.js +32 -0
- package/dist/theme-file.js.map +1 -1
- package/dist/token-meta.d.ts.map +1 -1
- package/dist/token-meta.js +6 -0
- package/dist/token-meta.js.map +1 -1
- package/dist/types.d.ts +64 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/vocab.d.ts +5 -0
- package/dist/vocab.d.ts.map +1 -1
- package/dist/vocab.js.map +1 -1
- package/package.json +1 -1
|
@@ -12,11 +12,31 @@ const DEFAULT_ACCENT_SPLIT = 45;
|
|
|
12
12
|
// Chroma of the faint accent-hue wash on a surface synthesized from an accent (the "keep the tone"
|
|
13
13
|
// derivation); kept low enough that any hue stays a neutral-reading surface rather than a muddy fill.
|
|
14
14
|
const DERIVED_SURFACE_TINT_C = 0.02;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
const DEFAULT_ACCENT_STRATEGY = "fan";
|
|
16
|
+
const ACCENT_STRATEGIES = ["fan", "step", "shade", "duo"];
|
|
17
|
+
/**
|
|
18
|
+
* The accent strategy in force for one derivation. It is both an algorithm's taste (a preset picks
|
|
19
|
+
* the posture it ships with) and a knob (a theme overrides it), so the knob wins where it is set and
|
|
20
|
+
* the preset's own choice is the default — the same layering anchors and every other knob follow.
|
|
21
|
+
*/
|
|
22
|
+
function accentStrategyOf(preset, knobs) {
|
|
23
|
+
const knob = knobs.accentStrategy;
|
|
24
|
+
if (typeof knob === "string" && ACCENT_STRATEGIES.includes(knob))
|
|
25
|
+
return knob;
|
|
26
|
+
return preset.accentStrategy ?? DEFAULT_ACCENT_STRATEGY;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Everything the accent family is built from, resolved in one place. The derivation and the
|
|
30
|
+
* invariant that grades it must read these identically — if they drift, the gauntlet grades a fan
|
|
31
|
+
* the engine never built.
|
|
32
|
+
*/
|
|
33
|
+
function resolveAccentKnobs(preset, knobs) {
|
|
34
|
+
return {
|
|
35
|
+
strategy: accentStrategyOf(preset, knobs),
|
|
36
|
+
split: typeof knobs.accentSplit === "number" ? knobs.accentSplit : DEFAULT_ACCENT_SPLIT,
|
|
37
|
+
shiftStep: typeof knobs.accentShiftStep === "number" ? knobs.accentShiftStep : DEFAULT_SHIFT_STEP,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
20
40
|
const ACHROMATIC_CHROMA = 0.02;
|
|
21
41
|
const DERIVED_ACCENT_HUE_ROTATION = 150;
|
|
22
42
|
const DERIVED_ACCENT_FALLBACK_HUE = 250;
|
|
@@ -24,6 +44,12 @@ const DERIVED_ACCENT_L = 0.62;
|
|
|
24
44
|
const DERIVED_ACCENT_C = 0.16;
|
|
25
45
|
const ACCENT_RAMP_L_MIN = 0.1;
|
|
26
46
|
const ACCENT_RAMP_L_MAX = 0.95;
|
|
47
|
+
// The `shade` strategy steps lightness (not hue) by this much per rung: `accent-2` a tint one step
|
|
48
|
+
// up, `accent-3`/`-4` one and two steps down, so the four read as distinct shades of the one brand hue.
|
|
49
|
+
const SHADE_LADDER_L_STEP = 0.12;
|
|
50
|
+
// How far `duo`'s two derived shades sit from the mean lightness of its two brand anchors. Larger than
|
|
51
|
+
// a single `shade` rung: the shades must clear *both* anchors, not just step away from one.
|
|
52
|
+
const DUO_L_STEP = 0.16;
|
|
27
53
|
const HUE_STABLE_CHROMA = 0.1;
|
|
28
54
|
// The fan (accent-2/3/4) varies hue at the accent's L/C, which collapses to identical grays when the
|
|
29
55
|
// accent has near-zero chroma. Floor the fan's *base* chroma (not the primary accent) so a near-gray
|
|
@@ -102,6 +128,23 @@ const CODE_HUE_RANK = [0, 4, 2, 6, 1, 5, 3, 7];
|
|
|
102
128
|
const CODE_STRUCTURAL_ROLES = ["comment", "operator", "punctuation", "variable"];
|
|
103
129
|
const CODE_SCOPES = [...CODE_VIVID_ROLES, ...CODE_STRUCTURAL_ROLES];
|
|
104
130
|
const CODE_SURFACES = ["--code-bg", "--code-fg", "--code-line-highlight", "--code-selection"];
|
|
131
|
+
// The ANSI palette. The four chrome roles map to xterm.js's ITheme
|
|
132
|
+
// (background / foreground / cursor / cursorAccent), and the sixteen colors are the
|
|
133
|
+
// standard 8 + 8-bright set. The six chromatic slots take fixed hue angles (aligned
|
|
134
|
+
// with the named `--color-*` palette) so a terminal skin re-colours with the chrome
|
|
135
|
+
// while staying recognisably red/green/yellow/blue/magenta/cyan; `black` and `white`
|
|
136
|
+
// are the achromatic endpoints (bg-fill / text) that a terminal uses regardless of scheme.
|
|
137
|
+
const TERMINAL_CHROME = ["bg", "fg", "cursor", "cursor-accent"];
|
|
138
|
+
const ANSI_ORDER = ["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"];
|
|
139
|
+
const ANSI_HUES = {
|
|
140
|
+
red: 25,
|
|
141
|
+
green: 145,
|
|
142
|
+
yellow: 95,
|
|
143
|
+
blue: 250,
|
|
144
|
+
magenta: 330,
|
|
145
|
+
cyan: 200,
|
|
146
|
+
};
|
|
147
|
+
const ANSI_CHROMATIC = ["red", "green", "yellow", "blue", "magenta", "cyan"];
|
|
105
148
|
const SURFACES = ["--body-bg", "--bg-0", "--bg-1", "--bg-2", "--bg-3"];
|
|
106
149
|
const PANEL_REF_INDEX = SURFACES.indexOf("--bg-2");
|
|
107
150
|
const PANEL_SURFACES = ["--bg-1", "--bg-2"];
|
|
@@ -150,6 +193,9 @@ function buildProduces() {
|
|
|
150
193
|
add("--placeholder", "color");
|
|
151
194
|
add("--line", "color");
|
|
152
195
|
add("--line-2", "color");
|
|
196
|
+
add("--scrollbar-track", "color");
|
|
197
|
+
add("--scrollbar-thumb", "color");
|
|
198
|
+
add("--scrollbar-thumb-hover", "color");
|
|
153
199
|
add("--ring", "color");
|
|
154
200
|
add("--ring-bg", "color");
|
|
155
201
|
add("--accent", "color");
|
|
@@ -204,6 +250,12 @@ function buildProduces() {
|
|
|
204
250
|
add(t, "color");
|
|
205
251
|
for (const role of CODE_SCOPES)
|
|
206
252
|
add(`--code-${role}`, "color");
|
|
253
|
+
for (const role of TERMINAL_CHROME)
|
|
254
|
+
add(`--terminal-${role}`, "color");
|
|
255
|
+
for (const name of ANSI_ORDER) {
|
|
256
|
+
add(`--terminal-${name}`, "color");
|
|
257
|
+
add(`--terminal-bright-${name}`, "color");
|
|
258
|
+
}
|
|
207
259
|
add("--font-sans", "font");
|
|
208
260
|
add("--font-mono", "font");
|
|
209
261
|
add("--font-display", "font");
|
|
@@ -237,10 +289,6 @@ const { produces: PRODUCES, categories: CATEGORIES } = buildProduces();
|
|
|
237
289
|
export const KEYWORD_DOMAINS = {
|
|
238
290
|
"--selection-cue": ["tint", "marker"],
|
|
239
291
|
};
|
|
240
|
-
function stepLightness(base, scheme, step, index) {
|
|
241
|
-
const direction = scheme === "dark" ? 1 : -1;
|
|
242
|
-
return base + direction * step * index;
|
|
243
|
-
}
|
|
244
292
|
function contrastBandFloor(knobs) {
|
|
245
293
|
const band = knobs.contrastBand;
|
|
246
294
|
if (typeof band === "number")
|
|
@@ -737,7 +785,32 @@ function resolveStatusHue(role, pinned) {
|
|
|
737
785
|
const pin = parseChromaticPin(pinned[`--${name}`] ?? pinned[`--color-${name}-base`] ?? pinned[`--color-${name}`]);
|
|
738
786
|
return pin ? pin.h : paletteHueAngle(name);
|
|
739
787
|
}
|
|
788
|
+
/**
|
|
789
|
+
* A single derivation is pure in `(preset, opts)`, and a live editor asks for the same one
|
|
790
|
+
* several ways at once: `derive` resolves the graph, `lineage` reads its edges, an inspector
|
|
791
|
+
* reads it again. Without this they each pay a full OKLCH pass over the whole register. The
|
|
792
|
+
* cache is per-preset and bounded — a slider drag mints a new key per settled value, so it
|
|
793
|
+
* evicts oldest-first rather than growing for the life of the page.
|
|
794
|
+
*/
|
|
795
|
+
const GRAPH_CACHE_LIMIT = 16;
|
|
796
|
+
const graphCaches = new WeakMap();
|
|
740
797
|
export function buildGraph(preset, opts) {
|
|
798
|
+
let cache = graphCaches.get(preset);
|
|
799
|
+
if (!cache)
|
|
800
|
+
graphCaches.set(preset, (cache = new Map()));
|
|
801
|
+
const key = JSON.stringify(opts ?? {});
|
|
802
|
+
const hit = cache.get(key);
|
|
803
|
+
if (hit)
|
|
804
|
+
return hit;
|
|
805
|
+
const nodes = buildGraphUncached(preset, opts);
|
|
806
|
+
cache.set(key, nodes);
|
|
807
|
+
if (cache.size > GRAPH_CACHE_LIMIT) {
|
|
808
|
+
const oldest = cache.keys().next().value;
|
|
809
|
+
cache.delete(oldest);
|
|
810
|
+
}
|
|
811
|
+
return nodes;
|
|
812
|
+
}
|
|
813
|
+
function buildGraphUncached(preset, opts) {
|
|
741
814
|
const completed = completeAnchors(preset, opts);
|
|
742
815
|
const bg = completed.bg;
|
|
743
816
|
const fgAnchor = completed.fg;
|
|
@@ -745,8 +818,7 @@ export function buildGraph(preset, opts) {
|
|
|
745
818
|
const accent = pinned["--accent"] ? toOklchColor(pinned["--accent"]) : completed.accent;
|
|
746
819
|
const scheme = completed.scheme;
|
|
747
820
|
const knobs = opts.knobs ?? {};
|
|
748
|
-
const
|
|
749
|
-
const accentSplit = typeof knobs.accentSplit === "number" ? knobs.accentSplit : DEFAULT_ACCENT_SPLIT;
|
|
821
|
+
const { strategy, split: accentSplit, shiftStep } = resolveAccentKnobs(preset, knobs);
|
|
750
822
|
const band = contrastBandFloor(knobs);
|
|
751
823
|
const floor = Math.max(ENFORCE, preset.contrastFloor, (band ?? 0) + 0.2);
|
|
752
824
|
const extreme = preset.extreme === true;
|
|
@@ -758,6 +830,15 @@ export function buildGraph(preset, opts) {
|
|
|
758
830
|
const density = densityOf(knobs);
|
|
759
831
|
const fonts = fontsOf(knobs);
|
|
760
832
|
const surfaceStep = 0.045;
|
|
833
|
+
// The signed lightness delta the surface stack walks from `--bg-0`. Unset, it resolves to the
|
|
834
|
+
// scheme-derived direction (dark ascends, light descends) at the default magnitude, so output is
|
|
835
|
+
// unchanged; set, the author's sign wins and the whole stack (body-bg, bg-1/2/3, bg-sunken)
|
|
836
|
+
// follows the one number instead of six hand-pinned surfaces.
|
|
837
|
+
const surfaceRamp = typeof knobs.surfaceRamp === "number"
|
|
838
|
+
? knobs.surfaceRamp
|
|
839
|
+
: scheme === "dark"
|
|
840
|
+
? surfaceStep
|
|
841
|
+
: -surfaceStep;
|
|
761
842
|
const nodes = [];
|
|
762
843
|
const lit = (name, value, refs) => {
|
|
763
844
|
nodes.push(refs && refs.length ? { name, value, refs } : { name, value });
|
|
@@ -769,14 +850,13 @@ export function buildGraph(preset, opts) {
|
|
|
769
850
|
? toOklchColor(pinned["--bg-0"])
|
|
770
851
|
: extreme
|
|
771
852
|
? oklch(scheme === "dark" ? 0 : 1, 0, 0)
|
|
772
|
-
: ensureTextHeadroom(withLightness(bg,
|
|
853
|
+
: ensureTextHeadroom(withLightness(bg, bg.l + surfaceRamp), scheme, floor);
|
|
773
854
|
const pageFloor = (fill) => separateFillFromSurface(fill, bg0, SURFACE_SEPARATION, floor);
|
|
774
|
-
const
|
|
775
|
-
const surfaceColors = SURFACES.map((_, index) => withLightness(bg0, bg0.l + direction * surfaceStep * (index - 1)));
|
|
855
|
+
const surfaceColors = SURFACES.map((_, index) => withLightness(bg0, bg0.l + surfaceRamp * (index - 1)));
|
|
776
856
|
SURFACES.forEach((name, index) => {
|
|
777
857
|
lit(name, formatCss(surfaceColors[index]), refIfPinned("--bg-0"));
|
|
778
858
|
});
|
|
779
|
-
lit("--bg-sunken", formatCss(withLightness(bg0, bg0.l -
|
|
859
|
+
lit("--bg-sunken", formatCss(withLightness(bg0, bg0.l - surfaceRamp * 2)), refIfPinned("--bg-0"));
|
|
780
860
|
lit("--scrim", formatCss(oklch(scheme === "dark" ? 0 : 0.1, 0, 0, 0.6)));
|
|
781
861
|
const overlayBase = withLightness(bg0, scheme === "dark" ? bg0.l + 0.07 : bg0.l + 0.03);
|
|
782
862
|
lit("--surface-overlay", formatCss(overlayBase), refIfPinned("--bg-0"));
|
|
@@ -897,7 +977,11 @@ export function buildGraph(preset, opts) {
|
|
|
897
977
|
const line2Seed = extreme
|
|
898
978
|
? oklch(scheme === "dark" ? 0.85 : 0.15, 0, 0)
|
|
899
979
|
: withLightness(bg0, scheme === "dark" ? bg0.l + 0.2 : bg0.l - 0.2);
|
|
900
|
-
|
|
980
|
+
const line2Color = borderForContrast(line2Seed, bg0, DIVIDER_SEPARATION);
|
|
981
|
+
lit("--line-2", formatCss(line2Color), refIfPinned("--bg-0"));
|
|
982
|
+
lit("--scrollbar-track", "transparent");
|
|
983
|
+
lit("--scrollbar-thumb", formatCss(line2Color), ["--line-2", ...refIfPinned("--bg-0")]);
|
|
984
|
+
lit("--scrollbar-thumb-hover", formatCss(withLightness(line2Color, line2Color.l + (scheme === "dark" ? 0.12 : -0.12))), ["--scrollbar-thumb"]);
|
|
901
985
|
lit("--ring", formatCss(withAlpha(accentFill, 0.7)), ["--accent"]);
|
|
902
986
|
lit("--ring-bg", formatCss(withAlpha(accentFill, 0.18)), ["--accent"]);
|
|
903
987
|
const fieldBg = withLightness(bg0, scheme === "dark" ? bg0.l - 0.03 : bg0.l + 0.02);
|
|
@@ -937,13 +1021,14 @@ export function buildGraph(preset, opts) {
|
|
|
937
1021
|
let a2;
|
|
938
1022
|
let a3;
|
|
939
1023
|
let a4;
|
|
940
|
-
// The lineage edges differ per
|
|
941
|
-
//
|
|
942
|
-
//
|
|
1024
|
+
// The lineage edges differ per strategy: a `fan`'s 2/3 flank the accent and 4 is its complement
|
|
1025
|
+
// (all off `--accent`, so a pinned flank pulls its mirror in), a `step` chains 3 off 2 and 4 off 3,
|
|
1026
|
+
// and a `duo` reads *both* anchors into each shade. Declared per-branch so `lineage()` names what
|
|
1027
|
+
// each token actually reads.
|
|
943
1028
|
let a2Refs;
|
|
944
1029
|
let a3Refs;
|
|
945
1030
|
let a4Refs;
|
|
946
|
-
if (
|
|
1031
|
+
if (strategy === "fan") {
|
|
947
1032
|
// The two flanks are symmetric either way: pin either wing and the other mirrors its hue
|
|
948
1033
|
// across the accent, so the fan stays balanced around the author's choice. With neither
|
|
949
1034
|
// pinned it's the default ∓split; with both pinned each holds its own value. Lightness and
|
|
@@ -964,10 +1049,56 @@ export function buildGraph(preset, opts) {
|
|
|
964
1049
|
a3Refs = a2Pin && !a3Pin ? ["--accent", "--accent-2"] : ["--accent"];
|
|
965
1050
|
a4Refs = ["--accent"];
|
|
966
1051
|
}
|
|
1052
|
+
else if (strategy === "shade") {
|
|
1053
|
+
// 2/3/4 hold the accent's hue and step its lightness: a tint one step up, two shades down, so
|
|
1054
|
+
// the fan reads as one brand color in four depths. The separation is on lightness, so a
|
|
1055
|
+
// near-gray accent still fans into four distinguishable rungs where a hue rotation is a no-op.
|
|
1056
|
+
// Each rung reads off `--accent` and is independently pinnable.
|
|
1057
|
+
a2 = fanned("2", applyAccentDelta(fanBase, { dL: SHADE_LADDER_L_STEP, dC: 0, dH: 0 }));
|
|
1058
|
+
a3 = fanned("3", applyAccentDelta(fanBase, { dL: -SHADE_LADDER_L_STEP, dC: 0, dH: 0 }));
|
|
1059
|
+
a4 = fanned("4", applyAccentDelta(fanBase, { dL: -2 * SHADE_LADDER_L_STEP, dC: 0, dH: 0 }));
|
|
1060
|
+
a2Refs = ["--accent"];
|
|
1061
|
+
a3Refs = ["--accent"];
|
|
1062
|
+
a4Refs = ["--accent"];
|
|
1063
|
+
}
|
|
1064
|
+
else if (strategy === "duo") {
|
|
1065
|
+
// Two brand colors, not one. `--accent` and `--accent-2` are both *inputs* — the only strategy
|
|
1066
|
+
// where a fan slot is an anchor rather than an output — and 3/4 are their shades. Unpinned,
|
|
1067
|
+
// `--accent-2` still has to come from somewhere, so it falls out of `--accent` by the same fan
|
|
1068
|
+
// distance the split uses; a duo theme that never sets a second color is just a fan that kept
|
|
1069
|
+
// two of its wings.
|
|
1070
|
+
//
|
|
1071
|
+
// The shades are placed against the *pair's* mean lightness rather than each anchor's own, which
|
|
1072
|
+
// is what makes this more than two ladders side by side: both land on one common lightness, so
|
|
1073
|
+
// they read as a matched secondary pair belonging to the same system. They step away from the
|
|
1074
|
+
// surface (up from a dark scheme, down from a light one) and flip if that pole has no headroom
|
|
1075
|
+
// left, so a pair of already-light brand colors on a light theme still yields separable rungs.
|
|
1076
|
+
a2 = fanned("2", applyAccentDelta(fanBase, rotate(accentSplit)));
|
|
1077
|
+
const midL = (a1.l + a2.l) / 2;
|
|
1078
|
+
const away = scheme === "dark" ? 1 : -1;
|
|
1079
|
+
const room = (dir) => {
|
|
1080
|
+
const target = midL + dir * DUO_L_STEP;
|
|
1081
|
+
return target <= ACCENT_RAMP_L_MAX && target >= ACCENT_RAMP_L_MIN;
|
|
1082
|
+
};
|
|
1083
|
+
const dir = room(away) ? away : -away;
|
|
1084
|
+
const shadeL = Math.min(ACCENT_RAMP_L_MAX, Math.max(ACCENT_RAMP_L_MIN, midL + dir * DUO_L_STEP));
|
|
1085
|
+
const shadeOf = (brand) => ({
|
|
1086
|
+
l: shadeL,
|
|
1087
|
+
c: Math.max(brand.c, FAN_MIN_CHROMA),
|
|
1088
|
+
h: brand.h,
|
|
1089
|
+
alpha: 1,
|
|
1090
|
+
});
|
|
1091
|
+
a3 = fanned("3", shadeOf(a1));
|
|
1092
|
+
a4 = fanned("4", shadeOf(a2));
|
|
1093
|
+
a2Refs = ["--accent"];
|
|
1094
|
+
// Both shades read both anchors: the hue is one brand's, the lightness is the pair's mean.
|
|
1095
|
+
a3Refs = ["--accent", "--accent-2"];
|
|
1096
|
+
a4Refs = ["--accent-2", "--accent"];
|
|
1097
|
+
}
|
|
967
1098
|
else {
|
|
968
|
-
//
|
|
969
|
-
//
|
|
970
|
-
// chromatic accent has `fanBase === a1`, so the step stays byte-identical.
|
|
1099
|
+
// `step`: each accent is one hue-step past the last. Chaining off `fanBase` (not `a1`) keeps the
|
|
1100
|
+
// whole walk at the floored chroma for a near-gray accent instead of escalating it down the
|
|
1101
|
+
// chain; a chromatic accent has `fanBase === a1`, so the step stays byte-identical.
|
|
971
1102
|
a2 = fanned("2", applyAccentDelta(fanBase, rotate(shiftStep)));
|
|
972
1103
|
a3 = fanned("3", applyAccentDelta(a2, accentDelta(fanBase, a2)));
|
|
973
1104
|
a4 = fanned("4", applyAccentDelta(a3, accentDelta(a2, a3)));
|
|
@@ -1098,15 +1229,15 @@ export function buildGraph(preset, opts) {
|
|
|
1098
1229
|
const codeTowardLight = contrast("#ffffff", codeBgCss) >= contrast("#000000", codeBgCss);
|
|
1099
1230
|
const codePole = codeTowardLight ? 1 : 0;
|
|
1100
1231
|
const codeFloor = AA;
|
|
1101
|
-
const
|
|
1232
|
+
const readableHuedOn = (bgCss, pole, l, c, h, fl) => {
|
|
1102
1233
|
const seed = oklch(l, c, h);
|
|
1103
1234
|
let best = seed;
|
|
1104
|
-
let bestContrast = emittedContrast(seed,
|
|
1235
|
+
let bestContrast = emittedContrast(seed, bgCss);
|
|
1105
1236
|
if (bestContrast >= fl)
|
|
1106
1237
|
return seed;
|
|
1107
1238
|
for (let i = 1; i <= 100; i++) {
|
|
1108
|
-
const cand = withLightness(seed, seed.l + (
|
|
1109
|
-
const ct = emittedContrast(cand,
|
|
1239
|
+
const cand = withLightness(seed, seed.l + (pole - seed.l) * (i / 100));
|
|
1240
|
+
const ct = emittedContrast(cand, bgCss);
|
|
1110
1241
|
if (ct >= fl)
|
|
1111
1242
|
return cand;
|
|
1112
1243
|
if (ct > bestContrast) {
|
|
@@ -1116,6 +1247,7 @@ export function buildGraph(preset, opts) {
|
|
|
1116
1247
|
}
|
|
1117
1248
|
return best;
|
|
1118
1249
|
};
|
|
1250
|
+
const readableHuedOnCode = (l, c, h, fl) => readableHuedOn(codeBgCss, codePole, l, c, h, fl);
|
|
1119
1251
|
const codeChroma = Math.max(0.08, Math.max(0.1, accent.c) * (0.7 + vibrancy * 0.7) * preset.paletteChromaMul);
|
|
1120
1252
|
// A near-gray accent has no hue to anchor the spread to, so seed the code wheel
|
|
1121
1253
|
// from the fallback hue rather than letting `NaN` collapse every scope to one ink.
|
|
@@ -1145,6 +1277,42 @@ export function buildGraph(preset, opts) {
|
|
|
1145
1277
|
lit("--code-operator", formatCss(readableHuedOnCode(codeBaseL, codeChroma * 0.5, codeBaseHue, codeFloor)), ["--accent", "--code-bg"]);
|
|
1146
1278
|
lit("--code-punctuation", formatCss(enforceContrastFloor(withLightness(codeFg, codeFg.l + (codePole - codeFg.l) * 0.18), codeBg, scheme, codeFloor)), ["--code-fg", "--code-bg"]);
|
|
1147
1279
|
lit("--code-variable", codeFgCss, ["--code-fg"]);
|
|
1280
|
+
const terminalBg = ensureTextHeadroom(withLightness(bg0, scheme === "dark" ? bg0.l - 0.035 : bg0.l + 0.02), scheme, floor);
|
|
1281
|
+
const terminalBgCss = formatCss(terminalBg);
|
|
1282
|
+
lit("--terminal-bg", terminalBgCss, refIfPinned("--bg-0"));
|
|
1283
|
+
const terminalFg = enforceContrastFloor(fg0, terminalBg, scheme, floor);
|
|
1284
|
+
lit("--terminal-fg", formatCss(terminalFg), ["--fg-0", ...refIfPinned("--bg-0")]);
|
|
1285
|
+
// A block cursor reads as the accent; the glyph under it flips to whichever pole
|
|
1286
|
+
// stays legible against that block.
|
|
1287
|
+
const terminalCursor = separateFillFromSurface(accentFill, terminalBg, SURFACE_SEPARATION, floor);
|
|
1288
|
+
lit("--terminal-cursor", formatCss(terminalCursor), ["--accent"]);
|
|
1289
|
+
lit("--terminal-cursor-accent", pickReadable(terminalCursor, TEXT_POLES, floor), ["--accent"]);
|
|
1290
|
+
// The six chromatic slots sit at a mid band that clears AA on the terminal bg; the
|
|
1291
|
+
// bright tier pushes each toward the readable pole (and up in chroma) so bright and
|
|
1292
|
+
// normal stay separable while both stay legible.
|
|
1293
|
+
const terminalTowardLight = contrast("#ffffff", terminalBgCss) >= contrast("#000000", terminalBgCss);
|
|
1294
|
+
const terminalPole = terminalTowardLight ? 1 : 0;
|
|
1295
|
+
const terminalFloor = AA;
|
|
1296
|
+
const terminalChroma = Math.max(0.07, Math.max(0.1, accent.c) * (0.55 + vibrancy * 0.7) * preset.paletteChromaMul);
|
|
1297
|
+
const terminalNormalL = terminalTowardLight ? 0.5 : 0.62;
|
|
1298
|
+
const terminalBrightL = terminalNormalL + (terminalPole - terminalNormalL) * 0.34;
|
|
1299
|
+
for (const name of ANSI_CHROMATIC) {
|
|
1300
|
+
const hue = ANSI_HUES[name];
|
|
1301
|
+
const normal = readableHuedOn(terminalBgCss, terminalPole, terminalNormalL, terminalChroma, hue, terminalFloor);
|
|
1302
|
+
const bright = readableHuedOn(terminalBgCss, terminalPole, terminalBrightL, terminalChroma * 1.08, hue, terminalFloor);
|
|
1303
|
+
lit(`--terminal-${name}`, formatCss(normal), ["--accent", "--terminal-bg"]);
|
|
1304
|
+
lit(`--terminal-bright-${name}`, formatCss(bright), ["--accent", "--terminal-bg"]);
|
|
1305
|
+
}
|
|
1306
|
+
// `black` and `white` are the achromatic endpoints — a terminal uses them as
|
|
1307
|
+
// fills / ink, not as legible-on-bg scopes, so they anchor to fixed dark / light
|
|
1308
|
+
// lightnesses (carrying a whisper of the bg hue for cohesion) rather than sweeping
|
|
1309
|
+
// for contrast like the chromatic slots.
|
|
1310
|
+
const terminalHue = Number.isFinite(bg0.h) ? bg0.h : 0;
|
|
1311
|
+
const terminalAchroma = (l) => oklch(l, 0.006, terminalHue);
|
|
1312
|
+
lit("--terminal-black", formatCss(terminalAchroma(0.2)), refIfPinned("--bg-0"));
|
|
1313
|
+
lit("--terminal-bright-black", formatCss(terminalAchroma(0.42)), refIfPinned("--bg-0"));
|
|
1314
|
+
lit("--terminal-white", formatCss(terminalAchroma(0.85)), ["--fg-0"]);
|
|
1315
|
+
lit("--terminal-bright-white", formatCss(terminalAchroma(0.97)), ["--fg-0"]);
|
|
1148
1316
|
lit("--font-sans", fonts.sans);
|
|
1149
1317
|
lit("--font-mono", fonts.mono);
|
|
1150
1318
|
lit("--font-display", fonts.display);
|
|
@@ -1778,27 +1946,32 @@ export function makeInvariants(preset) {
|
|
|
1778
1946
|
if (accent.c < HUE_STABLE_CHROMA) {
|
|
1779
1947
|
return { name, ok: true };
|
|
1780
1948
|
}
|
|
1781
|
-
const step =
|
|
1782
|
-
? ctx.knobs.accentShiftStep
|
|
1783
|
-
: DEFAULT_SHIFT_STEP;
|
|
1784
|
-
const split = typeof ctx.knobs.accentSplit === "number"
|
|
1785
|
-
? ctx.knobs.accentSplit
|
|
1786
|
-
: DEFAULT_ACCENT_SPLIT;
|
|
1949
|
+
const { strategy, split, shiftStep: step } = resolveAccentKnobs(preset, ctx.knobs);
|
|
1787
1950
|
const accent2Value = ctx.register["--accent-2"];
|
|
1788
1951
|
const accent3Value = ctx.register["--accent-3"];
|
|
1789
1952
|
const pinnedAccent2 = ctx.constraints["--accent-2"] && accent2Value ? toOklchColor(accent2Value) : null;
|
|
1790
1953
|
const pinnedAccent3 = ctx.constraints["--accent-3"] && accent3Value ? toOklchColor(accent3Value) : null;
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1954
|
+
// The hue each slot owes the accent. A `shade` holds one hue and steps lightness, so every
|
|
1955
|
+
// rung wants the accent's own. A `duo` carries two hues: 3 is brand one's (the accent's), 4 is
|
|
1956
|
+
// brand two's — whatever `--accent-2` actually landed on, pinned or derived.
|
|
1957
|
+
const duoSecondHue = () => pinnedAccent2 ? hueDelta(accent.h, pinnedAccent2.h) : split;
|
|
1958
|
+
const fanOffset = (n) => {
|
|
1959
|
+
if (strategy === "shade")
|
|
1960
|
+
return 0;
|
|
1961
|
+
if (strategy === "step")
|
|
1962
|
+
return step * (n - 1);
|
|
1963
|
+
// 3 shades brand one (the accent's own hue); 2 and 4 are brand two's.
|
|
1964
|
+
if (strategy === "duo")
|
|
1965
|
+
return n === 3 ? 0 : duoSecondHue();
|
|
1966
|
+
if (n === 2)
|
|
1967
|
+
return pinnedAccent3 ? -hueDelta(accent.h, pinnedAccent3.h) : -split;
|
|
1968
|
+
if (n === 3)
|
|
1969
|
+
return pinnedAccent2 ? -hueDelta(accent.h, pinnedAccent2.h) : split;
|
|
1970
|
+
return 180;
|
|
1971
|
+
};
|
|
1972
|
+
// `shade` and `duo` both deliberately move lightness off the accent's, so the constant-L/C
|
|
1973
|
+
// checks below belong only to the hue-rotating postures.
|
|
1974
|
+
const stepsLightness = strategy === "shade" || strategy === "duo";
|
|
1802
1975
|
for (let n = 2; n <= 4; n++) {
|
|
1803
1976
|
if (ctx.constraints[`--accent-${n}`])
|
|
1804
1977
|
continue;
|
|
@@ -1819,21 +1992,25 @@ export function makeInvariants(preset) {
|
|
|
1819
1992
|
};
|
|
1820
1993
|
}
|
|
1821
1994
|
}
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1995
|
+
// A lightness-stepping strategy gamut-clamps chroma per rung, so only the shared-hue check
|
|
1996
|
+
// above is a promise it makes; the constant-L/C pair below is the hue-fan postures' promise.
|
|
1997
|
+
if (!stepsLightness) {
|
|
1998
|
+
if (Math.abs(rotated.l - accent.l) > LIGHTNESS_TOLERANCE) {
|
|
1999
|
+
return {
|
|
2000
|
+
name,
|
|
2001
|
+
ok: false,
|
|
2002
|
+
detail: `--accent-${n} l=${rotated.l.toFixed(3)} want ${accent.l.toFixed(3)}`,
|
|
2003
|
+
};
|
|
2004
|
+
}
|
|
2005
|
+
const maxChroma = clampToGamut({ l: accent.l, c: accent.c, h: wantH, alpha: 1 }).c;
|
|
2006
|
+
const expectedChroma = Math.min(accent.c, maxChroma);
|
|
2007
|
+
if (Math.abs(rotated.c - expectedChroma) > 0.02) {
|
|
2008
|
+
return {
|
|
2009
|
+
name,
|
|
2010
|
+
ok: false,
|
|
2011
|
+
detail: `--accent-${n} chroma ${rotated.c.toFixed(3)} want max-at-hue ${expectedChroma.toFixed(3)}`,
|
|
2012
|
+
};
|
|
2013
|
+
}
|
|
1837
2014
|
}
|
|
1838
2015
|
}
|
|
1839
2016
|
return { name, ok: true };
|
|
@@ -2109,6 +2286,51 @@ export function makeInvariants(preset) {
|
|
|
2109
2286
|
}
|
|
2110
2287
|
return { name, ok: true };
|
|
2111
2288
|
},
|
|
2289
|
+
(ctx) => {
|
|
2290
|
+
const name = "terminal palette readable on --terminal-bg";
|
|
2291
|
+
const bg = ctx.register["--terminal-bg"];
|
|
2292
|
+
if (!bg)
|
|
2293
|
+
return { name, ok: false, detail: "--terminal-bg missing" };
|
|
2294
|
+
const readFloor = achievableFloor(AA, bg);
|
|
2295
|
+
const inks = [
|
|
2296
|
+
"--terminal-fg",
|
|
2297
|
+
...ANSI_CHROMATIC.map((n) => `--terminal-${n}`),
|
|
2298
|
+
...ANSI_CHROMATIC.map((n) => `--terminal-bright-${n}`),
|
|
2299
|
+
];
|
|
2300
|
+
for (const token of inks) {
|
|
2301
|
+
const v = ctx.register[token];
|
|
2302
|
+
const ratio = v ? contrast(v, bg) : 0;
|
|
2303
|
+
if (ratio < readFloor - 0.05) {
|
|
2304
|
+
return { name, ok: false, detail: `${token} on --terminal-bg = ${ratio.toFixed(2)} (floor ${readFloor.toFixed(2)})` };
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
return { name, ok: true };
|
|
2308
|
+
},
|
|
2309
|
+
(ctx) => {
|
|
2310
|
+
// OKLab distance, not WCAG contrast — two equally-light hues (a red and a green
|
|
2311
|
+
// both readable on the bg) can still be one indistinguishable colour to a reader.
|
|
2312
|
+
// Floored under the muted reality (the warm red/magenta pair converges to ~0.020
|
|
2313
|
+
// once a low-chroma seed floors the palette), so it guards a real collapse, not the
|
|
2314
|
+
// legitimate warm-family closeness a muted terminal skin is allowed.
|
|
2315
|
+
const name = "terminal ANSI hues mutually distinguishable";
|
|
2316
|
+
const MIN_DE = 0.012;
|
|
2317
|
+
const slots = ANSI_CHROMATIC.map((n) => `--terminal-${n}`);
|
|
2318
|
+
for (let i = 0; i < slots.length; i++) {
|
|
2319
|
+
for (let j = i + 1; j < slots.length; j++) {
|
|
2320
|
+
const ni = slots[i];
|
|
2321
|
+
const nj = slots[j];
|
|
2322
|
+
const a = ctx.register[ni];
|
|
2323
|
+
const b = ctx.register[nj];
|
|
2324
|
+
if (!a || !b)
|
|
2325
|
+
continue;
|
|
2326
|
+
const d = oklabDist(a, b);
|
|
2327
|
+
if (d < MIN_DE) {
|
|
2328
|
+
return { name, ok: false, detail: `${ni} vs ${nj} ΔE=${d.toFixed(4)} (min ${MIN_DE})` };
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2332
|
+
return { name, ok: true };
|
|
2333
|
+
},
|
|
2112
2334
|
(ctx) => {
|
|
2113
2335
|
// Mistaking success for danger is a usability failure WCAG contrast can't see — two
|
|
2114
2336
|
// equally-light status hues read as one. Floored well under the muted reality
|
|
@@ -2154,6 +2376,7 @@ export function makeXtylePipelineAlgorithm(preset, buildPasses) {
|
|
|
2154
2376
|
id: preset.id,
|
|
2155
2377
|
produces: PRODUCES,
|
|
2156
2378
|
knobs: preset.knobs,
|
|
2379
|
+
knobSpecs: resolveKnobSpecs(preset.knobs, preset.knobSpecs),
|
|
2157
2380
|
categories: CATEGORIES,
|
|
2158
2381
|
derive: (opts = {}) => run(opts).register,
|
|
2159
2382
|
lineage: (opts = {}) => singlePass
|
|
@@ -2169,6 +2392,8 @@ export function makeXtyleAlgorithm(preset) {
|
|
|
2169
2392
|
}
|
|
2170
2393
|
export const SHARED_KNOBS = [
|
|
2171
2394
|
"scheme",
|
|
2395
|
+
"surfaceRamp",
|
|
2396
|
+
"accentStrategy",
|
|
2172
2397
|
"accentShiftStep",
|
|
2173
2398
|
"accentSplit",
|
|
2174
2399
|
"contrastBand",
|
|
@@ -2180,6 +2405,95 @@ export const SHARED_KNOBS = [
|
|
|
2180
2405
|
"fonts",
|
|
2181
2406
|
"anchors",
|
|
2182
2407
|
];
|
|
2408
|
+
/**
|
|
2409
|
+
* The rendered *domain* of every knob the shared xtyle derivation reads — the kind, range, and
|
|
2410
|
+
* accepted values a consumer needs to build a control. `hour` is included so `nxi-nite` resolves
|
|
2411
|
+
* it from here without declaring its own spec. `fonts` and `anchors` are absent by design: they
|
|
2412
|
+
* are composite groups a consumer expands into multiple controls (font stacks, anchor pickers),
|
|
2413
|
+
* not single scalar knobs, so their orchestration stays with the consumer. Cosmetic concerns
|
|
2414
|
+
* (localized labels, unit suffixes, digit precision) are deliberately not here — they belong to
|
|
2415
|
+
* the consumer; the `label` hints below are just defaults a consumer may override.
|
|
2416
|
+
*/
|
|
2417
|
+
export const SHARED_KNOB_SPECS = [
|
|
2418
|
+
{
|
|
2419
|
+
name: "scheme",
|
|
2420
|
+
kind: "select",
|
|
2421
|
+
label: "Scheme",
|
|
2422
|
+
options: [
|
|
2423
|
+
{ value: "dark", label: "dark" },
|
|
2424
|
+
{ value: "light", label: "light" },
|
|
2425
|
+
],
|
|
2426
|
+
},
|
|
2427
|
+
{
|
|
2428
|
+
name: "contrastBand",
|
|
2429
|
+
kind: "select",
|
|
2430
|
+
label: "Contrast band",
|
|
2431
|
+
default: "aa",
|
|
2432
|
+
options: [
|
|
2433
|
+
{ value: "aa", label: "AA" },
|
|
2434
|
+
{ value: "aaa", label: "AAA" },
|
|
2435
|
+
],
|
|
2436
|
+
},
|
|
2437
|
+
{
|
|
2438
|
+
name: "density",
|
|
2439
|
+
kind: "select",
|
|
2440
|
+
label: "Density",
|
|
2441
|
+
default: "normal",
|
|
2442
|
+
options: [
|
|
2443
|
+
{ value: "compact", label: "compact" },
|
|
2444
|
+
{ value: "normal", label: "normal" },
|
|
2445
|
+
{ value: "comfortable", label: "comfortable" },
|
|
2446
|
+
],
|
|
2447
|
+
},
|
|
2448
|
+
{
|
|
2449
|
+
name: "cues",
|
|
2450
|
+
kind: "select",
|
|
2451
|
+
label: "Cues",
|
|
2452
|
+
default: "color",
|
|
2453
|
+
options: [
|
|
2454
|
+
{ value: "color", label: "color only" },
|
|
2455
|
+
{ value: "redundant", label: "redundant markers" },
|
|
2456
|
+
],
|
|
2457
|
+
},
|
|
2458
|
+
{
|
|
2459
|
+
name: "accentStrategy",
|
|
2460
|
+
kind: "select",
|
|
2461
|
+
label: "Accent strategy",
|
|
2462
|
+
options: [
|
|
2463
|
+
{ value: "fan", label: "fan (flanks + complement)" },
|
|
2464
|
+
{ value: "step", label: "step (even hue wheel)" },
|
|
2465
|
+
{ value: "shade", label: "shade (one hue, four depths)" },
|
|
2466
|
+
{ value: "duo", label: "duo (two brands + their shades)" },
|
|
2467
|
+
],
|
|
2468
|
+
},
|
|
2469
|
+
{ name: "vibrancy", kind: "range", label: "Vibrancy", min: 0, max: 1, step: 0.05, default: 0.5 },
|
|
2470
|
+
{ name: "typeScale", kind: "range", label: "Type scale", min: 1.05, max: 1.6, step: 0.01, default: 1.2 },
|
|
2471
|
+
{ name: "radiusScale", kind: "range", label: "Radius scale", min: 0, max: 3, step: 0.1, default: 1 },
|
|
2472
|
+
{ name: "surfaceRamp", kind: "range", label: "Surface ramp", min: -0.06, max: 0.06, step: 0.005, default: 0.045 },
|
|
2473
|
+
// The defaults are the engine's own constants, not a second copy of them: a slider that opens on a
|
|
2474
|
+
// value the derivation does not actually use is a lie the control surface tells about the engine.
|
|
2475
|
+
{ name: "accentSplit", kind: "range", label: "Accent split", min: 0, max: 90, step: 1, default: DEFAULT_ACCENT_SPLIT, unit: "°" },
|
|
2476
|
+
{ name: "accentShiftStep", kind: "range", label: "Accent shift step", min: 0, max: 180, step: 5, default: DEFAULT_SHIFT_STEP, unit: "°" },
|
|
2477
|
+
{ name: "hour", kind: "range", label: "Hour", min: 0, max: 24, step: 1, default: 12 },
|
|
2478
|
+
];
|
|
2479
|
+
const SHARED_KNOB_SPEC_BY_NAME = new Map(SHARED_KNOB_SPECS.map((spec) => [spec.name, spec]));
|
|
2480
|
+
/**
|
|
2481
|
+
* Resolve a declared knob-name list to the render specs a consumer needs. Names that match the
|
|
2482
|
+
* shared registry get its domain; composite groups a consumer expands itself (`anchors`, `fonts`)
|
|
2483
|
+
* resolve to nothing (they carry no single scalar control); a novel knob resolves from `extra` when
|
|
2484
|
+
* the algorithm supplies its own spec. This is the one place a knob name becomes a renderable domain,
|
|
2485
|
+
* so both baked and hosted facades — and a host facade rebuilding from a name list — agree.
|
|
2486
|
+
*/
|
|
2487
|
+
export function resolveKnobSpecs(names, extra = []) {
|
|
2488
|
+
const byName = new Map(extra.map((spec) => [spec.name, spec]));
|
|
2489
|
+
const out = [];
|
|
2490
|
+
for (const name of names) {
|
|
2491
|
+
const spec = byName.get(name) ?? SHARED_KNOB_SPEC_BY_NAME.get(name);
|
|
2492
|
+
if (spec)
|
|
2493
|
+
out.push(spec);
|
|
2494
|
+
}
|
|
2495
|
+
return out;
|
|
2496
|
+
}
|
|
2183
2497
|
export const DEFAULT_ANCHORS = {
|
|
2184
2498
|
bg: "#0f1115",
|
|
2185
2499
|
fg: "#e8eaed",
|