1 import { canGetInboxDesktopInfo, getInboxDesktopInfo, hasInboxDesktopFeature } from '../desktop/ipcHelpers';
2 import type { ThemeSetting } from '../themes/themes';
3 import { ThemeModeSetting, electronAppTheme, getDarkThemes } from '../themes/themes';
4 import { isElectronApp, isElectronOnMac, isElectronOnWindows } from './desktop';
6 export const updateElectronThemeModeClassnames = (theme: ThemeSetting) => {
8 theme.Mode === ThemeModeSetting.Dark ||
9 (theme.Mode === ThemeModeSetting.Auto && window.matchMedia('(prefers-color-scheme: dark)').matches);
11 const selectedTheme = prefersDark ? theme.DarkTheme : theme.LightTheme;
12 const isUsingDarkTheme = getDarkThemes().includes(selectedTheme);
14 if (isUsingDarkTheme) {
15 document.body.classList.add('is-electron-dark');
16 document.body.classList.remove('is-electron-light');
18 document.body.classList.remove('is-electron-dark');
19 document.body.classList.add('is-electron-light');
23 export const initElectronClassnames = () => {
25 document.body.classList.add('is-electron');
27 if (hasInboxDesktopFeature('ThemeSelection') && canGetInboxDesktopInfo) {
28 updateElectronThemeModeClassnames(getInboxDesktopInfo('theme'));
30 updateElectronThemeModeClassnames(electronAppTheme);
34 if (isElectronOnMac) {
35 document.body.classList.add('is-electron-mac');
38 if (isElectronOnWindows) {
39 document.body.classList.add('is-electron-windows');