MCPcopy Create free account
hub / github.com/BingyanStudio/github-analyzer / ThemeToggle

Function ThemeToggle

web/src/components/ThemeToggle.tsx:5–32  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3import { useTheme } from "./theme-provider";
4
5export function ThemeToggle() {
6 const { theme, setTheme } = useTheme();
7
8 const toggleTheme = () => {
9 const newTheme = theme === "dark" ? "light" : "dark";
10 console.log(`Switching theme from ${theme} to ${newTheme}`);
11 setTheme(newTheme);
12 };
13
14 // Log the current theme to help with debugging
15 console.log("Current theme:", theme);
16
17 return (
18 <Button
19 variant="ghost"
20 size="icon"
21 onClick={toggleTheme}
22 title={`Switch to ${theme === "dark" ? "light" : "dark"} theme`}
23 >
24 {theme === "dark" ? (
25 <Sun className="h-5 w-5" />
26 ) : (
27 <Moon className="h-5 w-5" />
28 )}
29 <span className="sr-only">Toggle theme</span>
30 </Button>
31 );
32}

Callers

nothing calls this directly

Calls 1

useThemeFunction · 0.90

Tested by

no test coverage detected