@unpunnyfuns/swatchbook-switcher 0.10.2

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.
@@ -0,0 +1,76 @@
1
+ import { KeyboardEvent, ReactElement } from "react";
2
+
3
+ //#region src/types.d.ts
4
+ /**
5
+ * Structural types the switcher consumes. Mirror the shapes produced by
6
+ * `@unpunnyfuns/swatchbook-core` and by the addon's preview INIT payload —
7
+ * re-declared here so the switcher stays framework-agnostic and doesn't pull
8
+ * core / addon as runtime deps.
9
+ */
10
+ interface SwitcherAxis {
11
+ name: string;
12
+ contexts: readonly string[];
13
+ default: string;
14
+ description?: string;
15
+ source?: 'resolver' | 'layered' | 'synthetic';
16
+ }
17
+ interface SwitcherPreset {
18
+ name: string;
19
+ axes: Partial<Record<string, string>>;
20
+ description?: string;
21
+ }
22
+ interface SwitcherTheme {
23
+ name: string;
24
+ input: Record<string, string>;
25
+ }
26
+ //#endregion
27
+ //#region src/ThemeSwitcher.d.ts
28
+ interface ThemeSwitcherProps {
29
+ /** Project axes the UI renders one section per. */
30
+ axes: readonly SwitcherAxis[];
31
+ /** Saved preset snapshots rendered above the axes, if any. */
32
+ presets?: readonly SwitcherPreset[];
33
+ /** Full theme list — only consulted for the "modified since preset applied" dot. */
34
+ themes?: readonly SwitcherTheme[];
35
+ /** Active axis tuple, keyed by axis name. */
36
+ activeTuple: Readonly<Record<string, string>>;
37
+ /** Default tuple used to fill in omitted preset axes. */
38
+ defaults: Readonly<Record<string, string>>;
39
+ /** Name of the most recently applied preset, or null. Drives the "modified" dot. */
40
+ lastApplied: string | null;
41
+ /** Receives an axis name + new context. */
42
+ onAxisChange(axisName: string, next: string): void;
43
+ /** Called with the full preset object when the user clicks a preset pill. */
44
+ onPresetApply(preset: SwitcherPreset): void;
45
+ /** Optional key handler, usually used by consumers to close a popover on Escape. */
46
+ onKeyDown?(event: KeyboardEvent<HTMLDivElement>): void;
47
+ /** Host-specific content rendered after the axes (e.g. the Storybook addon's color-format picker). */
48
+ footer?: ReactElement | null;
49
+ }
50
+ /**
51
+ * Popover body for the swatchbook theme switcher. Renders preset pills
52
+ * (when the project ships any) and one row per axis. Color-format
53
+ * selection is specific to the Storybook addon (it toggles how blocks
54
+ * stringify colors); hosts that need it slot
55
+ * `<ColorFormatSelector>` into the `footer` prop rather than it being
56
+ * baked into every consumer.
57
+ *
58
+ * Consumers own the trigger + positioning — the switcher just draws
59
+ * the menu. Uses classic JSX so it survives embedding in Storybook's
60
+ * manager bundle (which doesn't expose `react/jsx-runtime`).
61
+ */
62
+ declare function ThemeSwitcher({
63
+ axes,
64
+ presets,
65
+ themes,
66
+ activeTuple,
67
+ defaults,
68
+ lastApplied,
69
+ onAxisChange,
70
+ onPresetApply,
71
+ onKeyDown,
72
+ footer
73
+ }: ThemeSwitcherProps): ReactElement;
74
+ //#endregion
75
+ export { type SwitcherAxis, type SwitcherPreset, type SwitcherTheme, ThemeSwitcher, type ThemeSwitcherProps };
76
+ //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs ADDED
@@ -0,0 +1,109 @@
1
+ import './style.css';
2
+ import cx from "clsx";
3
+ import React from "react";
4
+ //#region src/ThemeSwitcher.tsx
5
+ /**
6
+ * Popover body for the swatchbook theme switcher. Renders preset pills
7
+ * (when the project ships any) and one row per axis. Color-format
8
+ * selection is specific to the Storybook addon (it toggles how blocks
9
+ * stringify colors); hosts that need it slot
10
+ * `<ColorFormatSelector>` into the `footer` prop rather than it being
11
+ * baked into every consumer.
12
+ *
13
+ * Consumers own the trigger + positioning — the switcher just draws
14
+ * the menu. Uses classic JSX so it survives embedding in Storybook's
15
+ * manager bundle (which doesn't expose `react/jsx-runtime`).
16
+ */
17
+ function ThemeSwitcher({ axes, presets = [], themes = [], activeTuple, defaults, lastApplied, onAxisChange, onPresetApply, onKeyDown, footer }) {
18
+ return /* @__PURE__ */ React.createElement("div", {
19
+ role: "menu",
20
+ tabIndex: -1,
21
+ className: "sb-switcher",
22
+ onKeyDown,
23
+ "data-testid": "swatchbook-switcher"
24
+ }, presets.length > 0 && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(PresetsSection, {
25
+ presets,
26
+ axes,
27
+ themes,
28
+ defaults,
29
+ activeTuple,
30
+ lastApplied,
31
+ onApply: onPresetApply
32
+ }), /* @__PURE__ */ React.createElement("div", { className: "sb-switcher__divider" })), axes.map((axis) => /* @__PURE__ */ React.createElement(AxisSection, {
33
+ key: `axis-${axis.name}`,
34
+ axis,
35
+ active: activeTuple[axis.name] ?? axis.default,
36
+ onSelect: (next) => onAxisChange(axis.name, next)
37
+ })), footer && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "sb-switcher__divider" }), footer));
38
+ }
39
+ function OptionPill({ label, active, title, onClick, trailing }) {
40
+ return /* @__PURE__ */ React.createElement("button", {
41
+ type: "button",
42
+ title,
43
+ onClick,
44
+ onMouseDown: (event) => event.preventDefault(),
45
+ className: cx("sb-switcher__pill", active && "sb-switcher__pill--active")
46
+ }, label, trailing ?? null);
47
+ }
48
+ function PresetsSection({ presets, axes, defaults, activeTuple, lastApplied, onApply }) {
49
+ return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { className: "sb-switcher__section-label" }, "Presets"), /* @__PURE__ */ React.createElement("div", { className: "sb-switcher__section-body" }, presets.map((preset) => {
50
+ const matches = tuplesEqual(presetTuple(preset, axes, defaults), activeTuple, axes);
51
+ const modified = !matches && preset.name === lastApplied;
52
+ const title = preset.description ? `${preset.name} — ${preset.description}` : preset.name;
53
+ return /* @__PURE__ */ React.createElement(OptionPill, {
54
+ key: `preset/${preset.name}`,
55
+ label: preset.name,
56
+ active: matches,
57
+ title,
58
+ onClick: () => onApply(preset),
59
+ trailing: modified ? /* @__PURE__ */ React.createElement("span", {
60
+ "aria-hidden": true,
61
+ className: "sb-switcher__pill-modified"
62
+ }) : null
63
+ });
64
+ })));
65
+ }
66
+ function AxisSection({ axis, active, onSelect }) {
67
+ return /* @__PURE__ */ React.createElement("div", { className: "sb-switcher__axis-row" }, /* @__PURE__ */ React.createElement("div", {
68
+ className: "sb-switcher__axis-label",
69
+ title: axis.description
70
+ }, displayLabelFor(axis)), /* @__PURE__ */ React.createElement("div", { className: "sb-switcher__axis-pills" }, axis.contexts.map((ctx) => /* @__PURE__ */ React.createElement(OptionPill, {
71
+ key: `${axis.name}/${ctx}`,
72
+ label: ctx,
73
+ active: ctx === active,
74
+ onClick: () => onSelect(ctx)
75
+ }))));
76
+ }
77
+ /**
78
+ * Treat the `{ name: 'theme', source: 'synthetic' }` axis — the one core
79
+ * fabricates for single-theme projects with no resolver — as a special case
80
+ * that reads as "Theme". Authored single-axis resolvers keep their real
81
+ * name (e.g. `mode`, `brand`).
82
+ */
83
+ function displayLabelFor(axis) {
84
+ if (axis.source === "synthetic" && axis.name === "theme") return "Theme";
85
+ return axis.name;
86
+ }
87
+ /**
88
+ * Compose a preset's sanitized partial tuple with the axis defaults, so
89
+ * applying a preset that only names some axes leaves the omitted ones at
90
+ * their defaults (not blank). Mirrors the addon preview decorator's own
91
+ * fallback logic so what the switcher sends out matches what the host
92
+ * honors.
93
+ */
94
+ function presetTuple(preset, axes, defaults) {
95
+ const out = { ...defaults };
96
+ for (const axis of axes) {
97
+ const candidate = preset.axes[axis.name];
98
+ if (candidate !== void 0 && axis.contexts.includes(candidate)) out[axis.name] = candidate;
99
+ }
100
+ return out;
101
+ }
102
+ function tuplesEqual(a, b, axes) {
103
+ for (const axis of axes) if (a[axis.name] !== b[axis.name]) return false;
104
+ return true;
105
+ }
106
+ //#endregion
107
+ export { ThemeSwitcher };
108
+
109
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/ThemeSwitcher.tsx"],"sourcesContent":["import cx from 'clsx';\nimport React, { type KeyboardEvent, type ReactElement } from 'react';\nimport './ThemeSwitcher.css';\nimport type { SwitcherAxis, SwitcherPreset, SwitcherTheme } from '#/types.ts';\n\nexport interface ThemeSwitcherProps {\n /** Project axes the UI renders one section per. */\n axes: readonly SwitcherAxis[];\n /** Saved preset snapshots rendered above the axes, if any. */\n presets?: readonly SwitcherPreset[];\n /** Full theme list — only consulted for the \"modified since preset applied\" dot. */\n themes?: readonly SwitcherTheme[];\n /** Active axis tuple, keyed by axis name. */\n activeTuple: Readonly<Record<string, string>>;\n /** Default tuple used to fill in omitted preset axes. */\n defaults: Readonly<Record<string, string>>;\n /** Name of the most recently applied preset, or null. Drives the \"modified\" dot. */\n lastApplied: string | null;\n /** Receives an axis name + new context. */\n onAxisChange(axisName: string, next: string): void;\n /** Called with the full preset object when the user clicks a preset pill. */\n onPresetApply(preset: SwitcherPreset): void;\n /** Optional key handler, usually used by consumers to close a popover on Escape. */\n onKeyDown?(event: KeyboardEvent<HTMLDivElement>): void;\n /** Host-specific content rendered after the axes (e.g. the Storybook addon's color-format picker). */\n footer?: ReactElement | null;\n}\n\n/**\n * Popover body for the swatchbook theme switcher. Renders preset pills\n * (when the project ships any) and one row per axis. Color-format\n * selection is specific to the Storybook addon (it toggles how blocks\n * stringify colors); hosts that need it slot\n * `<ColorFormatSelector>` into the `footer` prop rather than it being\n * baked into every consumer.\n *\n * Consumers own the trigger + positioning — the switcher just draws\n * the menu. Uses classic JSX so it survives embedding in Storybook's\n * manager bundle (which doesn't expose `react/jsx-runtime`).\n */\nexport function ThemeSwitcher({\n axes,\n presets = [],\n themes = [],\n activeTuple,\n defaults,\n lastApplied,\n onAxisChange,\n onPresetApply,\n onKeyDown,\n footer,\n}: ThemeSwitcherProps): ReactElement {\n return (\n <div\n role=\"menu\"\n tabIndex={-1}\n className=\"sb-switcher\"\n onKeyDown={onKeyDown}\n data-testid=\"swatchbook-switcher\"\n >\n {presets.length > 0 && (\n <>\n <PresetsSection\n presets={presets}\n axes={axes}\n themes={themes}\n defaults={defaults}\n activeTuple={activeTuple}\n lastApplied={lastApplied}\n onApply={onPresetApply}\n />\n <div className=\"sb-switcher__divider\" />\n </>\n )}\n\n {axes.map((axis) => (\n <AxisSection\n key={`axis-${axis.name}`}\n axis={axis}\n active={activeTuple[axis.name] ?? axis.default}\n onSelect={(next) => onAxisChange(axis.name, next)}\n />\n ))}\n\n {footer && (\n <>\n <div className=\"sb-switcher__divider\" />\n {footer}\n </>\n )}\n </div>\n );\n}\n\ninterface OptionPillProps {\n label: string;\n active: boolean;\n title?: string;\n onClick(): void;\n trailing?: ReactElement | null;\n}\n\nfunction OptionPill({ label, active, title, onClick, trailing }: OptionPillProps): ReactElement {\n return (\n <button\n type=\"button\"\n title={title}\n onClick={onClick}\n // Skip focus on mouse click so host themes that paint a :focus\n // border-color don't stick it on the previously-clicked pill.\n // Keyboard tabbing still lands focus normally; only preventDefault\n // on mousedown blocks the implicit focus-on-click behavior.\n onMouseDown={(event) => event.preventDefault()}\n className={cx('sb-switcher__pill', active && 'sb-switcher__pill--active')}\n >\n {label}\n {trailing ?? null}\n </button>\n );\n}\n\ninterface PresetsSectionProps {\n presets: readonly SwitcherPreset[];\n axes: readonly SwitcherAxis[];\n themes: readonly SwitcherTheme[];\n defaults: Readonly<Record<string, string>>;\n activeTuple: Readonly<Record<string, string>>;\n lastApplied: string | null;\n onApply(preset: SwitcherPreset): void;\n}\n\nfunction PresetsSection({\n presets,\n axes,\n defaults,\n activeTuple,\n lastApplied,\n onApply,\n}: PresetsSectionProps): ReactElement {\n return (\n <div>\n <div className=\"sb-switcher__section-label\">Presets</div>\n <div className=\"sb-switcher__section-body\">\n {presets.map((preset) => {\n const tuple = presetTuple(preset, axes, defaults);\n const matches = tuplesEqual(tuple, activeTuple, axes);\n const modified = !matches && preset.name === lastApplied;\n const title = preset.description ? `${preset.name} — ${preset.description}` : preset.name;\n return (\n <OptionPill\n key={`preset/${preset.name}`}\n label={preset.name}\n active={matches}\n title={title}\n onClick={() => onApply(preset)}\n trailing={\n modified ? <span aria-hidden className=\"sb-switcher__pill-modified\" /> : null\n }\n />\n );\n })}\n </div>\n </div>\n );\n}\n\ninterface AxisSectionProps {\n axis: SwitcherAxis;\n active: string;\n onSelect(next: string): void;\n}\n\nfunction AxisSection({ axis, active, onSelect }: AxisSectionProps): ReactElement {\n return (\n <div className=\"sb-switcher__axis-row\">\n <div className=\"sb-switcher__axis-label\" title={axis.description}>\n {displayLabelFor(axis)}\n </div>\n <div className=\"sb-switcher__axis-pills\">\n {axis.contexts.map((ctx) => (\n <OptionPill\n key={`${axis.name}/${ctx}`}\n label={ctx}\n active={ctx === active}\n onClick={() => onSelect(ctx)}\n />\n ))}\n </div>\n </div>\n );\n}\n\n/**\n * Treat the `{ name: 'theme', source: 'synthetic' }` axis — the one core\n * fabricates for single-theme projects with no resolver — as a special case\n * that reads as \"Theme\". Authored single-axis resolvers keep their real\n * name (e.g. `mode`, `brand`).\n */\nfunction displayLabelFor(axis: SwitcherAxis): string {\n if (axis.source === 'synthetic' && axis.name === 'theme') return 'Theme';\n return axis.name;\n}\n\n/**\n * Compose a preset's sanitized partial tuple with the axis defaults, so\n * applying a preset that only names some axes leaves the omitted ones at\n * their defaults (not blank). Mirrors the addon preview decorator's own\n * fallback logic so what the switcher sends out matches what the host\n * honors.\n */\nfunction presetTuple(\n preset: SwitcherPreset,\n axes: readonly SwitcherAxis[],\n defaults: Readonly<Record<string, string>>,\n): Record<string, string> {\n const out: Record<string, string> = { ...defaults };\n for (const axis of axes) {\n const candidate = preset.axes[axis.name];\n if (candidate !== undefined && axis.contexts.includes(candidate)) {\n out[axis.name] = candidate;\n }\n }\n return out;\n}\n\nfunction tuplesEqual(\n a: Readonly<Record<string, string>>,\n b: Readonly<Record<string, string>>,\n axes: readonly SwitcherAxis[],\n): boolean {\n for (const axis of axes) {\n if (a[axis.name] !== b[axis.name]) return false;\n }\n return true;\n}\n"],"mappings":"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"}
package/dist/style.css ADDED
@@ -0,0 +1,77 @@
1
+ .sb-switcher {
2
+ outline: none;
3
+ min-width: 260px;
4
+ padding: 4px 0;
5
+ }
6
+
7
+ .sb-switcher__section-label {
8
+ text-transform: uppercase;
9
+ letter-spacing: .5px;
10
+ opacity: .6;
11
+ padding: 8px 12px 4px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ .sb-switcher__section-body {
16
+ flex-wrap: wrap;
17
+ gap: 4px;
18
+ padding: 0 12px 10px;
19
+ display: flex;
20
+ }
21
+
22
+ .sb-switcher__axis-row {
23
+ grid-template-columns: max-content 1fr;
24
+ align-items: center;
25
+ gap: 4px 12px;
26
+ padding: 0 12px 10px;
27
+ display: grid;
28
+ }
29
+
30
+ .sb-switcher__axis-label {
31
+ opacity: .85;
32
+ font-size: 12px;
33
+ font-weight: 600;
34
+ }
35
+
36
+ .sb-switcher__axis-pills {
37
+ flex-wrap: wrap;
38
+ gap: 4px;
39
+ display: flex;
40
+ }
41
+
42
+ .sb-switcher__pill {
43
+ cursor: pointer;
44
+ color: inherit;
45
+ box-shadow: none;
46
+ background: none;
47
+ border: 1px solid #0000;
48
+ border-radius: 4px;
49
+ outline: none;
50
+ padding: 3px 8px;
51
+ font-size: 12px;
52
+ line-height: 18px;
53
+ }
54
+
55
+ .sb-switcher__pill--active {
56
+ background: #007aff1f;
57
+ border-color: #007aff73;
58
+ font-weight: 600;
59
+ }
60
+
61
+ .sb-switcher__pill-modified {
62
+ opacity: .6;
63
+ vertical-align: middle;
64
+ background: currentColor;
65
+ border-radius: 50%;
66
+ width: 6px;
67
+ height: 6px;
68
+ margin-left: 6px;
69
+ display: inline-block;
70
+ }
71
+
72
+ .sb-switcher__divider {
73
+ opacity: .1;
74
+ background: currentColor;
75
+ height: 1px;
76
+ margin: 2px 8px;
77
+ }
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@unpunnyfuns/swatchbook-switcher",
3
+ "version": "0.10.2",
4
+ "description": "Framework-agnostic theme-switcher UI for swatchbook — axis pills, preset pills, color-format selector. Consumed by the Storybook addon toolbar and any React host that knows how to set data-attributes on the document.",
5
+ "license": "MIT",
6
+ "author": "unpunnyfuns <unpunnyfuns@gmail.com>",
7
+ "homepage": "https://unpunnyfuns.github.io/swatchbook/",
8
+ "bugs": "https://github.com/unpunnyfuns/swatchbook/issues",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/unpunnyfuns/swatchbook.git",
12
+ "directory": "packages/switcher"
13
+ },
14
+ "keywords": [
15
+ "swatchbook",
16
+ "design-tokens",
17
+ "dtcg",
18
+ "theme-switcher",
19
+ "react"
20
+ ],
21
+ "type": "module",
22
+ "engines": {
23
+ "node": ">=24.14.0"
24
+ },
25
+ "main": "./dist/index.mjs",
26
+ "types": "./dist/index.d.mts",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.mts",
30
+ "import": "./dist/index.mjs"
31
+ },
32
+ "./package.json": "./package.json"
33
+ },
34
+ "imports": {
35
+ "#/*": "./src/*"
36
+ },
37
+ "files": [
38
+ "dist"
39
+ ],
40
+ "sideEffects": [
41
+ "**/*.css"
42
+ ],
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "scripts": {
47
+ "build": "tsdown",
48
+ "typecheck": "tsc --noEmit",
49
+ "test": "vitest run",
50
+ "test:watch": "vitest",
51
+ "lint": "oxlint --deny-warnings -c ../../.oxlintrc.json src test",
52
+ "format": "oxfmt -c ../../.oxfmtrc.json src test",
53
+ "format:check": "oxfmt --check -c ../../.oxfmtrc.json src test"
54
+ },
55
+ "peerDependencies": {
56
+ "react": ">=18"
57
+ },
58
+ "devDependencies": {
59
+ "@testing-library/react": "^16.3.2",
60
+ "@tsdown/css": "^0.21.9",
61
+ "@types/react": "^19.2.14",
62
+ "@vitejs/plugin-react": "^6.0.1",
63
+ "jsdom": "^29.0.2",
64
+ "react": "^19.2.4",
65
+ "react-dom": "^19.2.4",
66
+ "tsdown": "^0.21.9",
67
+ "typescript": "^6.0.0",
68
+ "vitest": "^4.1.4"
69
+ },
70
+ "dependencies": {
71
+ "clsx": "^2.1.1"
72
+ }
73
+ }