aboutsummaryrefslogtreecommitdiff
path: root/src/hooks
diff options
context:
space:
mode:
Diffstat (limited to 'src/hooks')
-rw-r--r--src/hooks/theme.tsx33
1 files changed, 0 insertions, 33 deletions
diff --git a/src/hooks/theme.tsx b/src/hooks/theme.tsx
deleted file mode 100644
index d65b18c..0000000
--- a/src/hooks/theme.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-// hooks/theme.ts
-import { useState, useEffect, useCallback } from 'react';
-
-type Theme = 'light' | 'dark';
-
-const STORAGE_KEY = 'theme';
-
-export function useTheme() {
- const [theme, setTheme] = useState<Theme>(() => {
- const stored = typeof window !== 'undefined' ? localStorage.getItem(STORAGE_KEY) : null;
- if (stored === 'light' || stored === 'dark') {
- return stored;
- }
-
- if (typeof window !== 'undefined' && window.matchMedia('(prefers-color-scheme: dark)').matches) {
- return 'dark';
- }
- return 'light';
- });
-
- useEffect(() => {
- const root = document.documentElement;
- root.setAttribute('data-theme', theme);
- root.classList.toggle('dark', theme === 'dark');
- localStorage.setItem(STORAGE_KEY, theme);
- }, [theme]);
-
- const toggleTheme = useCallback(() => {
- setTheme(prev => (prev === 'dark' ? 'light' : 'dark'));
- }, []);
-
- return { theme, toggleTheme };
-}