blob: 86b112b66b219d631d0dd0a967eb85a8a445a5e0 [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="#">
pineafan802daca2022-10-24 21:57:29 +010021 <img className={Styles.icon + " " + Styles.themeChangeIcon} alt="Theme" src={"https://assets.clicks.codes/web/icons/light-white.svg"} />
22 <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;