diff --git a/src/App.tsx b/src/App.tsx index 18daf2e..1bb3afd 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -5,23 +5,26 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { BrowserRouter, Routes, Route } from "react-router-dom"; import Index from "./pages/Index"; import NotFound from "./pages/NotFound"; +import { ThemeProvider } from "@/components/theme-provider"; const queryClient = new QueryClient(); const App = () => ( - - - - - - - } /> - {/* ADD ALL CUSTOM ROUTES ABOVE THE CATCH-ALL "*" ROUTE */} - } /> - - - - + + + + + + + + } /> + {/* ADD ALL CUSTOM ROUTES ABOVE THE CATCH-ALL "*" ROUTE */} + } /> + + + + + ); export default App; diff --git a/src/components/theme-provider.tsx b/src/components/theme-provider.tsx new file mode 100644 index 0000000..2244569 --- /dev/null +++ b/src/components/theme-provider.tsx @@ -0,0 +1,8 @@ +"use client"; + +import { ThemeProvider as NextThemesProvider } from "next-themes"; +import type { ThemeProviderProps } from "next-themes/dist/types"; + +export function ThemeProvider({ children, ...props }: ThemeProviderProps) { + return {children}; +} \ No newline at end of file diff --git a/src/pages/Index.tsx b/src/pages/Index.tsx index 8aa8a9b..f97bb5b 100644 --- a/src/pages/Index.tsx +++ b/src/pages/Index.tsx @@ -1,5 +1,5 @@ import { useState, useEffect, useCallback, useRef } from 'react'; -import { Trash2 } from 'lucide-react'; +import { Trash2, Moon, Sun } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Textarea } from '@/components/ui/textarea'; import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog'; @@ -9,6 +9,8 @@ import { Slider } from '@/components/ui/slider'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; import { toast } from '@/hooks/use-toast'; import { Window } from '@tauri-apps/api/window'; +import { Switch } from '@/components/ui/switch'; +import { useTheme } from 'next-themes'; interface Note { id: string; @@ -71,6 +73,8 @@ const Index = () => { const [gotoDateInput, setGotoDateInput] = useState(''); const [cacheMode, setCacheMode] = useState<'global' | 'scoped'>('global'); + const { resolvedTheme, setTheme } = useTheme(); + const previousNoteRef = useRef(null); const currentNoteRef = useRef(null); const scratchRef = useRef(null); @@ -1185,12 +1189,21 @@ const Index = () => { }; return ( -
+
{/* Header */} -
+
-

Journal

-
+

Journal

+
+
+ + setTheme(checked ? 'dark' : 'light')} + aria-label="Toggle theme" + /> + +