@adea-ai/themes 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/shadcn.d.ts +18 -0
- package/dist/adapters/shadcn.d.ts.map +1 -1
- package/dist/adapters/shadcn.js +89 -2
- package/dist/adapters/shadcn.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/adapters/shadcn.ts +117 -2
- package/src/index.ts +8 -1
|
@@ -26,6 +26,24 @@ import type { AdeaTheme, AdeaThemeColors, ShadcnThemeProjection } from '../schem
|
|
|
26
26
|
export type ShadcnTheme = AdeaTheme & {
|
|
27
27
|
shadcn?: ShadcnThemeProjection;
|
|
28
28
|
};
|
|
29
|
+
/** The solid destructive pair consumed by filled shadcn actions. */
|
|
30
|
+
export interface ShadcnDestructiveProjection {
|
|
31
|
+
/** Presentation fill derived from, but distinct from, the canonical error role. */
|
|
32
|
+
readonly fill: string;
|
|
33
|
+
/** Text color that clears the solid and 90%-hover presentation floors. */
|
|
34
|
+
readonly foreground: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The shared destructive solid fill and foreground as rendered by the UI.
|
|
38
|
+
*
|
|
39
|
+
* A filled destructive button uses `--destructive/90` on hover. A foreground that
|
|
40
|
+
* clears the original fill can fall below AA when that color is alpha-composited
|
|
41
|
+
* over a light or dark surface. This projection keeps the canonical error color
|
|
42
|
+
* untouched, adjusts only the presentation lightness along its hue, and tests the
|
|
43
|
+
* rounded sRGB output against the canvas and both card surfaces. The 5:1 internal
|
|
44
|
+
* margin protects the 4.5:1 AA floor from browser quantization.
|
|
45
|
+
*/
|
|
46
|
+
export declare function shadcnDestructiveProjection(theme: ShadcnTheme): ShadcnDestructiveProjection;
|
|
29
47
|
/**
|
|
30
48
|
* Canonical role → shadcn custom-property name.
|
|
31
49
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shadcn.d.ts","sourceRoot":"","sources":["../../src/adapters/shadcn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"shadcn.d.ts","sourceRoot":"","sources":["../../src/adapters/shadcn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AAWrF,iFAAiF;AACjF,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG;IAAE,MAAM,CAAC,EAAE,qBAAqB,CAAA;CAAE,CAAA;AAExE,oEAAoE;AACpE,MAAM,WAAW,2BAA2B;IAC1C,mFAAmF;IACnF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,0EAA0E;IAC1E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC5B;AAwBD;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,WAAW,GAAG,2BAA2B,CA6D3F;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,eAAe,EAAE,MAAM,CAAC,CAsBzE,CAAA;AAEF;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAItE;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA6D1E;AAED,0CAA0C;AAC1C,wBAAgB,SAAS,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,SAAU,GAAG,MAAM,CAKxE"}
|
package/dist/adapters/shadcn.js
CHANGED
|
@@ -22,6 +22,90 @@
|
|
|
22
22
|
* A table of the whole mapping is in `docs/shadcn-bridge.md`.
|
|
23
23
|
*/
|
|
24
24
|
import { STATUS_ROLES, statusForeground, tint } from '../derive.js';
|
|
25
|
+
import { contrastRatio, formatOklch, gamutMap, hexToOklch, oklchToHex, parseColor, } from '../oklch.js';
|
|
26
|
+
const DESTRUCTIVE_PRESENTATION_FLOOR = 5;
|
|
27
|
+
const DESTRUCTIVE_HOVER_OPACITY = 0.9;
|
|
28
|
+
const DESTRUCTIVE_PRESENTATION_SURFACES = ['background', 'surface', 'surfaceElevated'];
|
|
29
|
+
function renderedColor(value) {
|
|
30
|
+
const color = parseColor(value);
|
|
31
|
+
return color ? hexToOklch(oklchToHex(color)) : undefined;
|
|
32
|
+
}
|
|
33
|
+
function compositeSrgb(foreground, background, alpha) {
|
|
34
|
+
const foregroundHex = oklchToHex(parseColor(foreground));
|
|
35
|
+
const backgroundHex = oklchToHex(parseColor(background));
|
|
36
|
+
const channels = [1, 3, 5].map((offset) => {
|
|
37
|
+
const front = Number.parseInt(foregroundHex.slice(offset, offset + 2), 16);
|
|
38
|
+
const back = Number.parseInt(backgroundHex.slice(offset, offset + 2), 16);
|
|
39
|
+
return Math.round(front * alpha + back * (1 - alpha))
|
|
40
|
+
.toString(16)
|
|
41
|
+
.padStart(2, '0');
|
|
42
|
+
});
|
|
43
|
+
return hexToOklch(`#${channels.join('')}`);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The shared destructive solid fill and foreground as rendered by the UI.
|
|
47
|
+
*
|
|
48
|
+
* A filled destructive button uses `--destructive/90` on hover. A foreground that
|
|
49
|
+
* clears the original fill can fall below AA when that color is alpha-composited
|
|
50
|
+
* over a light or dark surface. This projection keeps the canonical error color
|
|
51
|
+
* untouched, adjusts only the presentation lightness along its hue, and tests the
|
|
52
|
+
* rounded sRGB output against the canvas and both card surfaces. The 5:1 internal
|
|
53
|
+
* margin protects the 4.5:1 AA floor from browser quantization.
|
|
54
|
+
*/
|
|
55
|
+
export function shadcnDestructiveProjection(theme) {
|
|
56
|
+
const sourceFill = parseColor(theme.colors.error);
|
|
57
|
+
const sourceForeground = parseColor(theme.colors.foreground);
|
|
58
|
+
const sourceBackground = parseColor(theme.colors.background);
|
|
59
|
+
if (!sourceFill || !sourceForeground || !sourceBackground) {
|
|
60
|
+
throw new Error(`theme ${theme.id} has an invalid destructive color pair`);
|
|
61
|
+
}
|
|
62
|
+
const preferredForeground = statusForeground(theme, 'error');
|
|
63
|
+
const alternateForeground = contrastRatio(sourceForeground, sourceFill) >= contrastRatio(sourceBackground, sourceFill)
|
|
64
|
+
? theme.colors.background
|
|
65
|
+
: theme.colors.foreground;
|
|
66
|
+
const foregrounds = [preferredForeground, alternateForeground]
|
|
67
|
+
.map((value) => ({ value, rendered: renderedColor(value) }))
|
|
68
|
+
.filter((entry) => Boolean(entry.rendered));
|
|
69
|
+
const surfaceValues = [
|
|
70
|
+
...DESTRUCTIVE_PRESENTATION_SURFACES.map((role) => theme.colors[role]),
|
|
71
|
+
theme.shadcn?.card ?? theme.colors.surface,
|
|
72
|
+
theme.shadcn?.popover ?? theme.colors.surfaceElevated,
|
|
73
|
+
];
|
|
74
|
+
const surfaces = surfaceValues
|
|
75
|
+
.map((value) => ({ value, rendered: renderedColor(value) }))
|
|
76
|
+
.filter((entry) => Boolean(entry.rendered));
|
|
77
|
+
if (surfaces.length !== surfaceValues.length) {
|
|
78
|
+
throw new Error(`theme ${theme.id} has an invalid destructive presentation surface`);
|
|
79
|
+
}
|
|
80
|
+
for (let step = 0; step <= 250; step += 1) {
|
|
81
|
+
const directions = step === 0 ? [0] : [-1, 1];
|
|
82
|
+
for (const direction of directions) {
|
|
83
|
+
const candidate = gamutMap({
|
|
84
|
+
...sourceFill,
|
|
85
|
+
l: sourceFill.l + direction * step * 0.001,
|
|
86
|
+
});
|
|
87
|
+
if (candidate.l < 0.02 || candidate.l > 0.98)
|
|
88
|
+
continue;
|
|
89
|
+
const fill = formatOklch(candidate);
|
|
90
|
+
const renderedFill = renderedColor(fill);
|
|
91
|
+
if (!renderedFill)
|
|
92
|
+
continue;
|
|
93
|
+
for (const foreground of foregrounds) {
|
|
94
|
+
const solidRatio = contrastRatio(foreground.rendered, renderedFill);
|
|
95
|
+
if (solidRatio < DESTRUCTIVE_PRESENTATION_FLOOR)
|
|
96
|
+
continue;
|
|
97
|
+
const clearsHoverFloor = surfaces.every(({ rendered }) => {
|
|
98
|
+
const composite = compositeSrgb(fill, formatOklch(rendered), DESTRUCTIVE_HOVER_OPACITY);
|
|
99
|
+
return (composite !== undefined &&
|
|
100
|
+
contrastRatio(foreground.rendered, composite) >= DESTRUCTIVE_PRESENTATION_FLOOR);
|
|
101
|
+
});
|
|
102
|
+
if (clearsHoverFloor)
|
|
103
|
+
return { fill, foreground: foreground.value };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
throw new Error(`theme ${theme.id} cannot meet the shared destructive presentation floor`);
|
|
108
|
+
}
|
|
25
109
|
/**
|
|
26
110
|
* Canonical role → shadcn custom-property name.
|
|
27
111
|
*
|
|
@@ -71,8 +155,9 @@ export function shadcnRoles(theme) {
|
|
|
71
155
|
*/
|
|
72
156
|
export function shadcnVariables(theme) {
|
|
73
157
|
const variables = {};
|
|
158
|
+
const destructive = shadcnDestructiveProjection(theme);
|
|
74
159
|
for (const [role, name] of Object.entries(SHADCN_MAPPING)) {
|
|
75
|
-
variables[`--${name}`] = theme.colors[role];
|
|
160
|
+
variables[`--${name}`] = role === 'error' ? destructive.fill : theme.colors[role];
|
|
76
161
|
}
|
|
77
162
|
variables['--accent'] = theme.colors.surfaceHover;
|
|
78
163
|
variables['--accent-foreground'] = theme.colors.text;
|
|
@@ -99,13 +184,15 @@ export function shadcnVariables(theme) {
|
|
|
99
184
|
variables['--sidebar-primary-foreground'] = theme.colors.accentForeground;
|
|
100
185
|
variables['--sidebar-ring'] = theme.colors.accent;
|
|
101
186
|
variables['--sidebar-muted-foreground'] = theme.colors.textMuted;
|
|
187
|
+
variables['--destructive-foreground'] = destructive.foreground;
|
|
102
188
|
for (const role of STATUS_ROLES) {
|
|
103
189
|
// Status labels on a subtle fill use the theme's body foreground; this
|
|
104
190
|
// foreground is reserved for text on the role's solid colour. Keep the
|
|
105
191
|
// generated shadcn names aligned with SHADCN_MAPPING, especially error →
|
|
106
192
|
// destructive, and resolve the tint against a real canvas so it is opaque.
|
|
107
193
|
const shadcnRole = SHADCN_MAPPING[role];
|
|
108
|
-
variables[`--${shadcnRole}-foreground`] =
|
|
194
|
+
variables[`--${shadcnRole}-foreground`] =
|
|
195
|
+
role === 'error' ? destructive.foreground : statusForeground(theme, role);
|
|
109
196
|
variables[`--${shadcnRole}-subtle`] = tint(theme.colors[role], theme.colors.background);
|
|
110
197
|
}
|
|
111
198
|
variables['--surface-sunken'] = theme.colors.background;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shadcn.js","sourceRoot":"","sources":["../../src/adapters/shadcn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"shadcn.js","sourceRoot":"","sources":["../../src/adapters/shadcn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnE,OAAO,EACL,aAAa,EACb,WAAW,EACX,QAAQ,EACR,UAAU,EACV,UAAU,EACV,UAAU,GACX,MAAM,aAAa,CAAA;AAapB,MAAM,8BAA8B,GAAG,CAAC,CAAA;AACxC,MAAM,yBAAyB,GAAG,GAAG,CAAA;AACrC,MAAM,iCAAiC,GAAG,CAAC,YAAY,EAAE,SAAS,EAAE,iBAAiB,CAAU,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C,CAAC;SAChD,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,IAAI,KAAK,KAAK,GAAG,CAAC;SAC9C,IAAI,CAAC,IAAI,CAAC,CAAA;IACb,OAAO,GAAG,QAAQ,OAAO,IAAI,KAAK,CAAA;AACpC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -65,5 +65,6 @@ export type { TailwindOptions } from './adapters/tailwind.js';
|
|
|
65
65
|
export { toTailwindTheme } from './adapters/tailwind.js';
|
|
66
66
|
export type { ShikiThemeRegistration, ShikiTokenSetting } from './adapters/shiki.js';
|
|
67
67
|
export { toShikiTheme, toShikiThemes } from './adapters/shiki.js';
|
|
68
|
-
export {
|
|
68
|
+
export type { ShadcnDestructiveProjection } from './adapters/shadcn.js';
|
|
69
|
+
export { SHADCN_MAPPING, shadcnCss, shadcnDestructiveProjection, shadcnRoles, shadcnVariables, } from './adapters/shadcn.js';
|
|
69
70
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAGH,YAAY,EACV,QAAQ,EACR,SAAS,EACT,eAAe,EACf,eAAe,EACf,OAAO,EACP,eAAe,EACf,aAAa,EACb,WAAW,EACX,aAAa,EACb,eAAe,EACf,qBAAqB,GACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEzD,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC7D,OAAO,EACL,OAAO,EACP,iBAAiB,EACjB,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,wBAAwB,EACxB,WAAW,EACX,WAAW,EACX,SAAS,EACT,Y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AAmB,CAAA;AAE9F,YAAY,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,YAAY,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACpF,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEjE,YAAY,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAA;AACvE,OAAO,EACL,cAAc,EACd,SAAS,EACT,2BAA2B,EAC3B,WAAW,EACX,eAAe,GAChB,MAAM,sBAAsB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -55,5 +55,5 @@ export { toXtermTheme } from './adapters/xterm.js';
|
|
|
55
55
|
export { catalogueCss, cssVariableName, themeCss, themeCssVariables } from './adapters/css.js';
|
|
56
56
|
export { toTailwindTheme } from './adapters/tailwind.js';
|
|
57
57
|
export { toShikiTheme, toShikiThemes } from './adapters/shiki.js';
|
|
58
|
-
export { SHADCN_MAPPING, shadcnCss, shadcnRoles, shadcnVariables } from './adapters/shadcn.js';
|
|
58
|
+
export { SHADCN_MAPPING, shadcnCss, shadcnDestructiveProjection, shadcnRoles, shadcnVariables, } from './adapters/shadcn.js';
|
|
59
59
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAgBH,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAGzD,OAAO,EACL,OAAO,EACP,iBAAiB,EACjB,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,wBAAwB,EACxB,WAAW,EACX,WAAW,EACX,SAAS,EACT,YAAY,EACZ,gBAAgB,GACjB,MAAM,cAAc,CAAA;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AAwB,CAAA;AAGxD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGjE,OAAO,EACL,cAAc,EACd,SAAS,EACT,2BAA2B,EAC3B,WAAW,EACX,eAAe,GAChB,MAAM,sBAAsB,CAAA"}
|
package/package.json
CHANGED
package/src/adapters/shadcn.ts
CHANGED
|
@@ -24,10 +24,121 @@
|
|
|
24
24
|
|
|
25
25
|
import type { AdeaTheme, AdeaThemeColors, ShadcnThemeProjection } from '../schema.js'
|
|
26
26
|
import { STATUS_ROLES, statusForeground, tint } from '../derive.js'
|
|
27
|
+
import {
|
|
28
|
+
contrastRatio,
|
|
29
|
+
formatOklch,
|
|
30
|
+
gamutMap,
|
|
31
|
+
hexToOklch,
|
|
32
|
+
oklchToHex,
|
|
33
|
+
parseColor,
|
|
34
|
+
} from '../oklch.js'
|
|
27
35
|
|
|
28
36
|
/** A canonical theme with optional owner-authored shadcn presentation values. */
|
|
29
37
|
export type ShadcnTheme = AdeaTheme & { shadcn?: ShadcnThemeProjection }
|
|
30
38
|
|
|
39
|
+
/** The solid destructive pair consumed by filled shadcn actions. */
|
|
40
|
+
export interface ShadcnDestructiveProjection {
|
|
41
|
+
/** Presentation fill derived from, but distinct from, the canonical error role. */
|
|
42
|
+
readonly fill: string
|
|
43
|
+
/** Text color that clears the solid and 90%-hover presentation floors. */
|
|
44
|
+
readonly foreground: string
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const DESTRUCTIVE_PRESENTATION_FLOOR = 5
|
|
48
|
+
const DESTRUCTIVE_HOVER_OPACITY = 0.9
|
|
49
|
+
const DESTRUCTIVE_PRESENTATION_SURFACES = ['background', 'surface', 'surfaceElevated'] as const
|
|
50
|
+
|
|
51
|
+
function renderedColor(value: string) {
|
|
52
|
+
const color = parseColor(value)
|
|
53
|
+
return color ? hexToOklch(oklchToHex(color)) : undefined
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function compositeSrgb(foreground: string, background: string, alpha: number) {
|
|
57
|
+
const foregroundHex = oklchToHex(parseColor(foreground)!)
|
|
58
|
+
const backgroundHex = oklchToHex(parseColor(background)!)
|
|
59
|
+
const channels = [1, 3, 5].map((offset) => {
|
|
60
|
+
const front = Number.parseInt(foregroundHex.slice(offset, offset + 2), 16)
|
|
61
|
+
const back = Number.parseInt(backgroundHex.slice(offset, offset + 2), 16)
|
|
62
|
+
return Math.round(front * alpha + back * (1 - alpha))
|
|
63
|
+
.toString(16)
|
|
64
|
+
.padStart(2, '0')
|
|
65
|
+
})
|
|
66
|
+
return hexToOklch(`#${channels.join('')}`)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The shared destructive solid fill and foreground as rendered by the UI.
|
|
71
|
+
*
|
|
72
|
+
* A filled destructive button uses `--destructive/90` on hover. A foreground that
|
|
73
|
+
* clears the original fill can fall below AA when that color is alpha-composited
|
|
74
|
+
* over a light or dark surface. This projection keeps the canonical error color
|
|
75
|
+
* untouched, adjusts only the presentation lightness along its hue, and tests the
|
|
76
|
+
* rounded sRGB output against the canvas and both card surfaces. The 5:1 internal
|
|
77
|
+
* margin protects the 4.5:1 AA floor from browser quantization.
|
|
78
|
+
*/
|
|
79
|
+
export function shadcnDestructiveProjection(theme: ShadcnTheme): ShadcnDestructiveProjection {
|
|
80
|
+
const sourceFill = parseColor(theme.colors.error)
|
|
81
|
+
const sourceForeground = parseColor(theme.colors.foreground)
|
|
82
|
+
const sourceBackground = parseColor(theme.colors.background)
|
|
83
|
+
if (!sourceFill || !sourceForeground || !sourceBackground) {
|
|
84
|
+
throw new Error(`theme ${theme.id} has an invalid destructive color pair`)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const preferredForeground = statusForeground(theme, 'error')
|
|
88
|
+
const alternateForeground =
|
|
89
|
+
contrastRatio(sourceForeground, sourceFill) >= contrastRatio(sourceBackground, sourceFill)
|
|
90
|
+
? theme.colors.background
|
|
91
|
+
: theme.colors.foreground
|
|
92
|
+
const foregrounds = [preferredForeground, alternateForeground]
|
|
93
|
+
.map((value) => ({ value, rendered: renderedColor(value) }))
|
|
94
|
+
.filter((entry): entry is { value: string; rendered: NonNullable<typeof entry.rendered> } =>
|
|
95
|
+
Boolean(entry.rendered)
|
|
96
|
+
)
|
|
97
|
+
const surfaceValues = [
|
|
98
|
+
...DESTRUCTIVE_PRESENTATION_SURFACES.map((role) => theme.colors[role]),
|
|
99
|
+
theme.shadcn?.card ?? theme.colors.surface,
|
|
100
|
+
theme.shadcn?.popover ?? theme.colors.surfaceElevated,
|
|
101
|
+
]
|
|
102
|
+
const surfaces = surfaceValues
|
|
103
|
+
.map((value) => ({ value, rendered: renderedColor(value) }))
|
|
104
|
+
.filter((entry): entry is { value: string; rendered: NonNullable<typeof entry.rendered> } =>
|
|
105
|
+
Boolean(entry.rendered)
|
|
106
|
+
)
|
|
107
|
+
if (surfaces.length !== surfaceValues.length) {
|
|
108
|
+
throw new Error(`theme ${theme.id} has an invalid destructive presentation surface`)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
for (let step = 0; step <= 250; step += 1) {
|
|
112
|
+
const directions = step === 0 ? [0] : [-1, 1]
|
|
113
|
+
for (const direction of directions) {
|
|
114
|
+
const candidate = gamutMap({
|
|
115
|
+
...sourceFill,
|
|
116
|
+
l: sourceFill.l + direction * step * 0.001,
|
|
117
|
+
})
|
|
118
|
+
if (candidate.l < 0.02 || candidate.l > 0.98) continue
|
|
119
|
+
const fill = formatOklch(candidate)
|
|
120
|
+
const renderedFill = renderedColor(fill)
|
|
121
|
+
if (!renderedFill) continue
|
|
122
|
+
|
|
123
|
+
for (const foreground of foregrounds) {
|
|
124
|
+
const solidRatio = contrastRatio(foreground.rendered, renderedFill)
|
|
125
|
+
if (solidRatio < DESTRUCTIVE_PRESENTATION_FLOOR) continue
|
|
126
|
+
|
|
127
|
+
const clearsHoverFloor = surfaces.every(({ rendered }) => {
|
|
128
|
+
const composite = compositeSrgb(fill, formatOklch(rendered), DESTRUCTIVE_HOVER_OPACITY)
|
|
129
|
+
return (
|
|
130
|
+
composite !== undefined &&
|
|
131
|
+
contrastRatio(foreground.rendered, composite) >= DESTRUCTIVE_PRESENTATION_FLOOR
|
|
132
|
+
)
|
|
133
|
+
})
|
|
134
|
+
if (clearsHoverFloor) return { fill, foreground: foreground.value }
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
throw new Error(`theme ${theme.id} cannot meet the shared destructive presentation floor`)
|
|
140
|
+
}
|
|
141
|
+
|
|
31
142
|
/**
|
|
32
143
|
* Canonical role → shadcn custom-property name.
|
|
33
144
|
*
|
|
@@ -81,9 +192,10 @@ export function shadcnRoles(theme: ShadcnTheme): Record<string, string> {
|
|
|
81
192
|
*/
|
|
82
193
|
export function shadcnVariables(theme: ShadcnTheme): Record<string, string> {
|
|
83
194
|
const variables: Record<string, string> = {}
|
|
195
|
+
const destructive = shadcnDestructiveProjection(theme)
|
|
84
196
|
|
|
85
197
|
for (const [role, name] of Object.entries(SHADCN_MAPPING) as [keyof AdeaThemeColors, string][]) {
|
|
86
|
-
variables[`--${name}`] = theme.colors[role]
|
|
198
|
+
variables[`--${name}`] = role === 'error' ? destructive.fill : theme.colors[role]
|
|
87
199
|
}
|
|
88
200
|
|
|
89
201
|
variables['--accent'] = theme.colors.surfaceHover
|
|
@@ -113,13 +225,16 @@ export function shadcnVariables(theme: ShadcnTheme): Record<string, string> {
|
|
|
113
225
|
variables['--sidebar-ring'] = theme.colors.accent
|
|
114
226
|
variables['--sidebar-muted-foreground'] = theme.colors.textMuted
|
|
115
227
|
|
|
228
|
+
variables['--destructive-foreground'] = destructive.foreground
|
|
229
|
+
|
|
116
230
|
for (const role of STATUS_ROLES) {
|
|
117
231
|
// Status labels on a subtle fill use the theme's body foreground; this
|
|
118
232
|
// foreground is reserved for text on the role's solid colour. Keep the
|
|
119
233
|
// generated shadcn names aligned with SHADCN_MAPPING, especially error →
|
|
120
234
|
// destructive, and resolve the tint against a real canvas so it is opaque.
|
|
121
235
|
const shadcnRole = SHADCN_MAPPING[role]
|
|
122
|
-
variables[`--${shadcnRole}-foreground`] =
|
|
236
|
+
variables[`--${shadcnRole}-foreground`] =
|
|
237
|
+
role === 'error' ? destructive.foreground : statusForeground(theme, role)
|
|
123
238
|
variables[`--${shadcnRole}-subtle`] = tint(theme.colors[role], theme.colors.background)
|
|
124
239
|
}
|
|
125
240
|
|
package/src/index.ts
CHANGED
|
@@ -161,4 +161,11 @@ export { toTailwindTheme } from './adapters/tailwind.js'
|
|
|
161
161
|
export type { ShikiThemeRegistration, ShikiTokenSetting } from './adapters/shiki.js'
|
|
162
162
|
export { toShikiTheme, toShikiThemes } from './adapters/shiki.js'
|
|
163
163
|
|
|
164
|
-
export {
|
|
164
|
+
export type { ShadcnDestructiveProjection } from './adapters/shadcn.js'
|
|
165
|
+
export {
|
|
166
|
+
SHADCN_MAPPING,
|
|
167
|
+
shadcnCss,
|
|
168
|
+
shadcnDestructiveProjection,
|
|
169
|
+
shadcnRoles,
|
|
170
|
+
shadcnVariables,
|
|
171
|
+
} from './adapters/shadcn.js'
|