Skip to content

Commit

Permalink
fix prefers dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
siriwatknp committed Aug 5, 2021
1 parent 6da00f4 commit c45e9fe
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions docs/src/layouts/AppHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as React from 'react';
import NextLink from 'next/link';
import { styled, alpha } from '@material-ui/core/styles';
import useMediaQuery from '@material-ui/core/useMediaQuery';
import useScrollTrigger from '@material-ui/core/useScrollTrigger';
import NoSsr from '@material-ui/core/NoSsr';
import Box from '@material-ui/core/Box';
import Container from '@material-ui/core/Container';
Expand Down Expand Up @@ -31,7 +30,6 @@ const Header = styled('div', {
}));

export default function AppHeader() {
const trigger = useScrollTrigger();
const changeTheme = useChangeTheme();
const [mode, setMode] = React.useState(getCookie('paletteMode') || 'system');
const prefersDarkMode = useMediaQuery('(prefers-color-scheme: dark)');
Expand All @@ -55,7 +53,7 @@ export default function AppHeader() {
}
};
return (
<Header trigger={trigger}>
<Header trigger={false}>
<Container sx={{ display: 'flex', alignItems: 'center', minHeight: 64 }}>
<NextLink href="/branding/home" passHref>
<Box component="a" sx={{ lineHeight: 0, mr: 2 }}>
Expand All @@ -70,7 +68,10 @@ export default function AppHeader() {
<HeaderNavDropdown />
</Box>
<NoSsr>
<ThemeModeToggle checked={mode === 'dark'} onChange={handleChangeThemeMode} />
<ThemeModeToggle
checked={mode === 'system' ? prefersDarkMode : mode === 'dark'}
onChange={handleChangeThemeMode}
/>
</NoSsr>
</Container>
</Header>
Expand Down

0 comments on commit c45e9fe

Please sign in to comment.