Skyler Turner | 16c08d3 | 2021-11-04 20:06:50 +0000 | [diff] [blame] | 1 | /** @jsxImportSource theme-ui */ |
| 2 | import { useColorMode } from 'theme-ui'; |
pineafan | e0283a8 | 2022-02-13 10:05:56 +0000 | [diff] [blame] | 3 | import Styles from '../styles/Components/navbar.module.css'; |
pineafan | 7872745 | 2021-11-04 21:25:07 +0000 | [diff] [blame] | 4 | import { useState, useEffect } from 'react'; |
| 5 | |
Skyler Turner | 16c08d3 | 2021-11-04 20:06:50 +0000 | [diff] [blame] | 6 | |
| 7 | const ThemeChangeButton = () => { |
| 8 | const [colorMode, setColorMode] = useColorMode() |
pineafan | 7872745 | 2021-11-04 21:25:07 +0000 | [diff] [blame] | 9 | const [render, setRender] = useState(false); |
| 10 | |
| 11 | useEffect(() => { |
| 12 | setRender(true); |
| 13 | }); |
| 14 | |
Skyler Turner | 16c08d3 | 2021-11-04 20:06:50 +0000 | [diff] [blame] | 15 | return ( |
pineafan | ff3d452 | 2022-05-06 19:51:02 +0100 | [diff] [blame] | 16 | <> |
pineafan | 7872745 | 2021-11-04 21:25:07 +0000 | [diff] [blame] | 17 | <a className={Styles.icon + " " + Styles.ThemeChangeButton} onClick={(e) => { |
| 18 | e.preventDefault(); |
| 19 | setColorMode(colorMode === 'light' ? 'dark' : 'light'); |
pineafan | ff3d452 | 2022-05-06 19:51:02 +0100 | [diff] [blame] | 20 | }} href="#"> |
| 21 | <img className={Styles.icon} alt="Theme" src={"https://assets.clicks.codes/web/icons/" + ( |
pineafan | 9babd75 | 2022-10-21 21:47:52 +0100 | [diff] [blame] | 22 | colorMode === 'light' ? "light-white" : "dark" |
pineafan | ff3d452 | 2022-05-06 19:51:02 +0100 | [diff] [blame] | 23 | ) + ".svg"} /> |
pineafan | 7872745 | 2021-11-04 21:25:07 +0000 | [diff] [blame] | 24 | </a> |
pineafan | ff3d452 | 2022-05-06 19:51:02 +0100 | [diff] [blame] | 25 | </> |
Skyler Turner | 16c08d3 | 2021-11-04 20:06:50 +0000 | [diff] [blame] | 26 | ) |
| 27 | } |
| 28 | |
| 29 | export default ThemeChangeButton; |