fix: enforce public contrast and audit rank errors

This commit is contained in:
Simo committed 2026-07-11 22:06:45 +02:00
1 parent e1381c0f40
commit b695a33ead
12 files changed
+184 -29

No files matched your search

+19 -1
View File
@@ -1,6 +1,6 @@
import { siteSettings } from "@/lib/services/site-settings";
import { FONTS } from "@/lib/theme-presets";
import { readableColor } from "@/lib/theme-contrast";
import { derivePublicForegrounds, readableColor } from "@/lib/theme-contrast";
// Injects the DB-driven CSS custom properties into :root, exactly like
// AtomCMS's app.blade.php. Falls back to the atom defaults when no DB. Covers
@@ -109,6 +109,18 @@ export async function ThemeVars() {
[safe(primary, "#f59e0b")],
);
const readableAccentForeground = readableColor("#ffffff", [safe(accent, "#10b981")]);
const semantic = derivePublicForegrounds({
color_background: safeBackground, color_surface: safeSurface,
color_dropdown: safe(dropdown, "#ffffff"), color_navbar: safe(navbar, "#ffffff"),
color_navbar_text: safe(navbarText, "#1e293b"), color_text: safe(text, "#0f172a"),
color_text_muted: safe(textMuted, "#64748b"), color_primary: safe(primary, "#f59e0b"),
color_accent: safe(accent, "#10b981"), button_primary_color: safe(buttonColor, "#f59e0b"),
button_text_color: safe(buttonText, "#1e293b"), button_secondary_color: safe(buttonSecondary, "#22c55e"),
button_secondary_text_color: safe(buttonSecondaryText, "#ffffff"), button_danger_color: safe(buttonDanger, "#ef4444"),
button_danger_text_color: safe(buttonDangerText, "#ffffff"), button_outline_color: safe(buttonOutline, "#eeb425"),
button_outline_text_color: safe(buttonOutlineText, "#1a1a2e"), link_color: safe(linkColor, "#eeb425"),
link_hover_color: safe(linkHover, "#cf9d15"),
});
const font = FONTS[fontKey ?? "nunito"] ?? FONTS.nunito;
@@ -151,6 +163,12 @@ export async function ThemeVars() {
--button-danger-text-color-readable:${readableDangerText};
--link-color-readable:${readableLink};
--link-hover-color-readable:${readableLinkHover};
--color-surface-text-readable:${semantic.byName.surface};
--color-dropdown-text-readable:${semantic.byName.dropdown};
--button-outline-text-color-readable:${semantic.byName["button-outline"]};
--color-pill-text-readable:${semantic.byName.pill};
--color-badge-text-readable:${semantic.byName.badge};
--color-overlay-text-readable:${semantic.byName.overlay};
--border-radius:${px(borderRadius, "12")}px;
--font-family:${font.stack};
--size-heading-h1:${px(h1, "30")}px;