@molecule/app-theme-css-variables 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,115 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work.
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship.
43
+
44
+ "Contribution" shall mean any work of authorship, including the
45
+ original version of the Work and any modifications or additions
46
+ to that Work, that is intentionally submitted to the Licensor for
47
+ inclusion in the Work by the copyright owner or by an individual or
48
+ Legal Entity authorized to submit on behalf of the copyright owner.
49
+
50
+ "Contributor" shall mean Licensor and any individual or Legal Entity
51
+ on behalf of whom a Contribution has been received by the Licensor and
52
+ subsequently incorporated within the Work.
53
+
54
+ 2. Grant of Copyright License. Subject to the terms and conditions of
55
+ this License, each Contributor hereby grants to You a perpetual,
56
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
57
+ copyright license to reproduce, prepare Derivative Works of,
58
+ publicly display, publicly perform, sublicense, and distribute the
59
+ Work and such Derivative Works in Source or Object form.
60
+
61
+ 3. Grant of Patent License. Subject to the terms and conditions of
62
+ this License, each Contributor hereby grants to You a perpetual,
63
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
64
+ patent license to make, have made, use, offer to sell, sell, import,
65
+ and otherwise transfer the Work.
66
+
67
+ 4. Redistribution. You may reproduce and distribute copies of the
68
+ Work or Derivative Works thereof in any medium, with or without
69
+ modifications, and in Source or Object form, provided that You
70
+ meet the following conditions:
71
+
72
+ (a) You must give any other recipients of the Work or
73
+ Derivative Works a copy of this License; and
74
+
75
+ (b) You must cause any modified files to carry prominent notices
76
+ stating that You changed the files; and
77
+
78
+ (c) You must retain, in the Source form of any Derivative Works
79
+ that You distribute, all copyright, patent, trademark, and
80
+ attribution notices from the Source form of the Work,
81
+ excluding those notices that do not pertain to any part of
82
+ the Derivative Works; and
83
+
84
+ (d) If the Work includes a "NOTICE" text file as part of its
85
+ distribution, then any Derivative Works that You distribute must
86
+ include a readable copy of the attribution notices contained
87
+ within such NOTICE file.
88
+
89
+ 5. Submission of Contributions.
90
+
91
+ 6. Trademarks. This License does not grant permission to use the trade
92
+ names, trademarks, service marks, or product names of the Licensor.
93
+
94
+ 7. Disclaimer of Warranty. Unless required by applicable law or
95
+ agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
96
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
97
+
98
+ 8. Limitation of Liability. In no event and under no legal theory shall
99
+ any Contributor be liable to You for damages.
100
+
101
+ 9. Accepting Warranty or Additional Liability.
102
+
103
+ Copyright 2026 Molecule Dev, Inc.
104
+
105
+ Licensed under the Apache License, Version 2.0 (the "License");
106
+ you may not use this file except in compliance with the License.
107
+ You may obtain a copy of the License at
108
+
109
+ http://www.apache.org/licenses/LICENSE-2.0
110
+
111
+ Unless required by applicable law or agreed to in writing, software
112
+ distributed under the License is distributed on an "AS IS" BASIS,
113
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
114
+ See the License for the specific language governing permissions and
115
+ limitations under the License.
@@ -0,0 +1,65 @@
1
+ /**
2
+ * CSS custom properties theme provider for molecule.dev.
3
+ *
4
+ * Provides a framework-agnostic ThemeProvider implementation that applies
5
+ * theme tokens as CSS custom properties (variables) to the document root.
6
+ * Works with any framework -- React, Vue, Svelte, Angular, Solid, or vanilla JS.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import {
11
+ * createCSSVariablesThemeProvider,
12
+ * lightTheme,
13
+ * darkTheme,
14
+ * } from '@molecule/app-theme-css-variables'
15
+ * import { setProvider } from '@molecule/app-theme'
16
+ *
17
+ * const provider = createCSSVariablesThemeProvider({
18
+ * themes: [lightTheme, darkTheme],
19
+ * defaultTheme: 'light',
20
+ * persistKey: 'molecule-theme',
21
+ * })
22
+ *
23
+ * setProvider(provider)
24
+ * ```
25
+ *
26
+ * Then use CSS variables in your stylesheets:
27
+ * ```css
28
+ * .button {
29
+ * background-color: var(--mol-color-primary);
30
+ * color: var(--mol-color-text-inverse);
31
+ * padding: var(--mol-spacing-sm) var(--mol-spacing-md);
32
+ * border-radius: var(--mol-radius-md);
33
+ * transition: background-color var(--mol-transition-fast);
34
+ * }
35
+ * ```
36
+ *
37
+ * @remarks
38
+ * Recoloring a scaffolded app — where the palette actually lives:
39
+ *
40
+ * This bond writes `--mol-color-*` variables and toggles light/dark via a
41
+ * `data-mol-mode` attribute. In `@molecule/app-ui-tailwind`'s `base.css` the
42
+ * Tailwind `@theme` reads each core token as
43
+ * `--color-primary: var(--mol-color-primary, <default>)`, so for a CUSTOM build
44
+ * (no per-app `theme.css`) this bond's `Theme` objects ARE the palette — edit
45
+ * `colors` here to recolor.
46
+ *
47
+ * BUT template-based apps ship `app/src/theme.css` that hardcodes `--color-*` on
48
+ * `:root` / `[data-mol-mode='dark']`. Those have the same `:root` specificity and
49
+ * load last, so they SHADOW the `var(--mol-color-*)` reference — the visible
50
+ * colors come only from `theme.css`. When `theme.css` defines colors, editing
51
+ * this bond has NO visible effect; recolor by editing `app/src/theme.css`. This
52
+ * bond still drives light/dark mode and is the palette for non-Tailwind targets
53
+ * (e.g. React Native). Precedence: `theme.css` > this bond > base defaults.
54
+ *
55
+ * The provider also toggles a `.dark` class on `<html>` (alongside the
56
+ * `data-mol-mode` attribute) so Tailwind `dark:` variants react to theme
57
+ * toggles — if `dark:` utilities aren't switching, check that this bond is
58
+ * wired and applying to the document.
59
+ *
60
+ * @module
61
+ */
62
+ export * from './provider.js';
63
+ export * from './themes.js';
64
+ export * from './types.js';
65
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAEH,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,65 @@
1
+ /**
2
+ * CSS custom properties theme provider for molecule.dev.
3
+ *
4
+ * Provides a framework-agnostic ThemeProvider implementation that applies
5
+ * theme tokens as CSS custom properties (variables) to the document root.
6
+ * Works with any framework -- React, Vue, Svelte, Angular, Solid, or vanilla JS.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import {
11
+ * createCSSVariablesThemeProvider,
12
+ * lightTheme,
13
+ * darkTheme,
14
+ * } from '@molecule/app-theme-css-variables'
15
+ * import { setProvider } from '@molecule/app-theme'
16
+ *
17
+ * const provider = createCSSVariablesThemeProvider({
18
+ * themes: [lightTheme, darkTheme],
19
+ * defaultTheme: 'light',
20
+ * persistKey: 'molecule-theme',
21
+ * })
22
+ *
23
+ * setProvider(provider)
24
+ * ```
25
+ *
26
+ * Then use CSS variables in your stylesheets:
27
+ * ```css
28
+ * .button {
29
+ * background-color: var(--mol-color-primary);
30
+ * color: var(--mol-color-text-inverse);
31
+ * padding: var(--mol-spacing-sm) var(--mol-spacing-md);
32
+ * border-radius: var(--mol-radius-md);
33
+ * transition: background-color var(--mol-transition-fast);
34
+ * }
35
+ * ```
36
+ *
37
+ * @remarks
38
+ * Recoloring a scaffolded app — where the palette actually lives:
39
+ *
40
+ * This bond writes `--mol-color-*` variables and toggles light/dark via a
41
+ * `data-mol-mode` attribute. In `@molecule/app-ui-tailwind`'s `base.css` the
42
+ * Tailwind `@theme` reads each core token as
43
+ * `--color-primary: var(--mol-color-primary, <default>)`, so for a CUSTOM build
44
+ * (no per-app `theme.css`) this bond's `Theme` objects ARE the palette — edit
45
+ * `colors` here to recolor.
46
+ *
47
+ * BUT template-based apps ship `app/src/theme.css` that hardcodes `--color-*` on
48
+ * `:root` / `[data-mol-mode='dark']`. Those have the same `:root` specificity and
49
+ * load last, so they SHADOW the `var(--mol-color-*)` reference — the visible
50
+ * colors come only from `theme.css`. When `theme.css` defines colors, editing
51
+ * this bond has NO visible effect; recolor by editing `app/src/theme.css`. This
52
+ * bond still drives light/dark mode and is the palette for non-Tailwind targets
53
+ * (e.g. React Native). Precedence: `theme.css` > this bond > base defaults.
54
+ *
55
+ * The provider also toggles a `.dark` class on `<html>` (alongside the
56
+ * `data-mol-mode` attribute) so Tailwind `dark:` variants react to theme
57
+ * toggles — if `dark:` utilities aren't switching, check that this bond is
58
+ * wired and applying to the document.
59
+ *
60
+ * @module
61
+ */
62
+ export * from './provider.js';
63
+ export * from './themes.js';
64
+ export * from './types.js';
65
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAEH,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * CSS variables theme provider implementation.
3
+ *
4
+ * Applies theme values as CSS custom properties to the document root,
5
+ * enabling framework-agnostic theming via standard CSS.
6
+ *
7
+ * @module
8
+ */
9
+ import type { ThemeProvider } from '@molecule/app-theme';
10
+ import type { CSSVariablesThemeConfig } from './types.js';
11
+ /**
12
+ * Creates a framework-agnostic ThemeProvider that applies theme tokens
13
+ * as CSS custom properties on the document root element.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * import { createCSSVariablesThemeProvider, lightTheme, darkTheme } from '`@molecule/app-theme-css-variables`'
18
+ * import { setProvider } from '`@molecule/app-theme`'
19
+ *
20
+ * const provider = createCSSVariablesThemeProvider({
21
+ * themes: [lightTheme, darkTheme],
22
+ * defaultTheme: 'light',
23
+ * prefix: 'mol',
24
+ * persistKey: 'molecule-theme',
25
+ * })
26
+ *
27
+ * setProvider(provider)
28
+ * ```
29
+ * @param config - Theme provider configuration (available themes, default theme, CSS variable prefix, persistence).
30
+ * @returns A ThemeProvider that applies themes as CSS custom properties on the document root.
31
+ */
32
+ export declare function createCSSVariablesThemeProvider(config: CSSVariablesThemeConfig): ThemeProvider;
33
+ /** Default CSS variables theme provider with light and dark themes. */
34
+ export declare const provider: ThemeProvider;
35
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAS,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAG/D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAmHzD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,uBAAuB,GAAG,aAAa,CAqF9F;AAED,uEAAuE;AACvE,eAAO,MAAM,QAAQ,EAAE,aAGrB,CAAA"}
@@ -0,0 +1,215 @@
1
+ /**
2
+ * CSS variables theme provider implementation.
3
+ *
4
+ * Applies theme values as CSS custom properties to the document root,
5
+ * enabling framework-agnostic theming via standard CSS.
6
+ *
7
+ * @module
8
+ */
9
+ import { darkTheme, lightTheme } from './themes.js';
10
+ /**
11
+ * Converts a camelCase string to kebab-case (e.g. `'primaryColor'` → `'primary-color'`).
12
+ * @param str - The camelCase string to convert.
13
+ * @returns The kebab-case string.
14
+ */
15
+ function camelToKebab(str) {
16
+ return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
17
+ }
18
+ /**
19
+ * Build the declaration body (CSS custom-property lines) for a single theme.
20
+ */
21
+ function buildDeclarations(theme, prefix) {
22
+ const lines = [];
23
+ for (const [key, value] of Object.entries(theme.colors)) {
24
+ lines.push(` --${prefix}-color-${camelToKebab(key)}: ${value};`);
25
+ }
26
+ for (const [key, value] of Object.entries(theme.spacing)) {
27
+ lines.push(` --${prefix}-spacing-${key}: ${value};`);
28
+ }
29
+ for (const [key, value] of Object.entries(theme.borderRadius)) {
30
+ lines.push(` --${prefix}-radius-${key}: ${value};`);
31
+ }
32
+ for (const [key, value] of Object.entries(theme.shadows)) {
33
+ lines.push(` --${prefix}-shadow-${key}: ${value};`);
34
+ }
35
+ for (const [key, value] of Object.entries(theme.typography.fontFamily)) {
36
+ lines.push(` --${prefix}-font-${key}: ${value};`);
37
+ }
38
+ for (const [key, value] of Object.entries(theme.typography.fontSize)) {
39
+ lines.push(` --${prefix}-text-${key}: ${value};`);
40
+ }
41
+ for (const [key, value] of Object.entries(theme.typography.fontWeight)) {
42
+ lines.push(` --${prefix}-font-weight-${key}: ${String(value)};`);
43
+ }
44
+ for (const [key, value] of Object.entries(theme.typography.lineHeight)) {
45
+ lines.push(` --${prefix}-leading-${key}: ${String(value)};`);
46
+ }
47
+ for (const [key, value] of Object.entries(theme.breakpoints)) {
48
+ lines.push(` --${prefix}-breakpoint-${camelToKebab(key)}: ${value};`);
49
+ }
50
+ for (const [key, value] of Object.entries(theme.transitions)) {
51
+ lines.push(` --${prefix}-transition-${key}: ${value};`);
52
+ }
53
+ for (const [key, value] of Object.entries(theme.zIndex)) {
54
+ lines.push(` --${prefix}-z-${key}: ${String(value)};`);
55
+ }
56
+ return lines.join('\n');
57
+ }
58
+ /**
59
+ * Apply the active theme to the document.
60
+ *
61
+ * Strategy: inject a single `<style>` element holding ONE rule per
62
+ * registered theme, each scoped with `:where(...)` so the rules have ZERO
63
+ * specificity. This lets an app's own `theme.css` (e.g. plain
64
+ * `:root { … }` or `[data-mol-mode="dark"] { … }`, both specificity 0,1,0)
65
+ * always win, while still giving apps that ship no theme.css a working
66
+ * baseline. The selector for the mode-matching theme bumps to the active
67
+ * mode via the `data-{prefix}-mode` attribute the function also writes.
68
+ *
69
+ * Without `:where()` the provider's inline / high-specificity styles
70
+ * defeated every per-app `[data-mol-mode="dark"]` block, leaving the
71
+ * fleet's brand-specific dark palettes unreachable. See
72
+ * `__tests__/provider.test.ts` for the regression that pinned this.
73
+ *
74
+ * @param themes - All themes registered with the provider.
75
+ * @param activeTheme - The currently-selected theme (drives data-attrs + class).
76
+ * @param prefix - CSS variable prefix (e.g. `'mol'` → `--mol-color-primary`).
77
+ */
78
+ function applyThemeToDocument(themes, activeTheme, prefix) {
79
+ if (typeof document === 'undefined')
80
+ return;
81
+ const root = document.documentElement;
82
+ const styleId = `${prefix}-theme-vars`;
83
+ // Build/refresh the single stylesheet with one :where()-wrapped rule per theme.
84
+ let style = document.getElementById(styleId);
85
+ if (!style) {
86
+ style = document.createElement('style');
87
+ style.id = styleId;
88
+ // Insert as early as possible so source-order ties go to app stylesheets
89
+ // imported later. The :where() wrapper makes specificity moot, but
90
+ // injecting at <head> top is the safest belt-and-braces.
91
+ const head = document.head || document.documentElement;
92
+ head.insertBefore(style, head.firstChild);
93
+ }
94
+ const rules = [];
95
+ // Default (light/baseline) rule — always present, selects :root unconditionally
96
+ // but inside :where(), so specificity is 0,0,0.
97
+ const baseline = themes.find((t) => t.mode === 'light') || themes[0];
98
+ if (baseline) {
99
+ rules.push(`:where(:root) {\n${buildDeclarations(baseline, prefix)}\n}`);
100
+ }
101
+ // Per-mode rules — fire when the active mode attribute matches.
102
+ for (const t of themes) {
103
+ rules.push(`:where([data-${prefix}-mode="${t.mode}"]) {\n${buildDeclarations(t, prefix)}\n}`);
104
+ }
105
+ style.textContent = rules.join('\n\n');
106
+ // Set data attributes for CSS selectors
107
+ root.setAttribute(`data-${prefix}-theme`, activeTheme.name);
108
+ root.setAttribute(`data-${prefix}-mode`, activeTheme.mode);
109
+ // Also toggle a `.dark` class on <html>. Many app templates rely on the
110
+ // Tailwind `dark:` modifier — which the generator wires via
111
+ // `@custom-variant dark (&:where(.dark, .dark *))` in index.css — so
112
+ // without this class on the root, every `dark:bg-*` / `dark:text-*` etc.
113
+ // utility silently no-ops on theme toggle.
114
+ root.classList.toggle('dark', activeTheme.mode === 'dark');
115
+ }
116
+ /**
117
+ * Creates a framework-agnostic ThemeProvider that applies theme tokens
118
+ * as CSS custom properties on the document root element.
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * import { createCSSVariablesThemeProvider, lightTheme, darkTheme } from '`@molecule/app-theme-css-variables`'
123
+ * import { setProvider } from '`@molecule/app-theme`'
124
+ *
125
+ * const provider = createCSSVariablesThemeProvider({
126
+ * themes: [lightTheme, darkTheme],
127
+ * defaultTheme: 'light',
128
+ * prefix: 'mol',
129
+ * persistKey: 'molecule-theme',
130
+ * })
131
+ *
132
+ * setProvider(provider)
133
+ * ```
134
+ * @param config - Theme provider configuration (available themes, default theme, CSS variable prefix, persistence).
135
+ * @returns A ThemeProvider that applies themes as CSS custom properties on the document root.
136
+ */
137
+ export function createCSSVariablesThemeProvider(config) {
138
+ const { themes, defaultTheme, prefix = 'mol', applyToDocument = true, persistKey } = config;
139
+ // If a persistKey is set without an explicit storage adapter, fall back to
140
+ // window.localStorage. The previous behavior — persistKey but no storage =
141
+ // silent no-op — was the source of "I toggled dark mode and it reset on
142
+ // reload" bugs across multiple flagships. SSR/non-browser environments
143
+ // still get undefined and skip persistence.
144
+ // Guard against partial localStorage shims (some test runners stub
145
+ // `globalThis.localStorage = {}` without methods); only adopt it when
146
+ // both getItem and setItem are real functions.
147
+ const browserStorage = globalThis.localStorage;
148
+ const storage = config.storage ??
149
+ (browserStorage &&
150
+ typeof browserStorage.getItem === 'function' &&
151
+ typeof browserStorage.setItem === 'function'
152
+ ? {
153
+ getItem: (key) => browserStorage.getItem(key),
154
+ setItem: (key, value) => {
155
+ ;
156
+ browserStorage.setItem(key, value);
157
+ },
158
+ }
159
+ : undefined);
160
+ let currentTheme = themes.find((t) => t.name === defaultTheme) || themes[0];
161
+ const listeners = new Set();
162
+ // Try to restore from storage adapter
163
+ if (persistKey && storage) {
164
+ const saved = storage.getItem(persistKey);
165
+ if (saved) {
166
+ const found = themes.find((t) => t.name === saved);
167
+ if (found)
168
+ currentTheme = found;
169
+ }
170
+ }
171
+ // Apply initial theme
172
+ if (applyToDocument) {
173
+ applyThemeToDocument(themes, currentTheme, prefix);
174
+ }
175
+ const provider = {
176
+ getTheme() {
177
+ return currentTheme;
178
+ },
179
+ setTheme(theme) {
180
+ const newTheme = typeof theme === 'string' ? themes.find((t) => t.name === theme) : theme;
181
+ if (!newTheme)
182
+ return;
183
+ currentTheme = newTheme;
184
+ if (applyToDocument) {
185
+ applyThemeToDocument(themes, currentTheme, prefix);
186
+ }
187
+ if (persistKey && storage) {
188
+ storage.setItem(persistKey, currentTheme.name);
189
+ }
190
+ listeners.forEach((fn) => fn(currentTheme));
191
+ },
192
+ toggleMode() {
193
+ const targetMode = currentTheme.mode === 'light' ? 'dark' : 'light';
194
+ const newTheme = themes.find((t) => t.mode === targetMode);
195
+ if (newTheme)
196
+ provider.setTheme(newTheme);
197
+ },
198
+ subscribe(callback) {
199
+ listeners.add(callback);
200
+ return () => {
201
+ listeners.delete(callback);
202
+ };
203
+ },
204
+ getThemes() {
205
+ return themes;
206
+ },
207
+ };
208
+ return provider;
209
+ }
210
+ /** Default CSS variables theme provider with light and dark themes. */
211
+ export const provider = createCSSVariablesThemeProvider({
212
+ themes: [lightTheme, darkTheme],
213
+ defaultTheme: 'light',
214
+ });
215
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGnD;;;;GAIG;AACH,SAAS,YAAY,CAAC,GAAW;IAC/B,OAAO,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAC5D,CAAC;AAED;;GAEG;AACH,SAAS,iBAAiB,CAAC,KAAY,EAAE,MAAc;IACrD,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;QACxD,KAAK,CAAC,IAAI,CAAC,OAAO,MAAM,UAAU,YAAY,CAAC,GAAG,CAAC,KAAK,KAAK,GAAG,CAAC,CAAA;IACnE,CAAC;IACD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACzD,KAAK,CAAC,IAAI,CAAC,OAAO,MAAM,YAAY,GAAG,KAAK,KAAK,GAAG,CAAC,CAAA;IACvD,CAAC;IACD,KAAK,MAAM,CAAC,GAAG,EAAE,KAA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C,QAAQ,CAAC,QAAQ,CAAC,CAAA;QAC3C,CAAC;QAED,SAAS,CAAC,QAAgC;YACxC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;YACvB,OAAO,GAAG,EAAE;gBACV,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;YAC5B,CAAC,CAAA;QACH,CAAC;QAED,SAAS;YACP,OAAO,MAAM,CAAA;QACf,CAAC;KACF,CAAA;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,uEAAuE;AACvE,MAAM,CAAC,MAAM,QAAQ,GAAkB,+BAA+B,CAAC;IACrE,MAAM,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,YAAY,EAAE,OAAO;CACtB,CAAC,CAAA"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Built-in light and dark theme definitions for CSS variables provider.
3
+ *
4
+ * These themes use a modern color palette with blue as the primary brand color.
5
+ * Colors are specified as hex/rgba values and will be applied as CSS custom
6
+ * properties by the provider.
7
+ *
8
+ * @module
9
+ */
10
+ import type { Theme } from '@molecule/app-theme';
11
+ /**
12
+ * Default light theme.
13
+ *
14
+ * Near-white backgrounds (#f6f6f6 background, #ffffff surface), dark text,
15
+ * blue primary (#4070e0).
16
+ */
17
+ export declare const lightTheme: Theme;
18
+ /**
19
+ * Default dark theme.
20
+ *
21
+ * Dark backgrounds (#0f172a, #1e293b), light text, blue primary (#60a5fa).
22
+ */
23
+ export declare const darkTheme: Theme;
24
+ //# sourceMappingURL=themes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../src/themes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,KAyHxB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,KAsHvB,CAAA"}
package/dist/themes.js ADDED
@@ -0,0 +1,252 @@
1
+ /**
2
+ * Built-in light and dark theme definitions for CSS variables provider.
3
+ *
4
+ * These themes use a modern color palette with blue as the primary brand color.
5
+ * Colors are specified as hex/rgba values and will be applied as CSS custom
6
+ * properties by the provider.
7
+ *
8
+ * @module
9
+ */
10
+ /**
11
+ * Default light theme.
12
+ *
13
+ * Near-white backgrounds (#f6f6f6 background, #ffffff surface), dark text,
14
+ * blue primary (#4070e0).
15
+ */
16
+ export const lightTheme = {
17
+ name: 'light',
18
+ mode: 'light',
19
+ colors: {
20
+ background: '#f6f6f6',
21
+ backgroundSecondary: '#eeeeee',
22
+ backgroundTertiary: '#e8e8e8',
23
+ surface: '#ffffff',
24
+ surfaceSecondary: '#f8f8f8',
25
+ inputBackground: '#ffffff',
26
+ text: '#333333',
27
+ // #686868 = the lightest grey passing WCAG AA 4.5:1 on EVERY light surface
28
+ // (#f6f6f6 bg 5.16, #eeeeee 4.80, #e8e8e8 4.55, #ffffff 5.57) — #808080
29
+ // was 3.65 on the page background and failed axe color-contrast.
30
+ textSecondary: '#686868',
31
+ textTertiary: '#555555',
32
+ textInverse: '#ffffff',
33
+ primary: '#4070e0',
34
+ primaryLight: '#6090f0',
35
+ primaryDark: '#3060c0',
36
+ secondary: '#808080',
37
+ secondaryLight: '#a0a0a0',
38
+ secondaryDark: '#606060',
39
+ success: '#309000',
40
+ successLight: '#dcfce7',
41
+ warning: '#e0e040',
42
+ warningLight: '#fef3c7',
43
+ error: '#d02000',
44
+ errorLight: '#fee2e2',
45
+ info: '#17a2b8',
46
+ infoLight: '#cffafe',
47
+ border: '#e0e0e0',
48
+ borderSecondary: '#d0d0d0',
49
+ borderFocus: '#4070e0',
50
+ overlay: 'rgba(0, 0, 0, 0.5)',
51
+ shadow: 'rgba(0, 0, 0, 0.1)',
52
+ },
53
+ breakpoints: {
54
+ mobileS: '320px',
55
+ mobileM: '375px',
56
+ mobileL: '425px',
57
+ tablet: '768px',
58
+ laptop: '1024px',
59
+ laptopL: '1440px',
60
+ desktop: '2560px',
61
+ },
62
+ spacing: {
63
+ xs: '4px',
64
+ sm: '8px',
65
+ md: '16px',
66
+ lg: '24px',
67
+ xl: '32px',
68
+ xxl: '48px',
69
+ xxxl: '64px',
70
+ },
71
+ typography: {
72
+ fontFamily: {
73
+ sans: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
74
+ serif: 'Georgia, "Times New Roman", Times, serif',
75
+ mono: 'SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',
76
+ },
77
+ fontSize: {
78
+ xs: '0.75rem',
79
+ sm: '0.875rem',
80
+ base: '1rem',
81
+ lg: '1.125rem',
82
+ xl: '1.25rem',
83
+ '2xl': '1.5rem',
84
+ '3xl': '1.875rem',
85
+ '4xl': '2.25rem',
86
+ '5xl': '3rem',
87
+ },
88
+ fontWeight: {
89
+ light: 300,
90
+ normal: 400,
91
+ medium: 500,
92
+ semibold: 600,
93
+ bold: 700,
94
+ },
95
+ lineHeight: {
96
+ tight: 1.25,
97
+ normal: 1.5,
98
+ relaxed: 1.75,
99
+ },
100
+ },
101
+ borderRadius: {
102
+ none: '0',
103
+ sm: '4px',
104
+ md: '8px',
105
+ lg: '12px',
106
+ xl: '16px',
107
+ full: '9999px',
108
+ },
109
+ shadows: {
110
+ none: 'none',
111
+ sm: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
112
+ md: '0 4px 6px -1px rgba(0, 0, 0, 0.1)',
113
+ lg: '0 10px 15px -3px rgba(0, 0, 0, 0.1)',
114
+ xl: '0 20px 25px -5px rgba(0, 0, 0, 0.15)',
115
+ },
116
+ transitions: {
117
+ fast: '150ms ease',
118
+ normal: '300ms ease',
119
+ slow: '500ms ease',
120
+ },
121
+ zIndex: {
122
+ hide: -1,
123
+ base: 0,
124
+ dropdown: 1000,
125
+ sticky: 1100,
126
+ fixed: 1200,
127
+ modal: 1300,
128
+ popover: 1400,
129
+ tooltip: 1500,
130
+ toast: 1600,
131
+ },
132
+ };
133
+ /**
134
+ * Default dark theme.
135
+ *
136
+ * Dark backgrounds (#0f172a, #1e293b), light text, blue primary (#60a5fa).
137
+ */
138
+ export const darkTheme = {
139
+ name: 'dark',
140
+ mode: 'dark',
141
+ colors: {
142
+ background: '#0f172a',
143
+ backgroundSecondary: '#1e293b',
144
+ backgroundTertiary: '#334155',
145
+ surface: '#1e293b',
146
+ surfaceSecondary: '#293548',
147
+ inputBackground: '#0a1020',
148
+ text: '#f8fafc',
149
+ textSecondary: '#cbd5e1',
150
+ textTertiary: '#64748b',
151
+ textInverse: '#0f172a',
152
+ primary: '#60a5fa',
153
+ primaryLight: '#93c5fd',
154
+ primaryDark: '#3b82f6',
155
+ secondary: '#94a3b8',
156
+ secondaryLight: '#cbd5e1',
157
+ secondaryDark: '#64748b',
158
+ success: '#4ade80',
159
+ successLight: '#14532d',
160
+ warning: '#fbbf24',
161
+ warningLight: '#422006',
162
+ error: '#f87171',
163
+ errorLight: '#450a0a',
164
+ info: '#22d3ee',
165
+ infoLight: '#083344',
166
+ border: '#334155',
167
+ borderSecondary: '#475569',
168
+ borderFocus: '#60a5fa',
169
+ overlay: 'rgba(0, 0, 0, 0.7)',
170
+ shadow: 'rgba(0, 0, 0, 0.4)',
171
+ },
172
+ breakpoints: {
173
+ mobileS: '320px',
174
+ mobileM: '375px',
175
+ mobileL: '425px',
176
+ tablet: '768px',
177
+ laptop: '1024px',
178
+ laptopL: '1440px',
179
+ desktop: '2560px',
180
+ },
181
+ spacing: {
182
+ xs: '4px',
183
+ sm: '8px',
184
+ md: '16px',
185
+ lg: '24px',
186
+ xl: '32px',
187
+ xxl: '48px',
188
+ xxxl: '64px',
189
+ },
190
+ typography: {
191
+ fontFamily: {
192
+ sans: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
193
+ serif: 'Georgia, "Times New Roman", Times, serif',
194
+ mono: 'SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',
195
+ },
196
+ fontSize: {
197
+ xs: '0.75rem',
198
+ sm: '0.875rem',
199
+ base: '1rem',
200
+ lg: '1.125rem',
201
+ xl: '1.25rem',
202
+ '2xl': '1.5rem',
203
+ '3xl': '1.875rem',
204
+ '4xl': '2.25rem',
205
+ '5xl': '3rem',
206
+ },
207
+ fontWeight: {
208
+ light: 300,
209
+ normal: 400,
210
+ medium: 500,
211
+ semibold: 600,
212
+ bold: 700,
213
+ },
214
+ lineHeight: {
215
+ tight: 1.25,
216
+ normal: 1.5,
217
+ relaxed: 1.75,
218
+ },
219
+ },
220
+ borderRadius: {
221
+ none: '0',
222
+ sm: '4px',
223
+ md: '8px',
224
+ lg: '12px',
225
+ xl: '16px',
226
+ full: '9999px',
227
+ },
228
+ shadows: {
229
+ none: 'none',
230
+ sm: '0 1px 2px 0 rgba(0, 0, 0, 0.15)',
231
+ md: '0 4px 6px -1px rgba(0, 0, 0, 0.25)',
232
+ lg: '0 10px 15px -3px rgba(0, 0, 0, 0.3)',
233
+ xl: '0 20px 25px -5px rgba(0, 0, 0, 0.35)',
234
+ },
235
+ transitions: {
236
+ fast: '150ms ease',
237
+ normal: '300ms ease',
238
+ slow: '500ms ease',
239
+ },
240
+ zIndex: {
241
+ hide: -1,
242
+ base: 0,
243
+ dropdown: 1000,
244
+ sticky: 1100,
245
+ fixed: 1200,
246
+ modal: 1300,
247
+ popover: 1400,
248
+ tooltip: 1500,
249
+ toast: 1600,
250
+ },
251
+ };
252
+ //# sourceMappingURL=themes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"themes.js","sourceRoot":"","sources":["../src/themes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAU;IAC/B,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,OAAO;IACb,MAAM,EAAE;QACN,UAAU,EAAE,SAAS;QACrB,mBAAmB,EAAE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R,EAAE,EAAE,SAAS;YACb,EAAE,EAAE,UAAU;YACd,IAAI,EAAE,MAAM;YACZ,EAAE,EAAE,UAAU;YACd,EAAE,EAAE,SAAS;YACb,KAAK,EAAE,QAAQ;YACf,KAAK,EAAE,UAAU;YACjB,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,MAAM;SACd;QACD,UAAU,EAAE;YACV,KAAK,EAAE,GAAG;YACV,MAAM,EAAE,GAAG;YACX,MAAM,EAAE,GAAG;YACX,QAAQ,EAAE,GAAG;YACb,IAAI,EAAE,GAAG;SACV;QACD,UAAU,EAAE;YACV,KAAK,EAAE,IAAI;YACX,MAAM,EAAE,GAAG;YACX,OAAO,EAAE,IAAI;SACd;KACF;IACD,YAAY,EAAE;QACZ,IAAI,EAAE,GAAG;QACT,EAAE,EAAE,KAAK;QACT,EAAE,EAAE,KAAK;QACT,EAAE,EAAE,MAAM;QACV,EAAE,EAAE,MAAM;QACV,IAAI,EAAE,QAAQ;KACf;IACD,OAAO,EAAE;QACP,IAAI,EAAE,MAAM;QACZ,EAAE,EAAE,iCAAiC;QACrC,EAAE,EAAE,oCAAoC;QACxC,EAAE,EAAE,qCAAqC;QACzC,EAAE,EAAE,sCAAsC;KAC3C;IACD,WAAW,EAAE;QACX,IAAI,EAAE,YAAY;QAClB,MAAM,EAAE,YAAY;QACpB,IAAI,EAAE,YAAY;KACnB;IACD,MAAM,EAAE;QACN,IAAI,EAAE,CAAC,CAAC;QACR,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,IAAI;QACX,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,IAAI;KACZ;CACF,CAAA"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Configuration types for the CSS variables theme provider.
3
+ *
4
+ * @module
5
+ */
6
+ import type { Theme } from '@molecule/app-theme';
7
+ /**
8
+ * Minimal storage adapter for theme persistence. Compatible with
9
+ * localStorage, sessionStorage, or any custom implementation
10
+ * (e.g., React Native AsyncStorage wrapper, SSR no-op).
11
+ */
12
+ export interface ThemeStorageAdapter {
13
+ getItem(key: string): string | null;
14
+ setItem(key: string, value: string): void;
15
+ }
16
+ /**
17
+ * Configuration for css variables theme.
18
+ */
19
+ export interface CSSVariablesThemeConfig {
20
+ /** Available themes. */
21
+ themes: Theme[];
22
+ /** Name of the default theme to use. */
23
+ defaultTheme?: string;
24
+ /** CSS variable prefix (default: 'mol'). */
25
+ prefix?: string;
26
+ /** Whether to auto-apply CSS variables to :root (default: true). */
27
+ applyToDocument?: boolean;
28
+ /**
29
+ * Key for persisting the selected theme name across reloads. When `storage`
30
+ * is omitted, persistence falls back to `window.localStorage` in browser
31
+ * environments; in SSR / non-browser environments persistence is skipped.
32
+ */
33
+ persistKey?: string;
34
+ /**
35
+ * Storage adapter for persisting theme preference. Optional — when omitted
36
+ * and `persistKey` is set, `window.localStorage` is used when available.
37
+ * Provide an adapter for React Native (AsyncStorage wrapper) or custom stores.
38
+ */
39
+ storage?: ThemeStorageAdapter;
40
+ }
41
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAEhD;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IACnC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,wBAAwB;IACxB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,wCAAwC;IACxC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,oEAAoE;IACpE,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,mBAAmB,CAAA;CAC9B"}
package/dist/types.js ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Configuration types for the CSS variables theme provider.
3
+ *
4
+ * @module
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@molecule/app-theme-css-variables",
3
+ "version": "1.0.0",
4
+ "description": "CSS custom properties theme provider for molecule.dev",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "test": "vitest run",
11
+ "test:watch": "vitest"
12
+ },
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "keywords": [
23
+ "molecule",
24
+ "theme",
25
+ "css-variables",
26
+ "css-custom-properties",
27
+ "dark-mode"
28
+ ],
29
+ "license": "Apache-2.0",
30
+ "devDependencies": {
31
+ "@types/node": "26.1.2",
32
+ "typescript": "6.0.3",
33
+ "vitest": "4.1.10"
34
+ },
35
+ "peerDependencies": {
36
+ "@molecule/app-theme": "^1.0.0"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "https://github.com/molecule-dev/molecule.git",
41
+ "directory": "packages/app/bonds/theme/css-variables"
42
+ },
43
+ "homepage": "https://github.com/molecule-dev/molecule/tree/main/packages/app/bonds/theme/css-variables",
44
+ "bugs": "https://github.com/molecule-dev/molecule/issues",
45
+ "publishConfig": {
46
+ "access": "public"
47
+ }
48
+ }