Implemented comprehensive dark/light mode support throughout the app: - Added ColorSchemeScript to layout for auto-detection of system preference - Updated MantineProvider to use 'auto' color scheme (respects system) - Updated theme.ts with dynamic Paper component styles based on color scheme - Created ThemeToggle component with sun/moon icons - Added toggle to desktop sidebar navigation - Created theme-specific favicons (favicon-light.svg, favicon-dark.svg) - Made ThoughtGalaxy 3D visualization theme-aware: - Dynamic node colors based on theme - Theme-aware lighting intensity - Theme-aware link colors - Theme-aware text labels - Added comprehensive Playwright tests for theme functionality - Theme preference persists via localStorage Tested manually with Playwright MCP: - ✅ Theme toggle switches between light and dark modes - ✅ Theme persists across page reloads - ✅ Both modes render correctly with appropriate colors - ✅ Icons change based on current theme (sun/moon) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
36 lines
974 B
TypeScript
36 lines
974 B
TypeScript
'use client';
|
|
|
|
import { ActionIcon, useMantineColorScheme, useComputedColorScheme } from '@mantine/core';
|
|
import { IconSun, IconMoon } from '@tabler/icons-react';
|
|
|
|
/**
|
|
* ThemeToggle Component
|
|
*
|
|
* Toggles between light and dark color schemes.
|
|
* Uses Mantine's built-in color scheme hooks for state management and persistence.
|
|
*/
|
|
export function ThemeToggle() {
|
|
const { setColorScheme } = useMantineColorScheme();
|
|
const computedColorScheme = useComputedColorScheme('light');
|
|
|
|
const toggleColorScheme = () => {
|
|
setColorScheme(computedColorScheme === 'dark' ? 'light' : 'dark');
|
|
};
|
|
|
|
return (
|
|
<ActionIcon
|
|
onClick={toggleColorScheme}
|
|
variant="subtle"
|
|
size="lg"
|
|
aria-label="Toggle color scheme"
|
|
title={`Switch to ${computedColorScheme === 'dark' ? 'light' : 'dark'} mode`}
|
|
>
|
|
{computedColorScheme === 'dark' ? (
|
|
<IconSun size={20} />
|
|
) : (
|
|
<IconMoon size={20} />
|
|
)}
|
|
</ActionIcon>
|
|
);
|
|
}
|