blob: 0a2151b5e45eeaacc8b28b91d97cef576a67f491 [file] [log] [blame]
Skyler Turner16c08d32021-11-04 20:06:50 +00001/** @jsxImportSource theme-ui */
2import { useColorMode } from 'theme-ui';
pineafane0283a82022-02-13 10:05:56 +00003import Styles from '../styles/Components/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;