mirror of
https://github.com/harivansh-afk/asap.it.git
synced 2026-04-17 12:04:11 +00:00
first commit
This commit is contained in:
commit
1cdbffff09
200 changed files with 30007 additions and 0 deletions
29
app/components/ui/ThemeSwitch.tsx
Normal file
29
app/components/ui/ThemeSwitch.tsx
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import { useStore } from '@nanostores/react';
|
||||
import { memo, useEffect, useState } from 'react';
|
||||
import { themeStore, toggleTheme } from '~/lib/stores/theme';
|
||||
import { IconButton } from './IconButton';
|
||||
|
||||
interface ThemeSwitchProps {
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export const ThemeSwitch = memo(({ className }: ThemeSwitchProps) => {
|
||||
const theme = useStore(themeStore);
|
||||
const [domLoaded, setDomLoaded] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setDomLoaded(true);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
domLoaded && (
|
||||
<IconButton
|
||||
className={className}
|
||||
icon={theme === 'dark' ? 'i-ph-sun-dim-duotone' : 'i-ph-moon-stars-duotone'}
|
||||
size="xl"
|
||||
title="Toggle Theme"
|
||||
onClick={toggleTheme}
|
||||
/>
|
||||
)
|
||||
);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue