22. Nutmeg is a hallucinogen.

This commit is contained in:
2023-09-28 21:34:59 +02:00
parent bc51a5cfa9
commit 6fa0520c7b
8 changed files with 64 additions and 64 deletions
+14 -15
View File
@@ -1,30 +1,29 @@
import { BsSunFill, BsMoonFill } from 'react-icons/bs'
import { useEffect, useState } from 'react'
import { useTheme } from 'next-themes'
import { VscColorMode } from 'react-icons/vsc'
import { Button } from '@nextui-org/button'
import { useTheme } from 'next-themes'
export const ThemeSwitcher = () => {
const [mounted, setMounted] = useState(false)
const { theme, setTheme } = useTheme()
const toggle = () => {
if (theme === 'dark') {
setTheme('light')
} else {
setTheme('dark')
switch (theme) {
case 'dark':
setTheme('light')
break
case 'light':
setTheme('dark')
break
default:
break
}
}
useEffect(() => setMounted(true), [])
if (!mounted) return null
return (
<Button aria-label="Switch Theme" size="sm" onClick={() => toggle()}>
<Button aria-label='Switch Theme' size='sm' onClick={() => toggle()}>
{theme === 'light' ? (
<BsMoonFill style={{ fill: 'black' }} size={20} />
<VscColorMode style={{ fill: 'black' }} size={20} />
) : (
<BsSunFill size={20} />
<VscColorMode size={20} key={'dark'} />
)}
</Button>
)