mirror of
https://github.com/antebudimir/feishin.git
synced 2025-12-31 10:03:33 +00:00
28 lines
887 B
TypeScript
28 lines
887 B
TypeScript
|
|
import { useIsDark, useToggleDark } from '/@/remote/store';
|
||
|
|
import { RiMoonLine, RiSunLine } from 'react-icons/ri';
|
||
|
|
import { RemoteButton } from '/@/remote/components/buttons/remote-button';
|
||
|
|
import { AppTheme } from '/@/renderer/themes/types';
|
||
|
|
import { useEffect } from 'react';
|
||
|
|
|
||
|
|
export const ThemeButton = () => {
|
||
|
|
const isDark = useIsDark();
|
||
|
|
const toggleDark = useToggleDark();
|
||
|
|
|
||
|
|
useEffect(() => {
|
||
|
|
const targetTheme: AppTheme = isDark ? AppTheme.DEFAULT_DARK : AppTheme.DEFAULT_LIGHT;
|
||
|
|
document.body.setAttribute('data-theme', targetTheme);
|
||
|
|
}, [isDark]);
|
||
|
|
|
||
|
|
return (
|
||
|
|
<RemoteButton
|
||
|
|
mr={5}
|
||
|
|
size="xl"
|
||
|
|
tooltip="Toggle Theme"
|
||
|
|
variant="default"
|
||
|
|
onClick={() => toggleDark()}
|
||
|
|
>
|
||
|
|
{isDark ? <RiSunLine size={30} /> : <RiMoonLine size={30} />}
|
||
|
|
</RemoteButton>
|
||
|
|
);
|
||
|
|
};
|