MCPcopy
hub / github.com/Peppermint-Lab/peppermint / ThemeSettings

Function ThemeSettings

apps/client/components/ThemeSettings/index.tsx:17–75  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15import { Moon } from "lucide-react";
16
17export default function ThemeSettings() {
18 const { user } = useUser();
19 const token = getCookie("session");
20
21 const [theme, setTheme] = useState("");
22
23 const { state } = useSidebar();
24
25 useEffect(() => {
26 // Retrieve the saved theme from localStorage or default to 'light'
27 const savedTheme = localStorage.getItem("theme") || "light";
28 setTheme(savedTheme);
29 document.documentElement.className = savedTheme;
30 }, []);
31
32 const toggleTheme = (selectedTheme) => {
33 // Update the class on the root element
34 document.documentElement.className = selectedTheme;
35 // Update state and save the theme in localStorage
36 setTheme(selectedTheme);
37 localStorage.setItem("theme", selectedTheme);
38 };
39
40 return (
41 <div>
42 <main className="relative">
43 <div className="flex justify-center">
44 <Select onValueChange={toggleTheme} value={theme}>
45 <SelectTrigger className={`${state === "expanded" ? "w-[280px]" : "hidden"}`}>
46 {state === "expanded" ? (
47 <SelectValue placeholder="Select a theme" />
48 ) : (
49 <Moon className="size-4" />
50 )}
51 </SelectTrigger>
52 <SelectContent>
53 <SelectGroup>
54 <SelectLabel>Themes</SelectLabel>
55 <SelectItem value="light">Peppermint Light</SelectItem>
56 <SelectItem value="dark">Peppermint Dark</SelectItem>
57 <SelectItem value="solarized-light">Solarized Light</SelectItem>
58 {/* <SelectItem value="solarized-dark">Solarized Dark</SelectItem> */}
59 <SelectItem value="forest">Forest</SelectItem>
60 <SelectItem value="material-light">Material Light</SelectItem>
61 {/* <SelectItem value="material-dark">Material Dark</SelectItem> */}
62 <SelectItem value="github-light">GitHub Light</SelectItem>
63 {/* <SelectItem value="github-dark">GitHub Dark</SelectItem> */}
64 {/* <SelectItem value="high-contrast-dark">
65 High Contrast Dark
66 </SelectItem> */}
67 {/* <SelectItem value="pastel">Pastel</SelectItem> */}
68 </SelectGroup>
69 </SelectContent>
70 </Select>
71 </div>
72 </main>
73 </div>
74 );

Callers

nothing calls this directly

Calls 2

useUserFunction · 0.90
useSidebarFunction · 0.90

Tested by

no test coverage detected