From 6994f509a59dc0d102dc77d28b104b281b1f8ed5 Mon Sep 17 00:00:00 2001 From: arsam Date: Fri, 18 Sep 2026 23:17:42 +0330 Subject: [PATCH] Import source: src/context/ThemeContext Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality. --- src/context/ThemeContext.tsx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/context/ThemeContext.tsx diff --git a/src/context/ThemeContext.tsx b/src/context/ThemeContext.tsx new file mode 100644 index 0000000..fd57931 --- /dev/null +++ b/src/context/ThemeContext.tsx @@ -0,0 +1,21 @@ +import { createContext, useContext, useState, useEffect, type ReactNode } from 'react'; + +interface ThemeCtx { isDark: boolean; toggle: () => void; } + +const ThemeContext = createContext({ isDark: true, toggle: () => {} }); + +export function ThemeProvider({ children }: { children: ReactNode }) { + const [isDark, setIsDark] = useState(false); + + useEffect(() => { + document.documentElement.setAttribute('data-theme', isDark ? 'dark' : 'light'); + }, [isDark]); + + return ( + setIsDark(d => !d) }}> + {children} + + ); +} + +export const useTheme = () => useContext(ThemeContext);