Files
Termix/src/ui/features/terminal/terminal-theme.ts
T

53 lines
1.8 KiB
TypeScript
Raw Normal View History

2026-06-04 15:16:53 -04:00
import { TERMINAL_THEMES } from "@/lib/terminal-themes.ts";
2026-06-29 13:28:26 -05:00
import type { TerminalConfig } from "@/types/index.ts";
2026-06-04 15:16:53 -04:00
// Background/foreground per UI theme for "Termix Default" - must match index.css
const TERMIX_DEFAULT_COLORS: Record<
string,
{ background: string; foreground: string }
> = {
dark: { background: "#0c0d0b", foreground: "#fafafa" },
light: { background: "#ffffff", foreground: "#111210" },
dracula: { background: "#282a36", foreground: "#f8f8f2" },
catppuccin: { background: "#1e1e2e", foreground: "#cdd6f4" },
nord: { background: "#2e3440", foreground: "#eceff4" },
solarized: { background: "#002b36", foreground: "#839496" },
"tokyo-night": { background: "#1a1b26", foreground: "#a9b1d6" },
"one-dark": { background: "#282c34", foreground: "#abb2bf" },
gruvbox: { background: "#282828", foreground: "#ebdbb2" },
};
export function resolveTermixThemeColors(
activeTheme: string,
appTheme: string,
2026-06-29 13:28:26 -05:00
customThemeColors?: TerminalConfig["customThemeColors"],
2026-06-04 15:16:53 -04:00
) {
2026-06-29 13:28:26 -05:00
if (activeTheme === "custom") {
if (customThemeColors) {
return customThemeColors;
}
return TERMINAL_THEMES.termixDark.colors;
}
2026-06-04 15:16:53 -04:00
if (activeTheme !== "termix") {
return (
TERMINAL_THEMES[activeTheme]?.colors || TERMINAL_THEMES.termixDark.colors
);
}
let resolvedUiTheme = appTheme;
if (appTheme === "system") {
resolvedUiTheme = window.matchMedia("(prefers-color-scheme: dark)").matches
? "dark"
: "light";
}
const uiColors =
TERMIX_DEFAULT_COLORS[resolvedUiTheme] ?? TERMIX_DEFAULT_COLORS.dark;
const base = TERMINAL_THEMES.termixDark.colors;
return {
...base,
background: uiColors.background,
foreground: uiColors.foreground,
cursor: uiColors.foreground,
cursorAccent: uiColors.background,
};
}