Files
pastel-ui/components/layout/ThemeToggle.tsx

29 lines
688 B
TypeScript
Raw Normal View History

feat: implement navigation and dark/light theme system Add complete navigation and theming infrastructure: **Theme System:** - ThemeProvider component with React Context - Supports light, dark, and system themes - Persists preference to localStorage - Auto-detects system theme preference - Listens for system theme changes - Smooth theme transitions - ThemeToggle component - Sun/Moon icon toggle button - Accessible with ARIA labels - Shows current theme state - Keyboard accessible **Navigation:** - Navbar component with sticky header - Gradient logo with Palette icon - Desktop horizontal navigation - Mobile responsive menu - Active route highlighting - Backdrop blur effect - Links to all main sections: - Home - Playground - Palettes - Accessibility - Named Colors - Batch Operations **Layout Updates:** - Integrated Navbar into root layout - Added ThemeProvider to Providers wrapper - Proper HTML suppressHydrationWarning for theme - Container-based responsive layout **Features:** - Theme persists across page reloads - System theme preference detection - Active navigation state - Smooth hover transitions - Mobile-first responsive design - Accessible navigation with proper semantics **Styling:** - Gradient text logo (pink → purple → blue) - Sticky top navbar with backdrop blur - Border bottom for visual separation - Consistent spacing and padding - Mobile menu slides in smoothly Build successful! Navigation and theming complete. Next: Palette generation pages and additional features. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 11:35:05 +01:00
'use client';
import { Moon, Sun } from 'lucide-react';
import { useTheme } from '@/components/providers/ThemeProvider';
import { Button } from '@/components/ui/button';
export function ThemeToggle() {
const { theme, setTheme, resolvedTheme } = useTheme();
const toggleTheme = () => {
setTheme(resolvedTheme === 'dark' ? 'light' : 'dark');
};
return (
<Button
variant="ghost"
size="icon"
onClick={toggleTheme}
aria-label={`Switch to ${resolvedTheme === 'dark' ? 'light' : 'dark'} mode`}
>
{resolvedTheme === 'dark' ? (
<Sun className="h-5 w-5" />
) : (
<Moon className="h-5 w-5" />
)}
</Button>
);
}