histoire
Version:
A fast story book powered by Vite
12 lines (11 loc) • 864 B
JavaScript
import { getHistoireSemanticThemeOverrides } from '@histoire/protocol';
/** Workbench roots own semantic palette overrides; preview content stays independent. */
const root = ':is(.histoire-app.histoire-provider,.histoire-workbench,.histoire-root)';
/** Shared portable shade mapping prevents native/iframe providers from restoring legacy defaults. */
function declarations(theme, dark) {
return Object.entries(getHistoireSemanticThemeOverrides(theme?.colors, dark)).map(([name, value]) => `${name}: ${value};`).join('');
}
/** Emit only project overrides; authored tokens remain the default design authority. */
export function resolvedWorkbenchPalette(theme) {
return `${root}{${declarations(theme, false)}}:is(.htw-dark,[data-histoire-appearance="dark"]) ${root},${root}:is(.htw-dark,[data-histoire-appearance="dark"]){${declarations(theme, true)}}`;
}