Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
}

.active-page{
border-bottom: 2px solid blue;
border-bottom: 2px solid rgb(73, 102, 217);
transition: 100ms ease;
}

.pages h1::first-letter{
color:rgb(89, 89, 200);
color:rgb(73, 102, 217);
}

body{
Expand Down
21 changes: 14 additions & 7 deletions src/contexts/ThemeContext.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
import { createContext, useState, type ReactNode } from "react";
import { createContext, useState, type ReactNode, useEffect } from "react";

interface ThemeTypes {
theme: "light" | "dark";
interface Themes {
theme: string;
toggleTheme: () => void;
}
const ThemeContext = createContext<Themes | null>(null);

export const ThemeContext = createContext<null | ThemeTypes>(null);
function ThemeProvider({ children }: { children: ReactNode }) {
const [theme, setTheme] = useState(localStorage.getItem("theme") || "light");

export function ThemeProvider({ children }: { children: ReactNode }) {
const [theme, setTheme] = useState<"light" | "dark">("light");
const toggleTheme = () =>
useEffect(() => {
localStorage.setItem("theme", theme);
}, [theme]);

const toggleTheme = () => {
setTheme((prev) => (prev === "light" ? "dark" : "light"));
};

return (
<ThemeContext.Provider value={{ theme, toggleTheme }}>
{children}
</ThemeContext.Provider>
);
}
export { ThemeContext, ThemeProvider };