blob: baf55f0146afe1b3929367c032501e8adaf1f650 [file] [log] [blame]
Skyler Turner16c08d32021-11-04 20:06:50 +00001/** @jsxImportSource theme-ui */
2import { useColorMode } from 'theme-ui';
pineafan78727452021-11-04 21:25:07 +00003import Styles from '../styles/navbar.module.css';
pineafan78727452021-11-04 21:25:07 +00004import { useState, useEffect } from 'react';
5
Skyler Turner16c08d32021-11-04 20:06:50 +00006
7const ThemeChangeButton = () => {
8 const [colorMode, setColorMode] = useColorMode()
pineafan78727452021-11-04 21:25:07 +00009 const [render, setRender] = useState(false);
10
11 useEffect(() => {
12 setRender(true);
13 });
14
Skyler Turner16c08d32021-11-04 20:06:50 +000015 return (
16 <header>
pineafan78727452021-11-04 21:25:07 +000017 <a className={Styles.icon + " " + Styles.ThemeChangeButton} onClick={(e) => {
18 e.preventDefault();
19 setColorMode(colorMode === 'light' ? 'dark' : 'light');
20 }}>
21 {
pineafana841c762021-11-14 21:21:04 +000022 !render ? null : (colorMode == 'light' ? <img src="https://assets.clicksminuteper.net/web/icons/light.svg" /> : <img src="https://assets.clicksminuteper.net/web/icons/dark.svg" />)
pineafan78727452021-11-04 21:25:07 +000023 }
24 </a>
Skyler Turner16c08d32021-11-04 20:06:50 +000025 </header>
26 )
27}
28
29export default ThemeChangeButton;