fix(dashboard): sidebar active-item text unreadable in light mode with custom accent

applyAccentColor() forced --sidebar-accent-foreground to the raw accent
color regardless of theme. Works in dark mode (bright text on dark-tinted
bg) but in light mode the tinted bg is near-white, so full-saturation
yellow text on pale-yellow bg was nearly invisible. Now only overrides
the foreground in dark mode; light mode keeps the theme's default
high-contrast foreground token.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-07 08:58:32 +02:00
parent e07af71f9e
commit b03441da59
+16 -8
View File
@@ -20,17 +20,25 @@ interface AuthState {
function applyAccentColor(color: string | null | undefined) {
if (typeof document === 'undefined') return;
const root = document.documentElement;
if (color) {
document.documentElement.style.setProperty('--primary', color);
document.documentElement.style.setProperty('--ring', color);
root.style.setProperty('--primary', color);
root.style.setProperty('--ring', color);
// Sidebar active state: accent color with 15% opacity (#rrggbbaa, 0x26 ≈ 15%)
document.documentElement.style.setProperty('--sidebar-accent', `${color}26`);
document.documentElement.style.setProperty('--sidebar-accent-foreground', color);
root.style.setProperty('--sidebar-accent', `${color}26`);
// Full-saturation accent text only reads well against the dark-mode sidebar's
// tinted-dark background; in light mode it's near-white behind it, so keep
// the theme's default (dark, high-contrast) foreground there instead.
if (root.classList.contains('dark')) {
root.style.setProperty('--sidebar-accent-foreground', color);
} else {
root.style.removeProperty('--sidebar-accent-foreground');
}
} else {
document.documentElement.style.removeProperty('--primary');
document.documentElement.style.removeProperty('--ring');
document.documentElement.style.removeProperty('--sidebar-accent');
document.documentElement.style.removeProperty('--sidebar-accent-foreground');
root.style.removeProperty('--primary');
root.style.removeProperty('--ring');
root.style.removeProperty('--sidebar-accent');
root.style.removeProperty('--sidebar-accent-foreground');
}
}