Skip to content

Conversation

jainal09
Copy link

@jainal09 jainal09 commented Sep 25, 2025

Summary

Implements a complete dark mode feature for grpcui with a toggle switch that allows users to seamlessly switch between light and dark themes.

All this time whenever I was working with your amazing tool, my eyes would pop out whenever I would switch tabs from dark theme of my editor to my browser to test my GRPC server. So, I thought I need dark mode ASAP!

Hope this helps others like me!

Features

  • Dark mode toggle switch with accessibility features (ARIA attributes, keyboard navigation)
  • localStorage persistence - remembers user preference across sessions
  • System preference detection - automatically respects prefers-color-scheme media query
  • Professional color scheme inspired by GitHub's dark theme
  • Comprehensive styling for all UI elements including:
    • Form inputs, buttons, and controls
    • Tables, tabs, and response panels
    • Error messages and status indicators
    • jQuery UI datepicker/calendar widget
  • Accessibility compliant with proper contrast ratios
  • Cross-browser compatibility

Implementation Details

  • Added toggle switch UI in webform-template.html
  • Implemented theme management JavaScript in webform.js
  • Extended CSS with comprehensive dark mode styles in webform-sample.css
  • Uses CSS custom properties for maintainable theming
  • Follows existing code patterns and conventions

Testing

Tested comprehensively with the KitchenSink test server to ensure all UI elements (including calendar widgets with timestamp fields) render correctly in both light and dark modes.

Screenshots

The implementation provides a professional dark theme that matches modern UI expectations while maintaining full functionality and accessibility.

image image image image

Light Mode stays as it is

image

jgosaliya added 2 commits September 25, 2025 03:29
- Add dark mode toggle switch in webform template with accessibility features
  - Implement localStorage persistence and system preference detection
  - Apply professional GitHub-inspired dark color scheme
  - Add comprehensive dark mode CSS for all UI elements including:
    - Form inputs, buttons, and controls
    - Tables, tabs, and response panels
    - Error messages and status indicators
    - jQuery UI datepicker/calendar widget
  - Ensure proper contrast ratios for accessibility
  - Maintain cross-browser compatibility
@jainal09
Copy link
Author

jainal09 commented Sep 28, 2025

@gpassini @dragonsinth @jhump @n0v1

Hi! I know u guys might be busy, but I would much appreciate a review as per your earliest convivence!

Cheers 🥂!

@dragonsinth
Copy link
Member

@jainal09 honestly this is a bit much... I think we could accept a pure-CSS change using light-dark() to simply respect the browser/device preference. But the UI toggle, javascript, and cookie storage is just kind of overkill.

@jainal09
Copy link
Author

@dragonsinth , Thank you for the feedback! I understand the concern about complexity, but
I'd like to address a key usability issue with a pure CSS-only approach.

The Problem:

  • Pure CSS light-dark() only respects system preferences with no override
    capability
  • So, If users want to use a different theme than their system setting, they
    have no way to do so.
  • We can keep a pure css toggle without local storage but Without any persistence, users would have to manually toggle the theme
    on every page refresh, which creates a poor user experience

So, I propose we find a middle ground approach:

  • We replace the complex toggle switch with a simple sun/moon icon button.
  • We keep minimal localStorage (just one key) for theme preference - this is
    essential UX
  • We also significantly simplify the JavaScript (remove system preference change
    listeners, complex state management)
  • use light-dark() CSS as the base with simple override classes
  • So, By default if there is no darkmode switch ever done, we still respect system preferences but allow
    users to override and remember their choice.

The localStorage is really the minimum viable functionality needed. Modern
web users expect their theme choice to persist, and it's just a single
localStorage key. Without it, the feature becomes more of a frustration
than a benefit.

Would this simplified approach with minimal persistence be acceptable?

@jainal09
Copy link
Author

jainal09 commented Sep 29, 2025

I made some changes and this is how it will look like if you approve it
image
image

This looks minimal and not too overkill

You can check the latest push for the new code changes. If you still dont like it I am open to make it to just system theme preference dependent. But I feel like this should address your concerns. @dragonsinth

  - Replace complex toggle switch with intuitive sun/moon icon button
  - Implement minimal localStorage persistence for user preference
  - Add system preference detection as fallback using prefers-color-scheme
  - Apply GitHub-inspired dark color scheme with proper contrast ratios
  - Position theme toggle on viewport edge to prevent layout issues
  - Reduce JavaScript complexity from ~75 to ~25 lines of code
  - Maintain cross-browser compatibility and accessibility standards

  Addresses maintainer feedback about implementation complexity while
  preserving essential UX functionality for voluntary theme switching.
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.

2 participants