Skyler Turner | 16c08d3 | 2021-11-04 20:06:50 +0000 | [diff] [blame^] | 1 | /** @jsxImportSource theme-ui */ |
| 2 | import { useColorMode } from 'theme-ui'; |
| 3 | import Styles from '../styles/navbar.module.css' |
| 4 | |
| 5 | const ThemeChangeButton = () => { |
| 6 | const [colorMode, setColorMode] = useColorMode() |
| 7 | return ( |
| 8 | <header> |
| 9 | <a onClick={(e) => { |
| 10 | e.preventDefault(); |
| 11 | setColorMode(colorMode === 'light' ? 'dark' : 'light'); |
| 12 | }}> |
| 13 | <img |
| 14 | alt="Theme" |
| 15 | className={Styles.icon} |
| 16 | src={`/${colorMode}.svg`} |
| 17 | /></a> |
| 18 | </header> |
| 19 | ) |
| 20 | } |
| 21 | |
| 22 | export default ThemeChangeButton; |