1 import { canGetInboxDesktopInfo, getInboxDesktopInfo, hasInboxDesktopFeature } from '../desktop/ipcHelpers';
2 import type { ThemeSetting } from '../themes/themes';
3 import { ColorScheme, ThemeModeSetting, electronAppTheme, getDarkThemes } from '../themes/themes';
4 import { isElectronApp, isElectronOnMac, isElectronOnWindows } from './desktop';
6 export const updateElectronThemeModeClassnames = (theme: ThemeSetting) => {
7 let prefersDark = false;
9 if (theme.Mode === ThemeModeSetting.Dark) {
11 } else if (theme.Mode === ThemeModeSetting.Auto) {
12 if (canGetInboxDesktopInfo && hasInboxDesktopFeature('FullTheme')) {
13 prefersDark = getInboxDesktopInfo('colorScheme') === ColorScheme.Dark;
15 prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
19 const selectedTheme = prefersDark ? theme.DarkTheme : theme.LightTheme;
20 const isUsingDarkTheme = getDarkThemes().includes(selectedTheme);
22 if (isUsingDarkTheme) {
23 document.body.classList.add('is-electron-dark');
24 document.body.classList.remove('is-electron-light');
26 document.body.classList.remove('is-electron-dark');
27 document.body.classList.add('is-electron-light');
31 export const initElectronClassnames = () => {
33 document.body.classList.add('is-electron');
35 if (hasInboxDesktopFeature('ThemeSelection') && canGetInboxDesktopInfo) {
36 updateElectronThemeModeClassnames(getInboxDesktopInfo('theme'));
38 updateElectronThemeModeClassnames(electronAppTheme);
42 if (isElectronOnMac) {
43 document.body.classList.add('is-electron-mac');
46 if (isElectronOnWindows) {
47 document.body.classList.add('is-electron-windows');