The Profile Rank (FitFinder) application now supports both light and dark themes, providing users with a better experience in different lighting conditions and personal preferences.
- Location: Header (top-right corner, next to GitHub button)
- Design: Beautiful toggle switch with sun/moon icons
- Functionality: Click to switch between light and dark themes
- Accessibility: Proper ARIA labels and keyboard navigation support
- Automatic Detection: Respects user's system preference (
prefers-color-scheme) - Fallback: Defaults to light theme if no preference is detected
- Dynamic Updates: Automatically updates when system theme changes
- Local Storage: User's theme preference is saved and restored on page reload
- Priority: User selection takes precedence over system preference
- Reset: Can be reset by clearing browser data
src/contexts/ThemeContext.tsx- Theme management with React Contextsrc/components/ThemeToggle.tsx- Toggle component with animationssrc/components/ThemeToggle.css- Styling for the toggle componentsrc/App.tsx- Updated to include ThemeProvider and togglesrc/App.css- Updated with CSS variables for theming
- CSS Variables: All colors are defined as CSS custom properties
- Smooth Transitions: 0.3s ease transitions for theme changes
- Responsive Design: Toggle adapts to different screen sizes
- TypeScript Support: Full type safety for theme management
- Background:
#f5f5f5(light gray) - Cards:
#ffffff(white) - Text:
#333333(dark gray) - Primary:
#007bff(blue) - Borders:
#dddddd(light gray)
- Background:
#1a202c(dark gray) - Cards:
#2d3748(medium dark gray) - Text:
#f7fafc(light gray) - Primary:
#63b3ed(light blue) - Borders:
#4a5568(medium gray)
- Click the theme toggle in the header (moon/sun icon)
- Theme changes immediately with smooth animation
- Preference is automatically saved
- System theme changes are respected (if no manual selection)
import { useTheme } from './contexts/ThemeContext';
const MyComponent = () => {
const { theme, toggleTheme, setTheme } = useTheme();
return (
<button onClick={toggleTheme}>
Current theme: {theme}
</button>
);
};- Modern Browsers: Full support for CSS custom properties
- System Theme:
prefers-color-schememedia query support - Local Storage: For theme persistence
- Fallbacks: Graceful degradation for older browsers
- Keyboard Navigation: Toggle is fully keyboard accessible
- Screen Readers: Proper ARIA labels and descriptions
- Focus Indicators: Clear focus states for keyboard users
- High Contrast: Themes maintain good contrast ratios
- Theme-specific images/icons
- Custom theme colors
- Theme scheduling (auto-switch based on time)
- Reduced motion support for animations