2022-03-23 21:21:46 -04:00
|
|
|
import React, { useEffect, useState } from 'react'
|
2022-03-07 19:54:33 -05:00
|
|
|
import MoonIcon from '@geist-ui/icons/moon'
|
|
|
|
import SunIcon from '@geist-ui/icons/sun'
|
|
|
|
// import { useAllThemes, useTheme } from '@geist-ui/core'
|
|
|
|
import styles from './header.module.css'
|
2022-03-22 23:06:15 -04:00
|
|
|
import { Select } from '@geist-ui/core'
|
2022-03-23 21:21:46 -04:00
|
|
|
import { useTheme } from 'next-themes'
|
2022-03-07 19:54:33 -05:00
|
|
|
|
2022-03-23 21:21:46 -04:00
|
|
|
const Controls = () => {
|
|
|
|
const [mounted, setMounted] = useState(false)
|
|
|
|
const { theme, setTheme } = useTheme()
|
|
|
|
useEffect(() => setMounted(true), [])
|
|
|
|
if (!mounted) return null
|
2022-03-22 23:06:15 -04:00
|
|
|
const switchThemes = () => {
|
2022-03-23 21:21:46 -04:00
|
|
|
if (theme === 'dark') {
|
|
|
|
setTheme('light')
|
|
|
|
} else {
|
|
|
|
setTheme('dark')
|
|
|
|
}
|
2022-03-07 19:54:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={styles.wrapper}>
|
|
|
|
<Select
|
|
|
|
scale={0.5}
|
|
|
|
h="28px"
|
|
|
|
pure
|
|
|
|
onChange={switchThemes}
|
|
|
|
value={theme}
|
|
|
|
>
|
|
|
|
<Select.Option value="light">
|
|
|
|
<span className={styles.selectContent}>
|
|
|
|
<SunIcon size={14} /> Light
|
|
|
|
</span>
|
|
|
|
</Select.Option>
|
|
|
|
<Select.Option value="dark">
|
|
|
|
<span className={styles.selectContent}>
|
|
|
|
<MoonIcon size={14} /> Dark
|
|
|
|
</span>
|
|
|
|
</Select.Option>
|
|
|
|
</Select>
|
|
|
|
</div >
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default React.memo(Controls);
|