Skip to content

Commit

Permalink
handle first load on dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler17 committed Oct 1, 2024
1 parent 9acc937 commit adc39ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion modules/app/components/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ const Header = (): JSX.Element => {
const { network } = useWeb3();
const { data: gas } = useGasPrice({ network });
const [mode, setMode] = useColorMode();
const [renderedMode, setRenderedMode] = useState('light');

const onToggleTheme = () => {
const next = mode === 'dark' ? 'light' : 'dark';
Expand All @@ -142,6 +143,10 @@ const Header = (): JSX.Element => {
setMode(next);
};

useEffect(() => {
setRenderedMode(mode);
}, [mode]);

return (
<Box
as="header"
Expand All @@ -164,7 +169,7 @@ const Header = (): JSX.Element => {
<InternalLink href={'/'} title="View homepage">
<IconButton aria-label="Sky home" sx={{ width: '70px', height: 4, p: 0 }}>
<Icon
name={mode === 'dark' ? 'sky_white' : 'sky'}
name={renderedMode === 'dark' ? 'sky_white' : 'sky'}
size="auto"
sx={{ width: '70px', cursor: 'pointer' }}
/>
Expand Down
2 changes: 1 addition & 1 deletion modules/home/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export default function Footer({ locale = 'en' }: { locale?: string }): React.Re
>
<ContactSection
heading="Official Community Channels"
icon={mode === 'dark' ? 'sky_white' : 'sky'}
icon={renderedMode === 'dark' ? 'sky_white' : 'sky'}
logos={logos.sky}
/>
<Flex
Expand Down

0 comments on commit adc39ff

Please sign in to comment.