blob: 616c14ae5dd0f1a9d9cc6ed59b6165f18c31fafb [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 (
pineafanff3d4522022-05-06 19:51:02 +010016 <>
pineafan78727452021-11-04 21:25:07 +000017 <a className={Styles.icon + " " + Styles.ThemeChangeButton} onClick={(e) => {
18 e.preventDefault();
19 setColorMode(colorMode === 'light' ? 'dark' : 'light');
pineafanff3d4522022-05-06 19:51:02 +010020 }} href="#">
21 <img className={Styles.icon} alt="Theme" src={"https://assets.clicks.codes/web/icons/" + (
22 colorMode == 'light' ? "light-white" : "dark"
23 ) + ".svg"} />
pineafan78727452021-11-04 21:25:07 +000024 </a>
pineafanff3d4522022-05-06 19:51:02 +010025 </>
Skyler Turner16c08d32021-11-04 20:06:50 +000026 )
27}
28
29export default ThemeChangeButton;