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'; |
pineafan | fd93e6e | 2022-05-06 20:30:09 +0100 | [diff] [blame^] | 5 | import Link from 'next/link' |
pineafan | 7872745 | 2021-11-04 21:25:07 +0000 | [diff] [blame] | 6 | |
Skyler Turner | 16c08d3 | 2021-11-04 20:06:50 +0000 | [diff] [blame] | 7 | |
| 8 | const ThemeChangeButton = () => { |
| 9 | const [colorMode, setColorMode] = useColorMode() |
pineafan | 7872745 | 2021-11-04 21:25:07 +0000 | [diff] [blame] | 10 | const [render, setRender] = useState(false); |
| 11 | |
| 12 | useEffect(() => { |
| 13 | setRender(true); |
| 14 | }); |
| 15 | |
Skyler Turner | 16c08d3 | 2021-11-04 20:06:50 +0000 | [diff] [blame] | 16 | return ( |
pineafan | ff3d452 | 2022-05-06 19:51:02 +0100 | [diff] [blame] | 17 | <> |
pineafan | fd93e6e | 2022-05-06 20:30:09 +0100 | [diff] [blame^] | 18 | <Link className={Styles.icon + " " + Styles.ThemeChangeButton} onClick={(e) => { |
pineafan | 7872745 | 2021-11-04 21:25:07 +0000 | [diff] [blame] | 19 | e.preventDefault(); |
| 20 | setColorMode(colorMode === 'light' ? 'dark' : 'light'); |
pineafan | ff3d452 | 2022-05-06 19:51:02 +0100 | [diff] [blame] | 21 | }} href="#"> |
| 22 | <img className={Styles.icon} alt="Theme" src={"https://assets.clicks.codes/web/icons/" + ( |
| 23 | colorMode == 'light' ? "light-white" : "dark" |
| 24 | ) + ".svg"} /> |
pineafan | fd93e6e | 2022-05-06 20:30:09 +0100 | [diff] [blame^] | 25 | </Link> |
pineafan | ff3d452 | 2022-05-06 19:51:02 +0100 | [diff] [blame] | 26 | </> |
Skyler Turner | 16c08d3 | 2021-11-04 20:06:50 +0000 | [diff] [blame] | 27 | ) |
| 28 | } |
| 29 | |
| 30 | export default ThemeChangeButton; |