File size: 798 Bytes
41a71fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { classNames } from '@/shared/lib/classNames/classNames';
import { Theme, useTheme } from '@/app/providers/ThemeProviders';
import Sun from '@/shared/assets/icons/sun.svg?react';
import Moon from '@/shared/assets/icons/moon.svg?react';
import { Button } from '@/shared/ui/Button';
import cls from './ThemeButton.module.scss';

interface ThemeButtonProps {
    className?: string;
}

export const ThemeButton = (props: ThemeButtonProps) => {
    const { className } = props;
    const { theme, toggleTheme } = useTheme();

    return (
        <Button
            className={classNames(cls.ThemeButton, {}, [className])}
            onClick={() => toggleTheme(theme === Theme.DARK ? Theme.LIGHT : Theme.DARK)}
            icon={theme === Theme.DARK ? <Sun /> : <Moon />}
        />
    );
};