feat(client): add shadcn theme
- Added Nix theme - Defaults to dark mode Signed-off-by: Noa Virellia <noa@requiem.garden>
This commit is contained in:
24
client/src/hooks/useTheme.ts
Normal file
24
client/src/hooks/useTheme.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { createContext, use } from 'react';
|
||||
|
||||
export type Theme = 'dark' | 'light' | 'system';
|
||||
|
||||
interface ThemeProviderState {
|
||||
theme: Theme;
|
||||
setTheme: (theme: Theme) => void;
|
||||
}
|
||||
|
||||
const initialState: ThemeProviderState = {
|
||||
theme: 'system',
|
||||
setTheme: () => null,
|
||||
};
|
||||
|
||||
export const ThemeProviderContext = createContext<ThemeProviderState>(initialState);
|
||||
|
||||
export function useTheme() {
|
||||
const context = use(ThemeProviderContext);
|
||||
|
||||
if (context === undefined)
|
||||
throw new Error('useTheme must be used within a ThemeProvider');
|
||||
|
||||
return context;
|
||||
}
|
||||
Reference in New Issue
Block a user