blob: 2e0b7b7542113456062725c1d8c9ba068ab0888a [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);
pineafan802daca2022-10-24 21:57:29 +010013 }, []);
pineafan78727452021-11-04 21:25:07 +000014
Skyler Turner16c08d32021-11-04 20:06:50 +000015 return (
pineafanff3d4522022-05-06 19:51:02 +010016 <>
pineafan7bd0ad62022-10-26 22:11:29 +010017 <a className={Styles.icon + " " + Styles.themeChangeIcon} onClick={(e) => {
pineafan78727452021-11-04 21:25:07 +000018 e.preventDefault();
19 setColorMode(colorMode === 'light' ? 'dark' : 'light');
pineafanff3d4522022-05-06 19:51:02 +010020 }} href="#">
pineafanb18f0192022-10-27 22:08:36 +010021 <img className={Styles.icon + " " + Styles.themeChangeIcon} alt="Theme" src={"https://assets.clicks.codes/web/icons/light.svg"} />
pineafan802daca2022-10-24 21:57:29 +010022 <img className={Styles.icon + " " + Styles.themeChangeIcon} alt="Theme" src={"https://assets.clicks.codes/web/icons/dark.svg"} />
pineafan78727452021-11-04 21:25:07 +000023 </a>
pineafanff3d4522022-05-06 19:51:02 +010024 </>
Skyler Turner16c08d32021-11-04 20:06:50 +000025 )
26}
27
28export default ThemeChangeButton;