Skip to content

Appearance System Implementation

✅ Now Fully Functional!

The appearance settings now actually apply to the UI when you save them!

How It Works

1. AppearanceProvider Context (contexts/AppearanceContext.tsx)

  • Wraps the entire dashboard
  • Reads appearance settings from currentUser.preferences.appearance
  • Applies changes to the DOM via CSS variables and classes

2. Theme Switching (Light / Dark / Auto)

// Applies 'dark' class to <html> element
if (theme === 'dark') {
    document.documentElement.classList.add('dark')
} else if (theme === 'auto') {
    // Uses system preference
    if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
        document.documentElement.classList.add('dark')
    }
}

3. Color Scheme (Default / Blue / Green / Purple)

// Sets CSS variable --primary-color
const colorMap = {
    default: '#F39C12',  // Orange
    blue: '#3498DB',
    green: '#27AE60',
    purple: '#9B59B6'
}
document.documentElement.style.setProperty('--primary-color', colorMap[colorScheme])

4. Font Size (Small / Medium / Large)

// Sets CSS variable --base-font-size
const fontSizeMap = {
    small: '14px',
    medium: '16px',
    large: '18px'
}
document.documentElement.style.setProperty('--base-font-size', fontSizeMap[fontSize])

5. Compact Mode

// Adds 'compact-mode' class which reduces spacing
if (compactMode) {
    document.documentElement.classList.add('compact-mode')
}

CSS then applies reduced spacing:

.compact-mode {
  --spacing-multiplier: 0.75;
}

.compact-mode .p-6 {
  padding: calc(1.5rem * var(--spacing-multiplier, 1));
}

Testing

  1. Go to Settings → Appearance
  2. Change Theme to Dark
  3. Click "Save Changes"
  4. Page reloads with dark mode applied
  5. Change Color Scheme to Purple
  6. Click "Save Changes"
  7. Primary color changes to purple
  8. Change Font Size to Large
  9. Click "Save Changes"
  10. Text becomes larger
  11. Enable Compact Mode
  12. Click "Save Changes"
  13. Spacing reduces throughout dashboard

Implementation Details

Files Modified:

  • contexts/AppearanceContext.tsx - NEW - Manages appearance state
  • app/globals.css - Added CSS variables and compact mode styles
  • app/dashboard/layout.tsx - Wrapped with AppearanceProvider
  • app/dashboard/settings/page.tsx - Added reload after appearance save

Why Page Reload?

The appearance settings modify CSS variables and classes that affect the entire app. While we could use React state, a page reload ensures all components properly pick up the new styles without any cached styling issues.

Future Enhancements

  • [ ] Smooth transitions between themes (fade effect)
  • [ ] Preview mode (see changes before saving)
  • [ ] More color schemes (red, teal, etc.)
  • [ ] Custom color picker for advanced users
  • [ ] Remember system preference for auto theme
  • [ ] Accessibility: High contrast mode
  • [ ] Dyslexia-friendly fonts option