2024-11-13 08:33:48 +01:00
|
|
|
import type { JSX } from 'react'
|
2024-07-27 11:33:34 +02:00
|
|
|
import {
|
|
|
|
|
ActionIcon,
|
|
|
|
|
useMantineColorScheme,
|
|
|
|
|
useComputedColorScheme,
|
|
|
|
|
} from '@mantine/core'
|
|
|
|
|
import { IconSun, IconMoon } from '@tabler/icons-react'
|
|
|
|
|
import cx from 'clsx'
|
|
|
|
|
|
|
|
|
|
import classes from './theme-btn.module.css'
|
|
|
|
|
|
|
|
|
|
export default function ThemeBtn(): JSX.Element {
|
|
|
|
|
const { setColorScheme } = useMantineColorScheme()
|
|
|
|
|
const computedColorScheme = useComputedColorScheme('light', {
|
|
|
|
|
getInitialValueInEffect: true,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<ActionIcon
|
2024-12-22 12:08:21 +01:00
|
|
|
onClick={() => {
|
2024-07-27 11:33:34 +02:00
|
|
|
setColorScheme(computedColorScheme === 'light' ? 'dark' : 'light')
|
2024-12-22 12:08:21 +01:00
|
|
|
}}
|
2024-07-27 11:33:34 +02:00
|
|
|
variant="default"
|
|
|
|
|
size="lg"
|
|
|
|
|
aria-label="Toggle color scheme"
|
|
|
|
|
>
|
|
|
|
|
<IconSun className={cx(classes.icon, classes.light)} stroke={1.5} />
|
|
|
|
|
<IconMoon className={cx(classes.icon, classes.dark)} stroke={1.5} />
|
|
|
|
|
</ActionIcon>
|
|
|
|
|
)
|
|
|
|
|
}
|