diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..30de70f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "editor.acceptSuggestionOnEnter": "on" +} \ No newline at end of file diff --git a/app/context/store.tsx b/app/context/store.tsx index c4f8af3..74324f6 100644 --- a/app/context/store.tsx +++ b/app/context/store.tsx @@ -1,5 +1,5 @@ "use client"; -import { createContext, useContext, useState, ReactNode } from "react"; +import { createContext, useContext, useState, ReactNode, useEffect } from "react"; import { AllPropsFromLayout, Theme, themeContext } from "@/types"; const ThemeContext = createContext({ @@ -10,8 +10,19 @@ const ThemeContext = createContext({ export const ThemeContextProvider = ({ children }: AllPropsFromLayout) => { const [theme, setTheme] = useState("dark"); + useEffect(() => { + // get the theme from localStorage on initial render + const storedTheme = localStorage.getItem("theme"); + if (storedTheme) { + setTheme(storedTheme); + } + }, []); + const handleThemeSwitch = () => { - setTheme(theme === "dark" ? "light" : "dark"); + // toggle the theme and store it in localStorage + const newTheme = theme === "dark" ? "light" : "dark"; + setTheme(newTheme); + localStorage.setItem("theme", newTheme); }; return ( diff --git a/app/layout.tsx b/app/layout.tsx index fe46873..14f9e49 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -4,6 +4,9 @@ import Navbar from "@/components/Navbar"; import { ThemeContextProvider } from "./context/store"; import NavigationLinks from "@/components/NavigationLinks"; import Footer from "@/components/Footer"; +import Announcement from "@/components/Announcement"; + + const inter = Inter({ subsets: ["latin"] }); @@ -13,11 +16,13 @@ export const metadata = { "A website where essential tools, prompts, and datasets are thoughtfully curated and combined in one place for your convenience.", }; + export default function RootLayout({ children, }: { children: React.ReactNode; }) { + return ( @@ -54,16 +59,21 @@ export default function RootLayout({ - - - {children} + +
+ + + {children} +
+