mirror of
https://github.com/davidkaya/aryx.git
synced 2026-08-27 13:23:57 +02:00
Use Bun-safe Electron and child_process import patterns for macOS GitHub Actions tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
42 lines
1.3 KiB
TypeScript
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);
|
|
}
|
|
}
|