@prismora/theme 0.0.0-stage → 0.1.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 +21 -0
- package/README.md +22 -2
- package/dist/browser.d.ts +5 -0
- package/dist/browser.js +1 -0
- package/dist/build.d.ts +36 -0
- package/dist/build.js +191 -0
- package/dist/config.d.ts +61 -0
- package/dist/config.js +14 -0
- package/dist/exports.d.ts +42 -0
- package/dist/exports.js +135 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/runtime.d.ts +59 -0
- package/dist/runtime.js +171 -0
- package/dist/share.d.ts +9 -0
- package/dist/share.js +40 -0
- package/dist/surfaces.d.ts +26 -0
- package/dist/surfaces.js +114 -0
- package/package.json +43 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aravind Kumar and Prismora contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @prismora/theme
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Prismora themes: define a theme from one seed colour, build its CSS, switch light/dark at runtime without a flash.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install @prismora/theme
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
// prismora.theme.ts
|
|
11
|
+
import { defineTheme } from '@prismora/theme';
|
|
12
|
+
export default defineTheme({ seed: '#6d28d9', surface: 'glass', radius: 'soft' });
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Build it with `npx prismora theme build`. In the browser:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { ThemeController } from '@prismora/theme';
|
|
19
|
+
const theme = new ThemeController();
|
|
20
|
+
button.addEventListener('click', () => theme.flip()); // light ⇄ dark, saved
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Documentation: [prismora.design/docs/theming](https://prismora.design/docs/theming) · Part of [Prismora](https://github.com/axxra/prismora), one seed, every theme. MIT licence.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser build for pages without a bundler: `import { ThemeController } from '…/@prismora/theme/dist/browser.js'`.
|
|
3
|
+
* Only the runtime controller and the no-flash script (no colour engine).
|
|
4
|
+
*/
|
|
5
|
+
export { ThemeController, noFlashScript, type ModePreference, type ThemeState } from './runtime.js';
|
package/dist/browser.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var m="pm-theme",l={font:"data-font",surface:"data-surface",radius:"data-radius",density:"data-density",motion:"data-motion",textSize:"data-text-size"},c=/^[a-z0-9-]{1,32}$/,u=`(()=>{try{var s=JSON.parse(localStorage.getItem('${m}')||'{}'),d=document.documentElement,ok=function(v){return typeof v==='string'&&/^[a-z0-9-]{1,32}$/.test(v)},p=${JSON.stringify(l)};if(s.mode==='light'||s.mode==='dark')d.dataset.mode=s.mode;if(ok(s.theme))d.dataset.theme=s.theme;for(var k in p)if(ok(s[k]))d.setAttribute(p[k],s[k]);if(s.mobile==='native')d.setAttribute('mobile','');else if(s.mobile==='web')d.setAttribute('mobile','false');}catch(e){}})();`;class d{#e;#s=new Set;#t;#i;constructor(e=document.documentElement){this.#t=e,this.#e=d.read(),this.#o(),addEventListener("storage",(t)=>{if(t.key!==m)return;this.#e=d.read(),this.#o(),this.#n()})}static read(){try{let e=JSON.parse(localStorage.getItem(m)??"{}"),t=(s)=>typeof s==="string"&&c.test(s)?s:null;return{mode:e.mode==="light"||e.mode==="dark"?e.mode:"system",theme:t(e.theme),font:t(e.font),surface:t(e.surface),radius:t(e.radius),density:t(e.density),motion:t(e.motion),textSize:t(e.textSize),mobile:e.mobile==="native"||e.mobile==="web"?e.mobile:null}}catch{return{mode:"system",theme:null}}}get state(){return{...this.#e}}get resolvedMode(){if(this.#e.mode!=="system")return this.#e.mode;return matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}subscribe(e){return this.#s.add(e),e(this.state),()=>this.#s.delete(e)}async set(e,t){let s=()=>{this.#e={...this.#e,...e};try{localStorage.setItem(m,JSON.stringify(this.#e))}catch{}this.#o(),this.#n()},o=document,n=!matchMedia("(prefers-reduced-motion: reduce)").matches&&!["none","reduced"].includes(this.#t.closest("[data-motion]")?.getAttribute("data-motion")??""),r="mode"in e&&e.mode!==this.#e.mode||"theme"in e&&e.theme!==this.#e.theme;if(o.startViewTransition&&n&&r){let i=o.startViewTransition(s),a=()=>{};if(i.finished.catch(a),i.updateCallbackDone.catch(a),i.ready.catch(a),await i.updateCallbackDone.catch(a),t){try{await i.ready}catch{return}let h=Math.hypot(Math.max(t.x,innerWidth-t.x),Math.max(t.y,innerHeight-t.y));document.documentElement.animate({clipPath:[`circle(0 at ${t.x}px ${t.y}px)`,`circle(${h}px at ${t.x}px ${t.y}px)`]},{duration:450,easing:"cubic-bezier(0.2, 0, 0, 1)",pseudoElement:"::view-transition-new(root)"})}}else s()}flip(e){return this.set({mode:this.resolvedMode==="dark"?"light":"dark"},e)}toggle(e){let t=["system","light","dark"],s=t[(t.indexOf(this.#e.mode)+1)%t.length];return this.set({mode:s},e)}reset(e){return this.set({mode:"system",theme:null,font:null,surface:null,radius:null,density:null,motion:null,textSize:null,mobile:null},e)}#o(){let{mode:e,theme:t}=this.#e;if(e==="system")delete this.#t.dataset.mode;else this.#t.dataset.mode=e;if(t)this.#t.dataset.theme=t;else delete this.#t.dataset.theme;for(let[o,n]of Object.entries(l)){let r=this.#e[o];if(r)this.#t.setAttribute(n,r);else this.#t.removeAttribute(n)}if(this.#i===void 0)this.#i=this.#e.mobile?null:this.#t.getAttribute("mobile");let s=this.#e.mobile==="native"?"":this.#e.mobile==="web"?"false":this.#i;if(s===null)this.#t.removeAttribute("mobile");else this.#t.setAttribute("mobile",s)}#n(){for(let e of this.#s)e(this.state)}}export{d as ThemeController,u as noFlashScript};
|
package/dist/build.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type Palette, parseColor } from '@prismora/color';
|
|
2
|
+
import { type ThemeConfig } from './config.js';
|
|
3
|
+
export interface ResolvedTheme {
|
|
4
|
+
name: string;
|
|
5
|
+
scheme: 'both' | 'light' | 'dark';
|
|
6
|
+
light: Palette;
|
|
7
|
+
dark: Palette;
|
|
8
|
+
}
|
|
9
|
+
/** Keys of the inherited tone context (`--pm-tone-*`) consumed by every component. */
|
|
10
|
+
export declare const TONE_KEYS: readonly ["solid", "solid-hover", "on-solid", "soft", "soft-hover", "soft-active", "border", "border-strong", "text", "text-strong"];
|
|
11
|
+
/** `--pm-tone-*` declarations pointing at a colour role. */
|
|
12
|
+
export declare function toneDeclarations(role?: string): string[];
|
|
13
|
+
/** Resolve the root theme and every named theme into light & dark palettes. */
|
|
14
|
+
export declare function resolveThemes(config: ThemeConfig): ResolvedTheme[];
|
|
15
|
+
/**
|
|
16
|
+
* `:root[x], [x]`: on <html> this beats the core stylesheet's `:root` defaults whatever the load order
|
|
17
|
+
* (theme CSS is often inlined in <head> before the linked core CSS); on other elements it is a plain scope.
|
|
18
|
+
*/
|
|
19
|
+
export declare const attrSelector: (attr: string) => string;
|
|
20
|
+
export interface BuildOptions {
|
|
21
|
+
/** Wrap output in `@layer pm.themes` (default true). */
|
|
22
|
+
layer?: boolean;
|
|
23
|
+
/** Include surface definitions and preset attribute selectors (default true). */
|
|
24
|
+
includeSurfaces?: boolean;
|
|
25
|
+
/** Root selector for the default theme (default `:root`). */
|
|
26
|
+
selector?: string;
|
|
27
|
+
}
|
|
28
|
+
/** Compile a theme config into a standalone CSS string. */
|
|
29
|
+
export declare function buildThemeCss(input: ThemeConfig, opts?: BuildOptions): string;
|
|
30
|
+
/** Contrast audit for every theme × mode. */
|
|
31
|
+
export declare function auditTheme(config: ThemeConfig): {
|
|
32
|
+
theme: string;
|
|
33
|
+
mode: "light" | "dark";
|
|
34
|
+
checks: import("@prismora/color").ContrastCheck[];
|
|
35
|
+
}[];
|
|
36
|
+
export { parseColor };
|
package/dist/build.js
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { ROLES, auditPalette, generatePalette, parseColor, toOklchString, } from '@prismora/color';
|
|
2
|
+
import { DENSITY_PRESETS, FONT_PAIRINGS, RADIUS_PRESETS, elevation, fontStack, pairingDeclarations, primitiveDeclarations } from '@prismora/tokens';
|
|
3
|
+
import { motionDeclarations } from '@prismora/motion';
|
|
4
|
+
import { DEFAULT_THEME } from './config.js';
|
|
5
|
+
import { surfaceDeclarations, surfacesCss } from './surfaces.js';
|
|
6
|
+
const css = (c) => toOklchString(c, 'srgb');
|
|
7
|
+
function paletteFor(base, mode, overrides) {
|
|
8
|
+
const merged = { ...base, ...overrides };
|
|
9
|
+
return generatePalette({
|
|
10
|
+
seed: merged.seed ?? DEFAULT_THEME.seed,
|
|
11
|
+
mode,
|
|
12
|
+
...(merged.secondary !== undefined && { secondary: merged.secondary }),
|
|
13
|
+
...(merged.harmony !== undefined && { harmony: merged.harmony }),
|
|
14
|
+
...(merged.neutralChroma !== undefined && { neutralChroma: merged.neutralChroma }),
|
|
15
|
+
...(merged.contrast !== undefined && { contrast: merged.contrast }),
|
|
16
|
+
...(merged.status !== undefined && { status: merged.status }),
|
|
17
|
+
...(merged.pins !== undefined && { pins: merged.pins }),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
const paletteKeys = ['seed', 'secondary', 'harmony', 'neutralChroma', 'contrast', 'status', 'pins'];
|
|
21
|
+
function pickPalette(o) {
|
|
22
|
+
const out = {};
|
|
23
|
+
for (const k of paletteKeys)
|
|
24
|
+
if (o[k] !== undefined)
|
|
25
|
+
out[k] = o[k];
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
/** Keys of the inherited tone context (`--pm-tone-*`) consumed by every component. */
|
|
29
|
+
export const TONE_KEYS = ['solid', 'solid-hover', 'on-solid', 'soft', 'soft-hover', 'soft-active', 'border', 'border-strong', 'text', 'text-strong'];
|
|
30
|
+
/** `--pm-tone-*` declarations pointing at a colour role. */
|
|
31
|
+
export function toneDeclarations(role = 'accent') {
|
|
32
|
+
return TONE_KEYS.map((k) => `--pm-tone-${k}: var(--pm-color-${role}-${k});`);
|
|
33
|
+
}
|
|
34
|
+
/** Resolve the root theme and every named theme into light & dark palettes. */
|
|
35
|
+
export function resolveThemes(config) {
|
|
36
|
+
const root = pickPalette(config);
|
|
37
|
+
const out = [
|
|
38
|
+
{
|
|
39
|
+
name: 'default',
|
|
40
|
+
scheme: 'both',
|
|
41
|
+
light: paletteFor(root, 'light', config.light),
|
|
42
|
+
dark: paletteFor(root, 'dark', config.dark),
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
for (const [name, t] of Object.entries(config.themes ?? {})) {
|
|
46
|
+
const base = { ...root, ...pickPalette(t) };
|
|
47
|
+
out.push({
|
|
48
|
+
name,
|
|
49
|
+
scheme: t.scheme ?? 'both',
|
|
50
|
+
light: paletteFor(base, 'light', { ...config.light, ...t.light }),
|
|
51
|
+
dark: paletteFor(base, 'dark', { ...config.dark, ...t.dark }),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
/** All colour custom properties (name → [light, dark]). */
|
|
57
|
+
function colorPairs(t) {
|
|
58
|
+
const rows = [];
|
|
59
|
+
for (const role of ROLES) {
|
|
60
|
+
t.light.scales[role].forEach((c, i) => {
|
|
61
|
+
rows.push([`--pm-${role}-${i + 1}`, css(c), css(t.dark.scales[role][i])]);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
for (const [k, v] of Object.entries(t.light.semantic)) {
|
|
65
|
+
rows.push([`--pm-color-${k}`, css(v), css(t.dark.semantic[k])]);
|
|
66
|
+
}
|
|
67
|
+
return rows;
|
|
68
|
+
}
|
|
69
|
+
function colorDeclarations(t) {
|
|
70
|
+
const d = colorPairs(t).map(([name, l, dk]) => {
|
|
71
|
+
if (t.scheme === 'light')
|
|
72
|
+
return `${name}: ${l};`;
|
|
73
|
+
if (t.scheme === 'dark')
|
|
74
|
+
return `${name}: ${dk};`;
|
|
75
|
+
return l === dk ? `${name}: ${l};` : `${name}: light-dark(${l}, ${dk});`;
|
|
76
|
+
});
|
|
77
|
+
const hue = Math.round(t.light.scales.neutral[8].h);
|
|
78
|
+
d.push(`--pm-neutral-hue: ${hue};`);
|
|
79
|
+
d.push(`--pm-shadow-color-soft: light-dark(oklch(30% 0.03 ${hue} / 0.08), oklch(0% 0 0 / 0.3));`, `--pm-shadow-color: light-dark(oklch(30% 0.04 ${hue} / 0.14), oklch(0% 0 0 / 0.45));`, `--pm-shadow-color-strong: light-dark(oklch(25% 0.05 ${hue} / 0.24), oklch(0% 0 0 / 0.6));`);
|
|
80
|
+
return d;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* `:root[x], [x]`: on <html> this beats the core stylesheet's `:root` defaults whatever the load order
|
|
84
|
+
* (theme CSS is often inlined in <head> before the linked core CSS); on other elements it is a plain scope.
|
|
85
|
+
*/
|
|
86
|
+
export const attrSelector = (attr) => `:root${attr}, ${attr}`;
|
|
87
|
+
const MOTION_SCALE = { none: 0, reduced: 0.5, full: 1 };
|
|
88
|
+
/** Compile a theme config into a standalone CSS string. */
|
|
89
|
+
export function buildThemeCss(input, opts = {}) {
|
|
90
|
+
const config = { ...DEFAULT_THEME, ...input, typography: { ...DEFAULT_THEME.typography, ...input.typography } };
|
|
91
|
+
const { layer = true, includeSurfaces = true, selector = ':root' } = opts;
|
|
92
|
+
const themes = resolveThemes(config);
|
|
93
|
+
const [root, ...named] = themes;
|
|
94
|
+
const typo = config.typography ?? {};
|
|
95
|
+
const rootDecls = [
|
|
96
|
+
'color-scheme: light dark;',
|
|
97
|
+
...primitiveDeclarations({
|
|
98
|
+
...(typo.scale !== undefined && { typeRatio: typo.scale }),
|
|
99
|
+
...pairingOptions(typo.font),
|
|
100
|
+
...(typo.sans !== undefined && { fontSans: typo.sans }),
|
|
101
|
+
...(typo.display !== undefined && { fontDisplay: typo.display }),
|
|
102
|
+
...(typo.serif !== undefined && { fontSerif: typo.serif }),
|
|
103
|
+
...(typo.mono !== undefined && { fontMono: typo.mono }),
|
|
104
|
+
...(typo.body !== undefined && { fontBody: typo.body }),
|
|
105
|
+
}),
|
|
106
|
+
...motionDeclarations(),
|
|
107
|
+
`--pm-radius-factor: ${RADIUS_PRESETS[config.radius ?? 'rounded']};`,
|
|
108
|
+
// Pill keeps the normal scale for cards and panels and rounds controls fully (same as data-radius="pill").
|
|
109
|
+
...(config.radius === 'pill' ? ['--pm-radius-control: 9999px;'] : []),
|
|
110
|
+
`--pm-density: ${DENSITY_PRESETS[config.density ?? 'comfortable']};`,
|
|
111
|
+
`--pm-motion-scale: ${MOTION_SCALE[config.motion ?? 'full']};`,
|
|
112
|
+
...(config.glass?.blur !== undefined ? [`--pm-glass-blur: ${config.glass.blur}px;`] : []),
|
|
113
|
+
...(config.glass?.opacity !== undefined ? [`--pm-glass-opacity: ${config.glass.opacity}%;`] : []),
|
|
114
|
+
`--pm-surface: ${config.surface ?? 'flat'};`,
|
|
115
|
+
...surfaceDeclarations(config.surface ?? 'flat'),
|
|
116
|
+
...colorDeclarations(root),
|
|
117
|
+
// var() resolves where declared: element-scoped themes must re-point the tone context at their own colours.
|
|
118
|
+
...(selector === ':root' ? [] : toneDeclarations('accent')),
|
|
119
|
+
...componentDefaultDeclarations(config),
|
|
120
|
+
];
|
|
121
|
+
const blocks = [`${selector} {\n ${rootDecls.join('\n ')}\n}`];
|
|
122
|
+
blocks.push(`${attrSelector('[data-mode="light"]')} { color-scheme: light; }`, `${attrSelector('[data-mode="dark"]')} { color-scheme: dark; }`);
|
|
123
|
+
for (const t of named) {
|
|
124
|
+
const scheme = t.scheme === 'both' ? '' : `color-scheme: ${t.scheme};\n `;
|
|
125
|
+
const sf = input.themes?.[t.name]?.surface;
|
|
126
|
+
const sfDecls = sf ? `\n --pm-surface: ${sf};\n ${surfaceDeclarations(sf).join('\n ')}` : '';
|
|
127
|
+
// Elevation shadows embed --pm-shadow-color, which is theme-tinted: re-declare so they resolve per theme.
|
|
128
|
+
const elev = Object.entries(elevation).map(([k, v]) => `--pm-elevation-${k}: ${v};`);
|
|
129
|
+
blocks.push(`${attrSelector(`[data-theme="${t.name}"]`)} {\n ${scheme}${[...colorDeclarations(t), ...elev].join('\n ')}${sfDecls}\n}`);
|
|
130
|
+
}
|
|
131
|
+
if (includeSurfaces) {
|
|
132
|
+
blocks.push(surfacesCss());
|
|
133
|
+
blocks.push(presetAttributesCss());
|
|
134
|
+
}
|
|
135
|
+
blocks.push(forcedColorsCss());
|
|
136
|
+
const body = blocks.join('\n\n');
|
|
137
|
+
const header = `/* Prismora theme: ${config.name ?? 'custom'} — generated by @prismora/theme. Do not edit by hand. */`;
|
|
138
|
+
return layer ? `${header}\n@layer pm.themes {\n${indent(body)}\n}\n` : `${header}\n${body}\n`;
|
|
139
|
+
}
|
|
140
|
+
/** Theme-level pairing (`typography.font`) as primitive options; explicit sans/display/serif/mono still win. */
|
|
141
|
+
function pairingOptions(id) {
|
|
142
|
+
if (!id || !(id in FONT_PAIRINGS))
|
|
143
|
+
return {};
|
|
144
|
+
const p = FONT_PAIRINGS[id];
|
|
145
|
+
const f = p.families;
|
|
146
|
+
return { fontSans: fontStack(f.sans, 'sans'), fontDisplay: fontStack(f.display, 'sans'), fontSerif: fontStack(f.serif, 'serif'), fontMono: fontStack(f.mono, 'mono'), fontBody: p.body ?? 'sans' };
|
|
147
|
+
}
|
|
148
|
+
function presetAttributesCss() {
|
|
149
|
+
const r = Object.entries(RADIUS_PRESETS).map(([k, v]) => `${attrSelector(`[data-radius="${k}"]`)} { --pm-radius-factor: ${k === 'pill' ? 1 : v};${k === 'pill' ? ' --pm-radius-control: 9999px;' : ''} }`);
|
|
150
|
+
const d = Object.entries(DENSITY_PRESETS).map(([k, v]) => `${attrSelector(`[data-density="${k}"]`)} { --pm-density: ${v}; }`);
|
|
151
|
+
const m = Object.entries(MOTION_SCALE).map(([k, v]) => `${attrSelector(`[data-motion="${k}"]`)} { --pm-motion-scale: ${v}; }`);
|
|
152
|
+
// Font pairings: data-font on any element switches every family below it (and its own text).
|
|
153
|
+
const f = Object.keys(FONT_PAIRINGS).map((k) => `${attrSelector(`[data-font="${k}"]`)} { ${pairingDeclarations(k).join(' ')} }`);
|
|
154
|
+
return [
|
|
155
|
+
...r,
|
|
156
|
+
...d,
|
|
157
|
+
...m,
|
|
158
|
+
...f,
|
|
159
|
+
`${attrSelector('[data-font]')} { font-family: var(--pm-font-sans); }`,
|
|
160
|
+
'@media (prefers-reduced-motion: reduce) { :root:not([data-motion]) { --pm-motion-scale: 0.5; } }',
|
|
161
|
+
].join('\n');
|
|
162
|
+
}
|
|
163
|
+
function forcedColorsCss() {
|
|
164
|
+
return `@media (forced-colors: active) {
|
|
165
|
+
:root, [data-theme] {
|
|
166
|
+
--pm-color-bg-canvas: Canvas; --pm-color-bg-surface: Canvas; --pm-color-fg: CanvasText;
|
|
167
|
+
--pm-color-fg-muted: CanvasText; --pm-color-border: CanvasText; --pm-color-border-strong: CanvasText;
|
|
168
|
+
--pm-color-ring: Highlight;
|
|
169
|
+
--pm-sf-border: CanvasText; --pm-sf-control-border: FieldText;
|
|
170
|
+
}
|
|
171
|
+
}`;
|
|
172
|
+
}
|
|
173
|
+
function componentDefaultDeclarations(config) {
|
|
174
|
+
const out = [];
|
|
175
|
+
for (const [comp, props] of Object.entries(config.components ?? {})) {
|
|
176
|
+
for (const [prop, value] of Object.entries(props))
|
|
177
|
+
out.push(`--pm-default-${comp}-${prop}: ${value};`);
|
|
178
|
+
}
|
|
179
|
+
return out;
|
|
180
|
+
}
|
|
181
|
+
const indent = (s) => s
|
|
182
|
+
.split('\n')
|
|
183
|
+
.map((l) => (l ? ` ${l}` : l))
|
|
184
|
+
.join('\n');
|
|
185
|
+
/** Contrast audit for every theme × mode. */
|
|
186
|
+
export function auditTheme(config) {
|
|
187
|
+
return resolveThemes({ ...DEFAULT_THEME, ...config }).flatMap((t) => ['light', 'dark']
|
|
188
|
+
.filter((m) => t.scheme === 'both' || t.scheme === m)
|
|
189
|
+
.map((mode) => ({ theme: t.name, mode, checks: auditPalette(t[mode]) })));
|
|
190
|
+
}
|
|
191
|
+
export { parseColor };
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { ColorInput, Harmony, StatusRole } from '@prismora/color';
|
|
2
|
+
import type { Density, RadiusPreset } from '@prismora/tokens';
|
|
3
|
+
import type { Surface } from './surfaces.js';
|
|
4
|
+
export type MotionLevel = 'none' | 'reduced' | 'full';
|
|
5
|
+
export type Scheme = 'both' | 'light' | 'dark';
|
|
6
|
+
/** Colour options that can be set globally, per mode, or per named theme. */
|
|
7
|
+
export interface PaletteOptions {
|
|
8
|
+
seed?: ColorInput;
|
|
9
|
+
secondary?: ColorInput;
|
|
10
|
+
harmony?: Harmony;
|
|
11
|
+
neutralChroma?: number;
|
|
12
|
+
contrast?: 'normal' | 'more';
|
|
13
|
+
status?: Partial<Record<StatusRole, ColorInput>>;
|
|
14
|
+
/** Pin individual scale steps, e.g. `{ 'accent-9': '#7c5cff' }`. */
|
|
15
|
+
pins?: Record<string, ColorInput>;
|
|
16
|
+
}
|
|
17
|
+
export interface NamedTheme extends PaletteOptions {
|
|
18
|
+
/** `both` follows light/dark mode; `light`/`dark` force a fixed scheme (e.g. "midnight"). */
|
|
19
|
+
scheme?: Scheme;
|
|
20
|
+
light?: PaletteOptions;
|
|
21
|
+
dark?: PaletteOptions;
|
|
22
|
+
surface?: Surface;
|
|
23
|
+
}
|
|
24
|
+
export interface Typography {
|
|
25
|
+
/** Font pairing id from FONT_PAIRINGS (system, inter, figtree, jakarta, manrope, grotesk, friendly, editorial). */
|
|
26
|
+
font?: string;
|
|
27
|
+
/** Explicit CSS font-family values (override the pairing). */
|
|
28
|
+
sans?: string;
|
|
29
|
+
display?: string;
|
|
30
|
+
serif?: string;
|
|
31
|
+
mono?: string;
|
|
32
|
+
/** Running text in the sans (default) or the serif family. */
|
|
33
|
+
body?: 'sans' | 'serif';
|
|
34
|
+
/** Modular type-scale ratio (1.125 – 1.5). */
|
|
35
|
+
scale?: number;
|
|
36
|
+
}
|
|
37
|
+
export type ComponentDefaults = Record<string, Record<string, string>>;
|
|
38
|
+
export interface ThemeConfig extends PaletteOptions {
|
|
39
|
+
name?: string;
|
|
40
|
+
seed: ColorInput;
|
|
41
|
+
/** Per-mode overrides of the root theme. */
|
|
42
|
+
light?: PaletteOptions;
|
|
43
|
+
dark?: PaletteOptions;
|
|
44
|
+
/** Extra named themes selectable with `data-theme="<name>"`. They inherit the root options. */
|
|
45
|
+
themes?: Record<string, NamedTheme>;
|
|
46
|
+
surface?: Surface;
|
|
47
|
+
radius?: RadiusPreset;
|
|
48
|
+
density?: Density;
|
|
49
|
+
motion?: MotionLevel;
|
|
50
|
+
/** Glass tuning. */
|
|
51
|
+
glass?: {
|
|
52
|
+
blur?: number;
|
|
53
|
+
opacity?: number;
|
|
54
|
+
};
|
|
55
|
+
typography?: Typography;
|
|
56
|
+
/** Default props per component, e.g. `{ button: { variant: 'soft' } }`. */
|
|
57
|
+
components?: ComponentDefaults;
|
|
58
|
+
}
|
|
59
|
+
export declare const DEFAULT_THEME: ThemeConfig;
|
|
60
|
+
/** Identity helper that gives editors full type-checking & autocomplete. */
|
|
61
|
+
export declare function defineTheme<T extends ThemeConfig>(config: T): T;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const DEFAULT_THEME = {
|
|
2
|
+
name: 'prismora',
|
|
3
|
+
seed: '#7c5cff',
|
|
4
|
+
harmony: 'analogous',
|
|
5
|
+
surface: 'flat',
|
|
6
|
+
radius: 'rounded',
|
|
7
|
+
density: 'comfortable',
|
|
8
|
+
motion: 'full',
|
|
9
|
+
typography: { scale: 1.2 },
|
|
10
|
+
};
|
|
11
|
+
/** Identity helper that gives editors full type-checking & autocomplete. */
|
|
12
|
+
export function defineTheme(config) {
|
|
13
|
+
return config;
|
|
14
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type ThemeConfig } from './config.js';
|
|
2
|
+
/** Tailwind CSS v4 preset: maps Tailwind theme variables onto Prismora tokens. */
|
|
3
|
+
export declare function toTailwind(): string;
|
|
4
|
+
type DtcgToken = {
|
|
5
|
+
$type: string;
|
|
6
|
+
$value: unknown;
|
|
7
|
+
$description?: string;
|
|
8
|
+
};
|
|
9
|
+
type DtcgGroup = {
|
|
10
|
+
[k: string]: DtcgToken | DtcgGroup;
|
|
11
|
+
};
|
|
12
|
+
/** W3C Design Tokens (DTCG 2025.10) JSON with light/dark groups per theme. */
|
|
13
|
+
export declare function toDTCG(config: ThemeConfig): DtcgGroup;
|
|
14
|
+
/** Figma Variables import format (one collection, a mode per theme × scheme). */
|
|
15
|
+
export declare function toFigmaVariables(config: ThemeConfig): {
|
|
16
|
+
collection: string;
|
|
17
|
+
modes: string[];
|
|
18
|
+
variables: {
|
|
19
|
+
name: string;
|
|
20
|
+
type: string;
|
|
21
|
+
valuesByMode: {
|
|
22
|
+
[k: string]: {
|
|
23
|
+
r: number;
|
|
24
|
+
g: number;
|
|
25
|
+
b: number;
|
|
26
|
+
a: number;
|
|
27
|
+
} | null;
|
|
28
|
+
};
|
|
29
|
+
}[];
|
|
30
|
+
};
|
|
31
|
+
/** SCSS variables (light + dark maps) for legacy pipelines. */
|
|
32
|
+
export declare function toScss(config: ThemeConfig): string;
|
|
33
|
+
/** `defineTheme()` source for the config. */
|
|
34
|
+
export declare function toThemeSource(config: ThemeConfig): string;
|
|
35
|
+
export type ExportFormat = 'css' | 'tailwind' | 'dtcg' | 'figma' | 'scss' | 'ts' | 'json';
|
|
36
|
+
export declare const EXPORT_FORMATS: {
|
|
37
|
+
id: ExportFormat;
|
|
38
|
+
label: string;
|
|
39
|
+
filename: string;
|
|
40
|
+
}[];
|
|
41
|
+
export declare function exportTheme(config: ThemeConfig, format: ExportFormat): string;
|
|
42
|
+
export {};
|
package/dist/exports.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { ROLES, toHex, toOklchString } from '@prismora/color';
|
|
2
|
+
import { buildThemeCss, resolveThemes } from './build.js';
|
|
3
|
+
import { DEFAULT_THEME } from './config.js';
|
|
4
|
+
const ok = (c) => toOklchString(c, 'srgb');
|
|
5
|
+
/** Tailwind CSS v4 preset: maps Tailwind theme variables onto Prismora tokens. */
|
|
6
|
+
export function toTailwind() {
|
|
7
|
+
const lines = ['/* Prismora × Tailwind v4 — import after prismora CSS. */', '@theme inline {'];
|
|
8
|
+
for (const role of ROLES) {
|
|
9
|
+
for (let i = 1; i <= 12; i++)
|
|
10
|
+
lines.push(` --color-${role}-${i}: var(--pm-${role}-${i});`);
|
|
11
|
+
for (const k of ['solid', 'solid-hover', 'on-solid', 'soft', 'soft-hover', 'border', 'text'])
|
|
12
|
+
lines.push(` --color-${role}-${k}: var(--pm-color-${role}-${k});`);
|
|
13
|
+
}
|
|
14
|
+
for (const k of ['bg-canvas', 'bg-surface', 'bg-subtle', 'bg-muted', 'fg', 'fg-muted', 'border', 'border-strong', 'ring'])
|
|
15
|
+
lines.push(` --color-${k}: var(--pm-color-${k});`);
|
|
16
|
+
for (const k of ['xs', 'sm', 'md', 'lg', 'xl', '2xl'])
|
|
17
|
+
lines.push(` --radius-${k}: var(--pm-radius-${k});`);
|
|
18
|
+
for (const k of ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl'])
|
|
19
|
+
lines.push(` --text-${k}: var(--pm-font-size-${k});`);
|
|
20
|
+
lines.push(' --font-sans: var(--pm-font-sans);', ' --font-mono: var(--pm-font-mono);');
|
|
21
|
+
for (let i = 1; i <= 5; i++)
|
|
22
|
+
lines.push(` --shadow-${i}: var(--pm-elevation-${i});`);
|
|
23
|
+
lines.push('}');
|
|
24
|
+
return lines.join('\n');
|
|
25
|
+
}
|
|
26
|
+
/** W3C Design Tokens (DTCG 2025.10) JSON with light/dark groups per theme. */
|
|
27
|
+
export function toDTCG(config) {
|
|
28
|
+
const out = {};
|
|
29
|
+
for (const t of resolveThemes({ ...DEFAULT_THEME, ...config })) {
|
|
30
|
+
const themeGroup = {};
|
|
31
|
+
for (const mode of ['light', 'dark']) {
|
|
32
|
+
const p = t[mode];
|
|
33
|
+
const g = {};
|
|
34
|
+
for (const role of ROLES) {
|
|
35
|
+
const scale = {};
|
|
36
|
+
p.scales[role].forEach((c, i) => {
|
|
37
|
+
scale[String(i + 1)] = { $type: 'color', $value: dtcgColor(c) };
|
|
38
|
+
});
|
|
39
|
+
g[role] = scale;
|
|
40
|
+
}
|
|
41
|
+
const sem = {};
|
|
42
|
+
for (const [k, v] of Object.entries(p.semantic))
|
|
43
|
+
sem[k] = { $type: 'color', $value: dtcgColor(v) };
|
|
44
|
+
g.semantic = sem;
|
|
45
|
+
themeGroup[mode] = g;
|
|
46
|
+
}
|
|
47
|
+
out[t.name] = themeGroup;
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
function dtcgColor(c) {
|
|
52
|
+
return {
|
|
53
|
+
colorSpace: 'oklch',
|
|
54
|
+
components: [round(c.l, 4), round(c.c, 4), round(c.h, 2)],
|
|
55
|
+
alpha: c.alpha ?? 1,
|
|
56
|
+
hex: toHex({ ...c, alpha: 1 }),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** Figma Variables import format (one collection, a mode per theme × scheme). */
|
|
60
|
+
export function toFigmaVariables(config) {
|
|
61
|
+
const themes = resolveThemes({ ...DEFAULT_THEME, ...config });
|
|
62
|
+
const modes = themes.flatMap((t) => ['light', 'dark'].map((m) => ({ t, m, name: `${t.name}/${m}` })));
|
|
63
|
+
const first = themes[0];
|
|
64
|
+
const names = [
|
|
65
|
+
...ROLES.flatMap((r) => Array.from({ length: 12 }, (_, i) => `${r}/${i + 1}`)),
|
|
66
|
+
...Object.keys(first.light.semantic).map((k) => `semantic/${k}`),
|
|
67
|
+
];
|
|
68
|
+
return {
|
|
69
|
+
collection: 'Prismora',
|
|
70
|
+
modes: modes.map((m) => m.name),
|
|
71
|
+
variables: names.map((name) => ({
|
|
72
|
+
name,
|
|
73
|
+
type: 'COLOR',
|
|
74
|
+
valuesByMode: Object.fromEntries(modes.map(({ t, m, name: modeName }) => {
|
|
75
|
+
const [group, key] = name.split('/');
|
|
76
|
+
const c = group === 'semantic'
|
|
77
|
+
? t[m].semantic[key]
|
|
78
|
+
: t[m].scales[group][Number(key) - 1];
|
|
79
|
+
return [modeName, c ? figmaRgba(c) : null];
|
|
80
|
+
})),
|
|
81
|
+
})),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function figmaRgba(c) {
|
|
85
|
+
const hex = toHex({ ...c, alpha: 1 });
|
|
86
|
+
const n = (i) => round(Number.parseInt(hex.slice(i, i + 2), 16) / 255, 4);
|
|
87
|
+
return { r: n(1), g: n(3), b: n(5), a: c.alpha ?? 1 };
|
|
88
|
+
}
|
|
89
|
+
/** SCSS variables (light + dark maps) for legacy pipelines. */
|
|
90
|
+
export function toScss(config) {
|
|
91
|
+
const [t] = resolveThemes({ ...DEFAULT_THEME, ...config });
|
|
92
|
+
const lines = ['// Prismora — generated SCSS. Prefer the CSS custom properties at runtime.'];
|
|
93
|
+
for (const mode of ['light', 'dark']) {
|
|
94
|
+
lines.push(`$pm-${mode}: (`);
|
|
95
|
+
for (const [k, v] of Object.entries(t[mode].semantic))
|
|
96
|
+
lines.push(` "${k}": ${ok(v)},`);
|
|
97
|
+
lines.push(');');
|
|
98
|
+
}
|
|
99
|
+
return lines.join('\n');
|
|
100
|
+
}
|
|
101
|
+
/** `defineTheme()` source for the config. */
|
|
102
|
+
export function toThemeSource(config) {
|
|
103
|
+
return `import { defineTheme } from '@prismora/theme';
|
|
104
|
+
|
|
105
|
+
export default defineTheme(${JSON.stringify(config, null, 2)});
|
|
106
|
+
`;
|
|
107
|
+
}
|
|
108
|
+
export const EXPORT_FORMATS = [
|
|
109
|
+
{ id: 'css', label: 'CSS', filename: 'prismora.theme.css' },
|
|
110
|
+
{ id: 'ts', label: 'defineTheme()', filename: 'prismora.theme.ts' },
|
|
111
|
+
{ id: 'tailwind', label: 'Tailwind v4', filename: 'prismora.tailwind.css' },
|
|
112
|
+
{ id: 'dtcg', label: 'Design Tokens (DTCG)', filename: 'prismora.tokens.json' },
|
|
113
|
+
{ id: 'figma', label: 'Figma Variables', filename: 'prismora.figma.json' },
|
|
114
|
+
{ id: 'scss', label: 'SCSS', filename: '_prismora.scss' },
|
|
115
|
+
{ id: 'json', label: 'Config JSON', filename: 'prismora.config.json' },
|
|
116
|
+
];
|
|
117
|
+
export function exportTheme(config, format) {
|
|
118
|
+
switch (format) {
|
|
119
|
+
case 'css':
|
|
120
|
+
return buildThemeCss(config);
|
|
121
|
+
case 'tailwind':
|
|
122
|
+
return toTailwind();
|
|
123
|
+
case 'dtcg':
|
|
124
|
+
return JSON.stringify(toDTCG(config), null, 2);
|
|
125
|
+
case 'figma':
|
|
126
|
+
return JSON.stringify(toFigmaVariables(config), null, 2);
|
|
127
|
+
case 'scss':
|
|
128
|
+
return toScss(config);
|
|
129
|
+
case 'ts':
|
|
130
|
+
return toThemeSource(config);
|
|
131
|
+
case 'json':
|
|
132
|
+
return JSON.stringify(config, null, 2);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const round = (v, d) => Math.round(v * 10 ** d) / 10 ** d;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ThemeConfig } from './config.js';
|
|
2
|
+
export type ModePreference = 'system' | 'light' | 'dark';
|
|
3
|
+
export interface ThemeState {
|
|
4
|
+
mode: ModePreference;
|
|
5
|
+
/** Named theme (`data-theme`), or null for the default. */
|
|
6
|
+
theme: string | null;
|
|
7
|
+
/** Saved visual preferences, applied as `data-*` on the root (null = the theme's default). */
|
|
8
|
+
surface?: string | null;
|
|
9
|
+
radius?: string | null;
|
|
10
|
+
density?: string | null;
|
|
11
|
+
motion?: string | null;
|
|
12
|
+
/** Font pairing id (`data-font`), e.g. inter, editorial, system. Load its fonts with @prismora/fonts. */
|
|
13
|
+
font?: string | null;
|
|
14
|
+
/** Root text size: sm (93.75%), md, lg (112.5%), xl (125%). Every rem-based token scales with it. */
|
|
15
|
+
textSize?: string | null;
|
|
16
|
+
/** Phone UI: 'native' sets the `mobile` attribute (bottom sheets, swipe, tab bar); 'web' keeps responsive web. */
|
|
17
|
+
mobile?: 'native' | 'web' | null;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Inline this in <head> before any stylesheet to apply the saved mode/theme before first paint
|
|
21
|
+
* (prevents a flash of the wrong theme). Framework-agnostic string; safe for SSR templates.
|
|
22
|
+
*/
|
|
23
|
+
export declare const noFlashScript: string;
|
|
24
|
+
/** Inject (or replace) a runtime-generated theme stylesheet. Returns the CSS. */
|
|
25
|
+
export declare function createTheme(config: ThemeConfig, target?: Document | ShadowRoot): string;
|
|
26
|
+
type Listener = (state: ThemeState) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Mode/theme controller: persists to localStorage, syncs across tabs, and animates
|
|
29
|
+
* the switch with a circular View Transition reveal when motion is allowed.
|
|
30
|
+
*/
|
|
31
|
+
export declare class ThemeController {
|
|
32
|
+
#private;
|
|
33
|
+
constructor(root?: HTMLElement);
|
|
34
|
+
static read(): ThemeState;
|
|
35
|
+
get state(): ThemeState;
|
|
36
|
+
/** Resolved scheme currently shown. */
|
|
37
|
+
get resolvedMode(): 'light' | 'dark';
|
|
38
|
+
subscribe(fn: Listener): () => void;
|
|
39
|
+
set(next: Partial<ThemeState>, origin?: {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
}): Promise<void>;
|
|
43
|
+
/** Switch between light and dark in one step: sets the opposite of what is shown now. For a two-state button. */
|
|
44
|
+
flip(origin?: {
|
|
45
|
+
x: number;
|
|
46
|
+
y: number;
|
|
47
|
+
}): Promise<void>;
|
|
48
|
+
/** Cycle system → light → dark. For a three-way control; use `flip()` for a two-state button. */
|
|
49
|
+
toggle(origin?: {
|
|
50
|
+
x: number;
|
|
51
|
+
y: number;
|
|
52
|
+
}): Promise<void>;
|
|
53
|
+
/** Forget every saved preference (back to system mode and the theme's defaults). */
|
|
54
|
+
reset(origin?: {
|
|
55
|
+
x: number;
|
|
56
|
+
y: number;
|
|
57
|
+
}): Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
export {};
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { buildThemeCss } from './build.js';
|
|
2
|
+
const STORAGE_KEY = 'pm-theme';
|
|
3
|
+
/** Preference → root attribute. */
|
|
4
|
+
const PREFS = { font: 'data-font', surface: 'data-surface', radius: 'data-radius', density: 'data-density', motion: 'data-motion', textSize: 'data-text-size' };
|
|
5
|
+
const TOKEN = /^[a-z0-9-]{1,32}$/;
|
|
6
|
+
/**
|
|
7
|
+
* Inline this in <head> before any stylesheet to apply the saved mode/theme before first paint
|
|
8
|
+
* (prevents a flash of the wrong theme). Framework-agnostic string; safe for SSR templates.
|
|
9
|
+
*/
|
|
10
|
+
export const noFlashScript = `(()=>{try{var s=JSON.parse(localStorage.getItem('${STORAGE_KEY}')||'{}'),d=document.documentElement,ok=function(v){return typeof v==='string'&&/^[a-z0-9-]{1,32}$/.test(v)},p=${JSON.stringify(PREFS)};if(s.mode==='light'||s.mode==='dark')d.dataset.mode=s.mode;if(ok(s.theme))d.dataset.theme=s.theme;for(var k in p)if(ok(s[k]))d.setAttribute(p[k],s[k]);if(s.mobile==='native')d.setAttribute('mobile','');else if(s.mobile==='web')d.setAttribute('mobile','false');}catch(e){}})();`;
|
|
11
|
+
/** Inject (or replace) a runtime-generated theme stylesheet. Returns the CSS. */
|
|
12
|
+
export function createTheme(config, target = document) {
|
|
13
|
+
const cssText = buildThemeCss(config);
|
|
14
|
+
const id = 'pm-runtime-theme';
|
|
15
|
+
if ('adoptedStyleSheets' in target && typeof CSSStyleSheet !== 'undefined' && 'replaceSync' in CSSStyleSheet.prototype) {
|
|
16
|
+
const holder = target;
|
|
17
|
+
if (!holder.__pmSheet) {
|
|
18
|
+
holder.__pmSheet = new CSSStyleSheet();
|
|
19
|
+
target.adoptedStyleSheets = [...target.adoptedStyleSheets, holder.__pmSheet];
|
|
20
|
+
}
|
|
21
|
+
holder.__pmSheet.replaceSync(cssText);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
const doc = target instanceof Document ? target : target.ownerDocument;
|
|
25
|
+
let el = doc.getElementById(id);
|
|
26
|
+
if (!el) {
|
|
27
|
+
el = doc.createElement('style');
|
|
28
|
+
el.id = id;
|
|
29
|
+
doc.head.append(el);
|
|
30
|
+
}
|
|
31
|
+
el.textContent = cssText;
|
|
32
|
+
}
|
|
33
|
+
return cssText;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Mode/theme controller: persists to localStorage, syncs across tabs, and animates
|
|
37
|
+
* the switch with a circular View Transition reveal when motion is allowed.
|
|
38
|
+
*/
|
|
39
|
+
export class ThemeController {
|
|
40
|
+
#state;
|
|
41
|
+
#listeners = new Set();
|
|
42
|
+
#root;
|
|
43
|
+
/** The page's own `mobile` attribute before any saved choice (restored on reset). */
|
|
44
|
+
#pageMobile;
|
|
45
|
+
constructor(root = document.documentElement) {
|
|
46
|
+
this.#root = root;
|
|
47
|
+
this.#state = ThemeController.read();
|
|
48
|
+
this.#apply();
|
|
49
|
+
addEventListener('storage', (e) => {
|
|
50
|
+
if (e.key !== STORAGE_KEY)
|
|
51
|
+
return;
|
|
52
|
+
this.#state = ThemeController.read();
|
|
53
|
+
this.#apply();
|
|
54
|
+
this.#emit();
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
static read() {
|
|
58
|
+
try {
|
|
59
|
+
const raw = JSON.parse(localStorage.getItem(STORAGE_KEY) ?? '{}');
|
|
60
|
+
const tok = (v) => (typeof v === 'string' && TOKEN.test(v) ? v : null);
|
|
61
|
+
return {
|
|
62
|
+
mode: raw.mode === 'light' || raw.mode === 'dark' ? raw.mode : 'system',
|
|
63
|
+
theme: tok(raw.theme),
|
|
64
|
+
font: tok(raw.font), surface: tok(raw.surface), radius: tok(raw.radius), density: tok(raw.density), motion: tok(raw.motion), textSize: tok(raw.textSize),
|
|
65
|
+
mobile: raw.mobile === 'native' || raw.mobile === 'web' ? raw.mobile : null,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return { mode: 'system', theme: null };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
get state() {
|
|
73
|
+
return { ...this.#state };
|
|
74
|
+
}
|
|
75
|
+
/** Resolved scheme currently shown. */
|
|
76
|
+
get resolvedMode() {
|
|
77
|
+
if (this.#state.mode !== 'system')
|
|
78
|
+
return this.#state.mode;
|
|
79
|
+
return matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
80
|
+
}
|
|
81
|
+
subscribe(fn) {
|
|
82
|
+
this.#listeners.add(fn);
|
|
83
|
+
fn(this.state);
|
|
84
|
+
return () => this.#listeners.delete(fn);
|
|
85
|
+
}
|
|
86
|
+
async set(next, origin) {
|
|
87
|
+
// Subscribers hear about a change only once it is applied: inside a view transition the update runs later, in
|
|
88
|
+
// the transition's callback, and listeners read resolvedMode then.
|
|
89
|
+
const update = () => {
|
|
90
|
+
this.#state = { ...this.#state, ...next };
|
|
91
|
+
try {
|
|
92
|
+
localStorage.setItem(STORAGE_KEY, JSON.stringify(this.#state));
|
|
93
|
+
}
|
|
94
|
+
catch { /* storage full or blocked: apply anyway */ }
|
|
95
|
+
this.#apply();
|
|
96
|
+
this.#emit();
|
|
97
|
+
};
|
|
98
|
+
const doc = document;
|
|
99
|
+
const motionOk = !matchMedia('(prefers-reduced-motion: reduce)').matches &&
|
|
100
|
+
!['none', 'reduced'].includes(this.#root.closest('[data-motion]')?.getAttribute('data-motion') ?? '');
|
|
101
|
+
// Only colour changes (mode, theme) get the cross-fade / circular reveal; layout preferences apply instantly.
|
|
102
|
+
const recolour = ('mode' in next && next.mode !== this.#state.mode) || ('theme' in next && next.theme !== this.#state.theme);
|
|
103
|
+
if (doc.startViewTransition && motionOk && recolour) {
|
|
104
|
+
const vt = doc.startViewTransition(update);
|
|
105
|
+
// A newer change can cut a transition short; that is expected, not an error.
|
|
106
|
+
const quiet = () => { };
|
|
107
|
+
vt.finished.catch(quiet);
|
|
108
|
+
vt.updateCallbackDone.catch(quiet);
|
|
109
|
+
vt.ready.catch(quiet);
|
|
110
|
+
// `await set(…)` resolves once the new state is applied.
|
|
111
|
+
await vt.updateCallbackDone.catch(quiet);
|
|
112
|
+
if (origin) {
|
|
113
|
+
try {
|
|
114
|
+
await vt.ready;
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const r = Math.hypot(Math.max(origin.x, innerWidth - origin.x), Math.max(origin.y, innerHeight - origin.y));
|
|
120
|
+
document.documentElement.animate({ clipPath: [`circle(0 at ${origin.x}px ${origin.y}px)`, `circle(${r}px at ${origin.x}px ${origin.y}px)`] }, { duration: 450, easing: 'cubic-bezier(0.2, 0, 0, 1)', pseudoElement: '::view-transition-new(root)' });
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
update();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/** Switch between light and dark in one step: sets the opposite of what is shown now. For a two-state button. */
|
|
128
|
+
flip(origin) {
|
|
129
|
+
return this.set({ mode: this.resolvedMode === 'dark' ? 'light' : 'dark' }, origin);
|
|
130
|
+
}
|
|
131
|
+
/** Cycle system → light → dark. For a three-way control; use `flip()` for a two-state button. */
|
|
132
|
+
toggle(origin) {
|
|
133
|
+
const order = ['system', 'light', 'dark'];
|
|
134
|
+
const next = order[(order.indexOf(this.#state.mode) + 1) % order.length];
|
|
135
|
+
return this.set({ mode: next }, origin);
|
|
136
|
+
}
|
|
137
|
+
/** Forget every saved preference (back to system mode and the theme's defaults). */
|
|
138
|
+
reset(origin) {
|
|
139
|
+
return this.set({ mode: 'system', theme: null, font: null, surface: null, radius: null, density: null, motion: null, textSize: null, mobile: null }, origin);
|
|
140
|
+
}
|
|
141
|
+
#apply() {
|
|
142
|
+
const { mode, theme } = this.#state;
|
|
143
|
+
if (mode === 'system')
|
|
144
|
+
delete this.#root.dataset.mode;
|
|
145
|
+
else
|
|
146
|
+
this.#root.dataset.mode = mode;
|
|
147
|
+
if (theme)
|
|
148
|
+
this.#root.dataset.theme = theme;
|
|
149
|
+
else
|
|
150
|
+
delete this.#root.dataset.theme;
|
|
151
|
+
for (const [k, attr] of Object.entries(PREFS)) {
|
|
152
|
+
const v = this.#state[k];
|
|
153
|
+
if (v)
|
|
154
|
+
this.#root.setAttribute(attr, v);
|
|
155
|
+
else
|
|
156
|
+
this.#root.removeAttribute(attr);
|
|
157
|
+
}
|
|
158
|
+
// Only touch `mobile` when the user chose; otherwise the page's own markup decides.
|
|
159
|
+
if (this.#pageMobile === undefined)
|
|
160
|
+
this.#pageMobile = this.#state.mobile ? null : this.#root.getAttribute('mobile');
|
|
161
|
+
const m = this.#state.mobile === 'native' ? '' : this.#state.mobile === 'web' ? 'false' : this.#pageMobile;
|
|
162
|
+
if (m === null)
|
|
163
|
+
this.#root.removeAttribute('mobile');
|
|
164
|
+
else
|
|
165
|
+
this.#root.setAttribute('mobile', m);
|
|
166
|
+
}
|
|
167
|
+
#emit() {
|
|
168
|
+
for (const fn of this.#listeners)
|
|
169
|
+
fn(this.state);
|
|
170
|
+
}
|
|
171
|
+
}
|
package/dist/share.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ThemeConfig } from './config.js';
|
|
2
|
+
/**
|
|
3
|
+
* Encode a theme config for a share URL: JSON → deflate-raw → base64url.
|
|
4
|
+
* Uses CompressionStream (browsers, Bun, Node ≥ 18).
|
|
5
|
+
*/
|
|
6
|
+
export declare function encodeTheme(config: ThemeConfig): Promise<string>;
|
|
7
|
+
export declare function decodeTheme(encoded: string): Promise<ThemeConfig>;
|
|
8
|
+
/** Extract the encoded theme from a full generator URL (`…/generator#t=1.xxxx` or `?t=`). */
|
|
9
|
+
export declare function themeParamFromUrl(url: string): string | null;
|
package/dist/share.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encode a theme config for a share URL: JSON → deflate-raw → base64url.
|
|
3
|
+
* Uses CompressionStream (browsers, Bun, Node ≥ 18).
|
|
4
|
+
*/
|
|
5
|
+
export async function encodeTheme(config) {
|
|
6
|
+
const bytes = new TextEncoder().encode(JSON.stringify(config));
|
|
7
|
+
const compressed = await pipe(bytes, new CompressionStream('deflate-raw'));
|
|
8
|
+
return `1.${toBase64Url(compressed)}`;
|
|
9
|
+
}
|
|
10
|
+
export async function decodeTheme(encoded) {
|
|
11
|
+
const [version, data] = encoded.split('.', 2);
|
|
12
|
+
if (version !== '1' || !data)
|
|
13
|
+
throw new Error('Unsupported theme link');
|
|
14
|
+
const bytes = await pipe(fromBase64Url(data), new DecompressionStream('deflate-raw'));
|
|
15
|
+
const parsed = JSON.parse(new TextDecoder().decode(bytes));
|
|
16
|
+
if (!parsed || typeof parsed !== 'object' || !('seed' in parsed))
|
|
17
|
+
throw new Error('Invalid theme');
|
|
18
|
+
return parsed;
|
|
19
|
+
}
|
|
20
|
+
/** Extract the encoded theme from a full generator URL (`…/generator#t=1.xxxx` or `?t=`). */
|
|
21
|
+
export function themeParamFromUrl(url) {
|
|
22
|
+
const u = new URL(url);
|
|
23
|
+
const fromHash = new URLSearchParams(u.hash.slice(1)).get('t');
|
|
24
|
+
return fromHash ?? u.searchParams.get('t');
|
|
25
|
+
}
|
|
26
|
+
async function pipe(bytes, stream) {
|
|
27
|
+
const out = new Blob([bytes]).stream().pipeThrough(stream);
|
|
28
|
+
return new Uint8Array(await new Response(out).arrayBuffer());
|
|
29
|
+
}
|
|
30
|
+
function toBase64Url(bytes) {
|
|
31
|
+
let s = '';
|
|
32
|
+
for (const b of bytes)
|
|
33
|
+
s += String.fromCharCode(b);
|
|
34
|
+
return btoa(s).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
35
|
+
}
|
|
36
|
+
function fromBase64Url(s) {
|
|
37
|
+
const b64 = s.replace(/-/g, '+').replace(/_/g, '/');
|
|
38
|
+
const bin = atob(b64 + '='.repeat((4 - (b64.length % 4)) % 4));
|
|
39
|
+
return Uint8Array.from(bin, (c) => c.charCodeAt(0));
|
|
40
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Surface styles. Each surface is a set of inherited UI-tier tokens (`--pm-sf-*`).
|
|
3
|
+
* Components only read these tokens, so every component supports every surface,
|
|
4
|
+
* and a surface can be set on any ancestor (nearest wins through inheritance) or
|
|
5
|
+
* on a single component.
|
|
6
|
+
*
|
|
7
|
+
* Contract:
|
|
8
|
+
* --pm-sf-bg container background colour
|
|
9
|
+
* --pm-sf-image extra background layer (gradient / sheen) or `none`
|
|
10
|
+
* --pm-sf-border container border colour (meets 3:1 where it is the only boundary)
|
|
11
|
+
* --pm-sf-shadow container shadow
|
|
12
|
+
* --pm-sf-backdrop backdrop-filter value or `none`
|
|
13
|
+
* --pm-sf-control-bg text-input / select field background
|
|
14
|
+
* --pm-sf-control-border field border colour (≥ 3:1)
|
|
15
|
+
* --pm-sf-control-shadow field shadow (inset for neumorphic)
|
|
16
|
+
* --pm-sf-raise shadow for raised controls (buttons, switches)
|
|
17
|
+
* --pm-sf-press shadow for pressed controls
|
|
18
|
+
* --pm-sf-solid-image overlay for solid fills (gradient sheen) or `none`
|
|
19
|
+
* --pm-sf-soft-mix % of the soft tone mixed with transparency (glass translucency)
|
|
20
|
+
*/
|
|
21
|
+
export type Surface = 'flat' | 'outline' | 'gradient' | 'glass' | 'neumorphic';
|
|
22
|
+
export declare const SURFACES: Surface[];
|
|
23
|
+
export declare const surfaceTokens: Record<Surface, Record<string, string>>;
|
|
24
|
+
export declare function surfaceDeclarations(surface: Surface): string[];
|
|
25
|
+
/** CSS for all `[data-surface]` selectors plus accessibility fallbacks. */
|
|
26
|
+
export declare function surfacesCss(): string;
|
package/dist/surfaces.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Surface styles. Each surface is a set of inherited UI-tier tokens (`--pm-sf-*`).
|
|
3
|
+
* Components only read these tokens, so every component supports every surface,
|
|
4
|
+
* and a surface can be set on any ancestor (nearest wins through inheritance) or
|
|
5
|
+
* on a single component.
|
|
6
|
+
*
|
|
7
|
+
* Contract:
|
|
8
|
+
* --pm-sf-bg container background colour
|
|
9
|
+
* --pm-sf-image extra background layer (gradient / sheen) or `none`
|
|
10
|
+
* --pm-sf-border container border colour (meets 3:1 where it is the only boundary)
|
|
11
|
+
* --pm-sf-shadow container shadow
|
|
12
|
+
* --pm-sf-backdrop backdrop-filter value or `none`
|
|
13
|
+
* --pm-sf-control-bg text-input / select field background
|
|
14
|
+
* --pm-sf-control-border field border colour (≥ 3:1)
|
|
15
|
+
* --pm-sf-control-shadow field shadow (inset for neumorphic)
|
|
16
|
+
* --pm-sf-raise shadow for raised controls (buttons, switches)
|
|
17
|
+
* --pm-sf-press shadow for pressed controls
|
|
18
|
+
* --pm-sf-solid-image overlay for solid fills (gradient sheen) or `none`
|
|
19
|
+
* --pm-sf-soft-mix % of the soft tone mixed with transparency (glass translucency)
|
|
20
|
+
*/
|
|
21
|
+
export const SURFACES = ['flat', 'outline', 'gradient', 'glass', 'neumorphic'];
|
|
22
|
+
const NEU_LIGHT = 'light-dark(oklch(100% 0 0 / 0.85), oklch(100% 0 0 / 0.06))';
|
|
23
|
+
const NEU_DARK = 'light-dark(oklch(35% 0.03 var(--pm-neutral-hue) / 0.22), oklch(0% 0 0 / 0.55))';
|
|
24
|
+
export const surfaceTokens = {
|
|
25
|
+
flat: {
|
|
26
|
+
'sf-bg': 'var(--pm-color-bg-surface)',
|
|
27
|
+
'sf-image': 'none',
|
|
28
|
+
'sf-border': 'var(--pm-color-border)',
|
|
29
|
+
'sf-shadow': 'var(--pm-elevation-1)',
|
|
30
|
+
'sf-backdrop': 'none',
|
|
31
|
+
'sf-control-bg': 'var(--pm-color-bg-surface)',
|
|
32
|
+
'sf-control-border': 'var(--pm-color-border-strong)',
|
|
33
|
+
'sf-control-shadow': 'none',
|
|
34
|
+
'sf-raise': 'var(--pm-elevation-1)',
|
|
35
|
+
'sf-press': 'none',
|
|
36
|
+
'sf-solid-image': 'none',
|
|
37
|
+
'sf-soft-mix': '100%',
|
|
38
|
+
},
|
|
39
|
+
outline: {
|
|
40
|
+
'sf-bg': 'transparent',
|
|
41
|
+
'sf-image': 'none',
|
|
42
|
+
'sf-border': 'var(--pm-color-border-strong)',
|
|
43
|
+
'sf-shadow': 'none',
|
|
44
|
+
'sf-backdrop': 'none',
|
|
45
|
+
'sf-control-bg': 'transparent',
|
|
46
|
+
'sf-control-border': 'var(--pm-color-border-strong)',
|
|
47
|
+
'sf-control-shadow': 'none',
|
|
48
|
+
'sf-raise': 'none',
|
|
49
|
+
'sf-press': 'none',
|
|
50
|
+
'sf-solid-image': 'none',
|
|
51
|
+
'sf-soft-mix': '100%',
|
|
52
|
+
},
|
|
53
|
+
gradient: {
|
|
54
|
+
'sf-bg': 'var(--pm-color-bg-surface)',
|
|
55
|
+
'sf-image': 'linear-gradient(150deg in oklab, color-mix(in oklab, var(--pm-color-accent-soft) 75%, transparent), transparent 55%, color-mix(in oklab, var(--pm-color-secondary-soft) 70%, transparent))',
|
|
56
|
+
'sf-border': 'color-mix(in oklab, var(--pm-color-accent-border) 70%, var(--pm-color-border))',
|
|
57
|
+
'sf-shadow': 'var(--pm-elevation-2)',
|
|
58
|
+
'sf-backdrop': 'none',
|
|
59
|
+
'sf-control-bg': 'var(--pm-color-bg-surface)',
|
|
60
|
+
'sf-control-border': 'var(--pm-color-border-strong)',
|
|
61
|
+
'sf-control-shadow': 'none',
|
|
62
|
+
'sf-raise': 'var(--pm-elevation-2)',
|
|
63
|
+
'sf-press': 'var(--pm-elevation-1)',
|
|
64
|
+
'sf-solid-image': 'linear-gradient(160deg in oklab, oklch(100% 0 0 / 0.22), oklch(100% 0 0 / 0) 50%, oklch(0% 0 0 / 0.12))',
|
|
65
|
+
'sf-soft-mix': '100%',
|
|
66
|
+
},
|
|
67
|
+
glass: {
|
|
68
|
+
'sf-bg': 'color-mix(in oklab, var(--pm-color-bg-surface) var(--pm-glass-opacity, 58%), transparent)',
|
|
69
|
+
'sf-image': 'linear-gradient(160deg in oklab, light-dark(oklch(100% 0 0 / 0.5), oklch(100% 0 0 / 0.08)), oklch(100% 0 0 / 0) 40%)',
|
|
70
|
+
'sf-border': 'light-dark(oklch(100% 0 0 / 0.6), oklch(100% 0 0 / 0.14))',
|
|
71
|
+
'sf-shadow': 'inset 0 1px 0 light-dark(oklch(100% 0 0 / 0.7), oklch(100% 0 0 / 0.1)), var(--pm-elevation-3)',
|
|
72
|
+
'sf-backdrop': 'blur(var(--pm-glass-blur, 18px)) saturate(170%)',
|
|
73
|
+
'sf-control-bg': 'color-mix(in oklab, var(--pm-color-bg-surface) 70%, transparent)',
|
|
74
|
+
'sf-control-border': 'var(--pm-color-border-strong)',
|
|
75
|
+
'sf-control-shadow': 'inset 0 1px 0 light-dark(oklch(100% 0 0 / 0.5), oklch(100% 0 0 / 0.06))',
|
|
76
|
+
'sf-raise': 'inset 0 1px 0 oklch(100% 0 0 / 0.25), var(--pm-elevation-1)',
|
|
77
|
+
'sf-press': 'none',
|
|
78
|
+
'sf-solid-image': 'linear-gradient(180deg, oklch(100% 0 0 / 0.2), oklch(100% 0 0 / 0) 60%)',
|
|
79
|
+
'sf-soft-mix': '72%',
|
|
80
|
+
},
|
|
81
|
+
neumorphic: {
|
|
82
|
+
'sf-bg': 'var(--pm-color-bg-canvas)',
|
|
83
|
+
'sf-image': 'none',
|
|
84
|
+
// A visible boundary is kept so components meet WCAG 1.4.11 without relying on shadows.
|
|
85
|
+
'sf-border': 'color-mix(in oklab, var(--pm-color-border) 70%, transparent)',
|
|
86
|
+
'sf-shadow': `-6px -6px 14px ${NEU_LIGHT}, 6px 6px 16px ${NEU_DARK}`,
|
|
87
|
+
'sf-backdrop': 'none',
|
|
88
|
+
'sf-control-bg': 'var(--pm-color-bg-canvas)',
|
|
89
|
+
'sf-control-border': 'var(--pm-color-border-strong)',
|
|
90
|
+
'sf-control-shadow': `inset 3px 3px 6px ${NEU_DARK}, inset -3px -3px 6px ${NEU_LIGHT}`,
|
|
91
|
+
'sf-raise': `-3px -3px 8px ${NEU_LIGHT}, 3px 3px 8px ${NEU_DARK}`,
|
|
92
|
+
'sf-press': `inset 2px 2px 5px ${NEU_DARK}, inset -2px -2px 5px ${NEU_LIGHT}`,
|
|
93
|
+
'sf-solid-image': 'none',
|
|
94
|
+
'sf-soft-mix': '100%',
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
export function surfaceDeclarations(surface) {
|
|
98
|
+
return Object.entries(surfaceTokens[surface]).map(([k, v]) => `--pm-${k}: ${v};`);
|
|
99
|
+
}
|
|
100
|
+
/** CSS for all `[data-surface]` selectors plus accessibility fallbacks. */
|
|
101
|
+
export function surfacesCss() {
|
|
102
|
+
const blocks = SURFACES.map((s) => `:root[data-surface="${s}"], [data-surface="${s}"] {\n --pm-surface: ${s};\n ${surfaceDeclarations(s).join('\n ')}\n}`);
|
|
103
|
+
return `${blocks.join('\n')}
|
|
104
|
+
/* Glass fallbacks: opaque when blur is unsupported or the user prefers less transparency. */
|
|
105
|
+
@supports not (backdrop-filter: blur(1px)) {
|
|
106
|
+
[data-surface="glass"], :root { --pm-glass-opacity: 96%; }
|
|
107
|
+
}
|
|
108
|
+
@media (prefers-reduced-transparency: reduce) {
|
|
109
|
+
:root, [data-surface] { --pm-glass-opacity: 96%; --pm-sf-backdrop: none; }
|
|
110
|
+
}
|
|
111
|
+
@media (prefers-contrast: more) {
|
|
112
|
+
:root, [data-surface] { --pm-glass-opacity: 92%; --pm-sf-border: var(--pm-color-border-strong); }
|
|
113
|
+
}`;
|
|
114
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismora/theme",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "defineTheme(), CSS theme compiler, exporters, share links and runtime theme controller.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"prismora",
|
|
7
|
+
"design-system",
|
|
8
|
+
"theme",
|
|
9
|
+
"dark-mode",
|
|
10
|
+
"oklch"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://prismora.design",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/axxra/prismora/issues"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/axxra/prismora.git",
|
|
19
|
+
"directory": "packages/theme"
|
|
20
|
+
},
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"author": "Aravind Kumar",
|
|
23
|
+
"type": "module",
|
|
24
|
+
"main": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"default": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./browser": "./dist/browser.js"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist"
|
|
35
|
+
],
|
|
36
|
+
"sideEffects": false,
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@prismora/color": "^0.1.0",
|
|
39
|
+
"@prismora/tokens": "^0.1.0",
|
|
40
|
+
"@prismora/motion": "^0.1.0"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
}
|
|
45
|
+
}
|