swordev/suid

Automatic dark theme is not working

Azq2 opened this issue · 2 comments

Azq2 commented
function App() {
	let drawerWidth = 240;

	let prefersDarkMode = useMediaQuery('(prefers-color-scheme: dark)');
	let theme = createMemo(() => {
		console.log('prefersDarkMode=', prefersDarkMode());
		return createTheme({
			palette: {
				mode: prefersDarkMode() ? 'dark' : 'light',
				primary: {
					main: prefersDarkMode() ? '#b39ddb' : '#673ab7',
				},
				secondary: {
					main: prefersDarkMode() ? '#673ab7' : '#651fff',
				},
			},
			typography: {
				fontFamily: [
					'-apple-system',
					'BlinkMacSystemFont',
					'"Segoe UI"',
					'Roboto',
					'"Helvetica Neue"',
					'Arial',
					'sans-serif',
					'"Apple Color Emoji"',
					'"Segoe UI Emoji"',
					'"Segoe UI Symbol"',
				].join(','),
			}
		});
	});

	return (
		<SerialProvider>
			<ThemeProvider theme={theme()}>
				....
			</ThemeProvider>
		</SerialProvider>
	);
}

I see console.log('prefersDarkMode=', prefersDarkMode()); on the console, but the theme is not changed.