mirror of
https://github.com/freedbygrace/ActiveDirectoryManager.git
synced 2026-08-11 03:09:37 +00:00
Enhance theme switching to handle missing context
Replit-Commit-Author: Agent Replit-Commit-Session-Id: 705f2157-ef97-4fbd-89e4-8c7f2ecaea90 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7ed01c5f-a82d-405a-b728-b2e3d127c60c/70b9c0b1-a5f0-4a27-9a6a-5bb48b9d90b1.jpg
This commit is contained in:
@@ -9,7 +9,25 @@ import {
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import { useTheme } from "@/hooks/use-theme";
|
||||
|
||||
// Fallback toggle without context dependency
|
||||
export function ThemeToggle() {
|
||||
// Try/catch block to handle possible context errors
|
||||
try {
|
||||
return <ThemeToggleWithContext />;
|
||||
} catch (error) {
|
||||
console.error("Theme context error:", error);
|
||||
// Fallback rendering without context
|
||||
return (
|
||||
<Button variant="ghost" size="icon" className="relative h-9 w-9 rounded-md">
|
||||
<Sun className="h-5 w-5" />
|
||||
<span className="sr-only">Theme settings</span>
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Component that uses the theme context
|
||||
function ThemeToggleWithContext() {
|
||||
const { theme, setTheme } = useTheme();
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user