Files
aryx/src/main/windows/titleBarTheme.ts
T
David KayaandCopilot d9f3f5302a fix: resolve macos bun interop
Use Bun-safe Electron and child_process import patterns for macOS GitHub Actions tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-26 00:30:41 +01:00

42 lines
1.3 KiB
TypeScript

import electron from 'electron';
import type { BrowserWindow } from 'electron';
import type { AppearanceTheme } from '@shared/domain/tooling';
const { nativeTheme } = electron;
interface TitleBarColors {
backgroundColor: string;
overlay: { color: string; symbolColor: string };
}
const darkColors: TitleBarColors = {
backgroundColor: '#09090b',
overlay: { color: '#09090b', symbolColor: '#a1a1aa' },
};
const lightColors: TitleBarColors = {
backgroundColor: '#ffffff',
overlay: { color: '#ffffff', symbolColor: '#52525b' },
};
function resolveEffectiveTheme(theme: AppearanceTheme): 'dark' | 'light' {
if (theme === 'light') return 'light';
if (theme === 'dark') return 'dark';
return nativeTheme.shouldUseDarkColors ? 'dark' : 'light';
}
function colorsForTheme(theme: AppearanceTheme): TitleBarColors {
return resolveEffectiveTheme(theme) === 'light' ? lightColors : darkColors;
}
export function applyTitleBarTheme(window: BrowserWindow, theme: AppearanceTheme): void {
const { backgroundColor, overlay } = colorsForTheme(theme);
window.setBackgroundColor(backgroundColor);
// setTitleBarOverlay is only available on Windows (and some Linux WMs).
if (typeof window.setTitleBarOverlay === 'function') {
window.setTitleBarOverlay(overlay);
}
}