Add option to select system theme

This commit is contained in:
schroda
2024-09-04 23:46:04 +02:00
parent e909fc64fd
commit ba2ce37468
6 changed files with 83 additions and 24 deletions

View File

@@ -15,23 +15,27 @@ import {
responsiveFontSizes,
Theme,
} from '@mui/material/styles';
import { ThemeMode } from '@/components/context/ThemeModeContext.tsx';
import { MediaQuery } from '@/lib/ui/MediaQuery.tsx';
export const SCROLLBAR_WIDTH = 14;
let theme: Theme;
export const getCurrentTheme = () => theme;
export const createTheme = (
dark?: boolean,
themeMode: ThemeMode,
direction: Direction = 'ltr',
color: string = '#5b74ef',
pureBlackMode: boolean = false,
) => {
const isDarkMode = dark || pureBlackMode;
const systemMode = MediaQuery.getSystemThemeMode();
const mode = themeMode === ThemeMode.SYSTEM ? systemMode : themeMode;
const isDarkMode = mode === ThemeMode.DARK;
const baseTheme = createMuiTheme({
direction,
palette: {
mode: isDarkMode ? 'dark' : 'light',
mode,
primary: {
main: color,
},