blob: 48b84eee526723d141fe989a79c58db2af7edf5e [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';
pineafanfd93e6e2022-05-06 20:30:09 +01005import Link from 'next/link'
pineafan78727452021-11-04 21:25:07 +00006
Skyler Turner16c08d32021-11-04 20:06:50 +00007
8const ThemeChangeButton = () => {
9 const [colorMode, setColorMode] = useColorMode()
pineafan78727452021-11-04 21:25:07 +000010 const [render, setRender] = useState(false);
11
12 useEffect(() => {
13 setRender(true);
14 });
15
Skyler Turner16c08d32021-11-04 20:06:50 +000016 return (
pineafanff3d4522022-05-06 19:51:02 +010017 <>
pineafanfd93e6e2022-05-06 20:30:09 +010018 <Link className={Styles.icon + " " + Styles.ThemeChangeButton} onClick={(e) => {
pineafan78727452021-11-04 21:25:07 +000019 e.preventDefault();
20 setColorMode(colorMode === 'light' ? 'dark' : 'light');
pineafanff3d4522022-05-06 19:51:02 +010021 }} href="#">
22 <img className={Styles.icon} alt="Theme" src={"https://assets.clicks.codes/web/icons/" + (
23 colorMode == 'light' ? "light-white" : "dark"
24 ) + ".svg"} />
pineafanfd93e6e2022-05-06 20:30:09 +010025 </Link>
pineafanff3d4522022-05-06 19:51:02 +010026 </>
Skyler Turner16c08d32021-11-04 20:06:50 +000027 )
28}
29
30export default ThemeChangeButton;