feat: add semantic admin palette
This commit is contained in:
1 parent
d4bcf89449
commit
4ce35e91fb
4 files changed
+97
-2
No files matched your search
+19
-1
@@ -1,4 +1,4 @@
|
||||
import { derivePublicForegrounds, readableColor } from "@/lib/theme-contrast";
|
||||
import { deriveAdminPalette, derivePublicForegrounds, readableColor } from "@/lib/theme-contrast";
|
||||
import type { ThemePalette } from "@/lib/theme-presets";
|
||||
|
||||
const CSS_VARIABLES: Record<keyof ThemePalette, string> = {
|
||||
@@ -19,6 +19,7 @@ const CSS_VARIABLES: Record<keyof ThemePalette, string> = {
|
||||
|
||||
export function themePaletteCss(selector: string, palette: ThemePalette): string {
|
||||
const semantic = derivePublicForegrounds(palette);
|
||||
const admin = deriveAdminPalette(palette);
|
||||
const declarations = Object.entries(CSS_VARIABLES).map(
|
||||
([key, cssName]) => `--${cssName}:${palette[key as keyof ThemePalette]};`,
|
||||
);
|
||||
@@ -47,6 +48,23 @@ export function themePaletteCss(selector: string, palette: ThemePalette): string
|
||||
`--admin-sidebar-text-readable:${semantic.byName.sidebar};`,
|
||||
`--admin-sidebar-muted-readable:${semantic.byName.sidebar};`,
|
||||
`--admin-input-text-readable:${semantic.byName.input};`,
|
||||
`--admin-canvas:${admin.canvas};`,
|
||||
`--admin-surface:${admin.surface};`,
|
||||
`--admin-surface-elevated:${admin.surfaceElevated};`,
|
||||
`--admin-text:${admin.text};`,
|
||||
`--admin-text-muted:${admin.muted};`,
|
||||
`--admin-border:${admin.border};`,
|
||||
`--admin-accent:${admin.accent};`,
|
||||
`--admin-accent-text:${admin.accentText};`,
|
||||
`--admin-accent-foreground:${admin.accentForeground};`,
|
||||
`--admin-success:${admin.success};`,
|
||||
`--admin-warning:${admin.warning};`,
|
||||
`--admin-error:${admin.error};`,
|
||||
`--admin-info:${admin.info};`,
|
||||
`--admin-sidebar:${admin.sidebar};`,
|
||||
`--admin-sidebar-text:${admin.sidebarText};`,
|
||||
`--admin-overlay:${admin.overlay};`,
|
||||
`--admin-focus-ring:${admin.focusRing};`,
|
||||
...(["success", "warning", "error", "info"] as const).flatMap((status) => [
|
||||
`--color-${status}-text-readable:${semantic.byName[`${status}-text`]};`,
|
||||
`--color-${status}-foreground-readable:${semantic.byName[`${status}-solid`]};`,
|
||||
|
||||
Reference in new issue
Block a user