blob: c8c6d8c06a4510c1313b4fd4c40d49a13b9e2938 [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 {
pineafan0a178732022-02-09 21:00:05 +000022 !render ? null : (colorMode == 'light' ? <img alt="Light" src="https://assets.clicksminuteper.net/web/icons/light.svg" /> : <img alt="Dark" 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;