Dynamic Theme Update
This commit is contained in:
@@ -48,9 +48,31 @@ const themes: Record<ColorTheme, ThemeJson> = {
|
||||
// Export themes for external access
|
||||
export { themes };
|
||||
|
||||
// Build theme colors from JSON
|
||||
// CSS variable mappings for theme colors - these update dynamically with mode changes
|
||||
const themeColorVars: Record<string, string> = {
|
||||
'primary': 'var(--terminal-primary)',
|
||||
'secondary': 'var(--terminal-secondary)',
|
||||
'accent': 'var(--terminal-accent)',
|
||||
'background': 'var(--terminal-bg)',
|
||||
'backgroundLight': 'var(--terminal-bg-light)',
|
||||
'text': 'var(--terminal-text)',
|
||||
'textMuted': 'var(--terminal-muted)',
|
||||
'border': 'var(--terminal-border)',
|
||||
'terminal': 'var(--terminal-bg)',
|
||||
'terminalPrompt': 'var(--terminal-prompt)',
|
||||
'terminalUser': 'var(--terminal-user)',
|
||||
'terminalPath': 'var(--terminal-path)',
|
||||
};
|
||||
|
||||
// Build theme colors from JSON - merges colors into colorMap so formatter can use both
|
||||
function buildThemeColors(theme: ThemeJson, mode: Mode): ThemeColors {
|
||||
const modeData = theme[mode];
|
||||
// Merge colors and colorMap - use CSS variables for theme colors so they update dynamically
|
||||
const mergedColorMap: ThemeColorMap = {
|
||||
...defaultColorMap, // Fallback defaults
|
||||
...(modeData.colorMap ?? {}), // Theme's color palette
|
||||
...themeColorVars // Theme colors as CSS variables - update with mode changes
|
||||
};
|
||||
return {
|
||||
primary: modeData.colors.primary,
|
||||
secondary: modeData.colors.secondary,
|
||||
@@ -64,7 +86,7 @@ function buildThemeColors(theme: ThemeJson, mode: Mode): ThemeColors {
|
||||
terminalPrompt: modeData.colors.terminalPrompt,
|
||||
terminalUser: modeData.colors.terminalUser,
|
||||
terminalPath: modeData.colors.terminalPath,
|
||||
colorMap: modeData.colorMap ?? defaultColorMap
|
||||
colorMap: mergedColorMap
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user