Use same lock values as mobile clients
[ProtonMail-WebClient.git] / packages / shared / lib / helpers / initElectronClassnames.ts
blob5e54e1bc21ec8bff5c891380b1350b1a27bb1996
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) => {
7     const prefersDark =
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');
17     } else {
18         document.body.classList.remove('is-electron-dark');
19         document.body.classList.add('is-electron-light');
20     }
23 export const initElectronClassnames = () => {
24     if (isElectronApp) {
25         document.body.classList.add('is-electron');
27         if (hasInboxDesktopFeature('ThemeSelection') && canGetInboxDesktopInfo) {
28             updateElectronThemeModeClassnames(getInboxDesktopInfo('theme'));
29         } else {
30             updateElectronThemeModeClassnames(electronAppTheme);
31         }
32     }
34     if (isElectronOnMac) {
35         document.body.classList.add('is-electron-mac');
36     }
38     if (isElectronOnWindows) {
39         document.body.classList.add('is-electron-windows');
40     }