-
Notifications
You must be signed in to change notification settings - Fork 103
Add dark mode support following system preference #1296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
b95cae6 to
74d3fb2
Compare
Add comprehensive dark mode support to the Maintenance Tasks UI that automatically follows the user's system/browser preference (prefers-color-scheme): - Switch from bulma-no-dark-mode.min.css to bulma.min.css to enable Bulma's built-in dark mode support - Implement CSS custom properties for syntax highlighting colors with dark mode variants - Use CSS color-scheme property to automatically apply correct theme based on system preference - Update CSP hashes for modified inline styles - Update Bulma CDN integrity hash for the full version The implementation provides a seamless dark mode experience that automatically adapts to the user's system settings, similar to Mission Control Jobs. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
74d3fb2 to
478fde3
Compare
|
Note: The Run button keeps white text in both light and dark modes. While Bulma's success button color varies slightly between themes, white text provides sufficient contrast in both cases without overcomplicating the implementation. |
|
Note: The Run button keeps white text (has-text-white-ter) in both light and dark modes. While Bulma's success button color varies slightly between themes, white text provides sufficient contrast in both cases without overcomplicating the implementation. |
|
I have signed the CLA! |
adrianna-chang-shopify
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @marckohlbrugge , thanks for the contribution!
Changes generally look good on 🎩 , I think we may just need to make the contrast for the boxes even stronger.
cc @nvasilevski @etiennebarrie either of you up for tophatting?
| BULMA_CDN = "https://cdn.jsdelivr.net" | ||
|
|
||
| content_security_policy do |policy| | ||
| policy.style_src( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change necessary? We changed from style_src -> style_src_elem in #1195 to prevent CSP conflicts when the parent application uses style_src_elem directives, since we fall back to style_src.
|
|
||
| @media (prefers-color-scheme: dark) { | ||
| .box { | ||
| background-color: var(--bulma-scheme-main-bis); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
@adrianna-chang-shopify Thanks for the feedback! I agree with using I tried testing this locally but kept running into CSP issues that I couldn't resolve after 30 minutes. Given the strict CSP configuration in the test dummy app, it might be easier if you could commit this change directly so it can be validated during tophatting. |


Summary
Add comprehensive dark mode support that automatically follows the user's system/browser preference (
prefers-color-scheme), similar to how Mission Control Jobs handles theming.Changes
1. Switch to Bulma with Dark Mode Support
bulma-no-dark-mode.min.csstobulma.min.css(v1.0.3)2. Custom Syntax Highlighting for Dark Mode
prefers-color-scheme3. Enhanced Box/Card Visibility in Dark Mode
background-color: var(--bulma-scheme-main-bis)to.boxelements in dark mode4. Fixed Button Text Contrast
has-text-white-terclass from Run button5. Updated Content Security Policy
policy.style_src(:self, BULMA_CDN)to allow external stylesheet loadingImplementation Details
No Toggle Required: The implementation uses pure CSS
@media (prefers-color-scheme: dark)queries, so the UI automatically adapts to the user's system preference without any JavaScript toggle or localStorage.CSS Variables Used:
--bulma-scheme-main-bis: For box backgrounds in dark mode (official Bulma variable)--ruby-*variables: For syntax highlighting that adapts to themeFiles Modified:
app/views/layouts/maintenance_tasks/application.html.erb- CSS variables and dark mode stylesapp/views/layouts/maintenance_tasks/_navbar.html.erb- Removedis-lightclass for automatic themingapp/controllers/maintenance_tasks/application_controller.rb- Updated CSP configurationapp/views/maintenance_tasks/tasks/show.html.erb- Removed hardcoded button text colorTesting
To test dark mode:
prefers-color-schemeScreenshots
Related
Inspired by Mission Control Jobs' approach to dark mode - simple, automatic, and respecting user preferences.