Skip to content

Conversation

@roo-code-cte
Copy link

@roo-code-cte roo-code-cte bot commented Jan 28, 2026

This PR adds a comprehensive dark mode feature with a theme picker component.

Changes

Tailwind CSS Configuration

  • Enabled class-based dark mode using @custom-variant dark
  • Added smooth transition effects for theme changes

Theme Stimulus Controller (theme_controller.js)

  • Supports three modes: Light, Dark, and System (auto-detect)
  • Persists user preference in localStorage
  • Listens for OS preference changes when in System mode
  • Prevents flash of unstyled content with inline script

UI Components

  • Theme picker positioned in top-right corner
  • Three icon buttons: Sun (light), Moon (dark), Monitor (system)
  • Clean, accessible design that works in both themes

Updated Views

  • application.html.erb: Added theme picker and body dark classes
  • home/index.html.erb: Added dark mode variants for all elements
  • home/_counter.html.erb: Added dark mode variants for counter display

How It Works

  1. User clicks a theme button (Light/Dark/System)
  2. Preference is saved to localStorage
  3. dark class is toggled on <html> element
  4. Tailwind applies all dark: variant styles
  5. On page load, theme is restored before paint to prevent flicker

Testing

  1. Click the sun icon for light mode
  2. Click the moon icon for dark mode
  3. Click the monitor icon to follow system preference
  4. Refresh the page - preference should persist
  5. In System mode, change OS dark mode setting to see auto-switch

Important

Adds dark mode with a theme picker, using Tailwind CSS and a Stimulus controller to manage and persist user theme preferences.

  • Dark Mode Implementation:
    • Enabled class-based dark mode in application.css using @custom-variant dark.
    • Added smooth transition effects for theme changes in application.css.
  • Theme Controller:
    • Added theme_controller.js to manage light, dark, and system theme modes.
    • Persists user theme preference in localStorage and listens for OS preference changes.
    • Prevents flash of unstyled content with an inline script in application.html.erb.
  • UI Components:
    • Added theme picker in application.html.erb with buttons for light, dark, and system modes.
    • Updated home/index.html.erb and home/_counter.html.erb to include dark mode variants for elements.
  • Behavior:
    • Theme preference is saved to localStorage and applied on page load.
    • dark class toggled on <html> element based on user preference or system setting.

This description was created by Ellipsis for b3b0aed. You can customize this summary. It will automatically update as commits are pushed.

- Add Tailwind CSS dark mode configuration with class-based variant
- Create Stimulus theme controller with light/dark/system options
- Add theme picker UI component in layout with sun/moon/monitor icons
- Add inline script to prevent flash of unstyled content
- Update home page and counter partial with dark mode classes
- Theme preference persists in localStorage
- System preference option respects OS dark mode setting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant