mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-06-26 18:26:38 +00:00
- Move stores/utils/types to their relative directories (i.e chat stores in chat directory) - Move utility files to shared/utils - Move component files to shared/components - Move type definitions to shared/types - Move stores to shared/stores - Update import paths across the project
30 lines
742 B
TypeScript
30 lines
742 B
TypeScript
import { useStore } from '@nanostores/react';
|
|
import { memo, useEffect, useState } from 'react';
|
|
import { themeStore, toggleTheme } from '~/shared/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}
|
|
/>
|
|
)
|
|
);
|
|
});
|