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); |
pineafan | 802daca | 2022-10-24 21:57:29 +0100 | [diff] [blame] | 13 | }, []); |
pineafan | 7872745 | 2021-11-04 21:25:07 +0000 | [diff] [blame] | 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 | 7bd0ad6 | 2022-10-26 22:11:29 +0100 | [diff] [blame] | 17 | <a className={Styles.icon + " " + Styles.themeChangeIcon} onClick={(e) => { |
pineafan | 7872745 | 2021-11-04 21:25:07 +0000 | [diff] [blame] | 18 | e.preventDefault(); |
| 19 | setColorMode(colorMode === 'light' ? 'dark' : 'light'); |
pineafan | ff3d452 | 2022-05-06 19:51:02 +0100 | [diff] [blame] | 20 | }} href="#"> |
pineafan | b18f019 | 2022-10-27 22:08:36 +0100 | [diff] [blame^] | 21 | <img className={Styles.icon + " " + Styles.themeChangeIcon} alt="Theme" src={"https://assets.clicks.codes/web/icons/light.svg"} /> |
pineafan | 802daca | 2022-10-24 21:57:29 +0100 | [diff] [blame] | 22 | <img className={Styles.icon + " " + Styles.themeChangeIcon} alt="Theme" src={"https://assets.clicks.codes/web/icons/dark.svg"} /> |
pineafan | 7872745 | 2021-11-04 21:25:07 +0000 | [diff] [blame] | 23 | </a> |
pineafan | ff3d452 | 2022-05-06 19:51:02 +0100 | [diff] [blame] | 24 | </> |
Skyler Turner | 16c08d3 | 2021-11-04 20:06:50 +0000 | [diff] [blame] | 25 | ) |
| 26 | } |
| 27 | |
| 28 | export default ThemeChangeButton; |