Skip to content

Commit 74d3fb2

Browse files
Add dark mode support following system preference
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]>
1 parent 004f83c commit 74d3fb2

File tree

3 files changed

+47
-12
lines changed

3 files changed

+47
-12
lines changed

app/controllers/maintenance_tasks/application_controller.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ class ApplicationController < MaintenanceTasks.parent_controller.constantize
88
BULMA_CDN = "https://cdn.jsdelivr.net"
99

1010
content_security_policy do |policy|
11+
policy.style_src(
12+
:self,
13+
BULMA_CDN,
14+
)
1115
policy.style_src_elem(
1216
BULMA_CDN,
1317
# <style> tag in app/views/layouts/maintenance_tasks/application.html.erb
14-
"'sha256-WHHDQLdkleXnAN5zs0GDXC5ls41CHUaVsJtVpaNx+EM='",
18+
"'sha256-LVai3C2/+O9MPVaeiRrXbcSwDbPxqWfXI4pz487d9Js='",
1519
)
1620
capybara_lockstep_scripts = [
1721
"'sha256-1AoN3ZtJC5OvqkMgrYvhZjp4kI8QjJjO7TAyKYiDw+U='",

app/views/layouts/maintenance_tasks/_navbar.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<nav class="navbar is-light" role="navigation" aria-label="main navigation">
1+
<nav class="navbar" role="navigation" aria-label="main navigation">
22
<div class="navbar-brand">
33
<%= link_to 'Maintenance Tasks', root_path, class: 'navbar-item is-size-4 has-text-weight-semibold has-text-danger' %>
44
</div>

app/views/layouts/maintenance_tasks/application.html.erb

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,44 @@
1616
<%= csrf_meta_tags %>
1717

1818
<%=
19-
stylesheet_link_tag(URI.join(controller.class::BULMA_CDN, "npm/[email protected]/css/versions/bulma-no-dark-mode.min.css"),
19+
stylesheet_link_tag(URI.join(controller.class::BULMA_CDN, "npm/[email protected]/css/bulma.min.css"),
2020
media: :all,
21-
integrity: "sha256-HCNMQcqH/4MnGR0EYg2S3/BXYMM1z9lrFV10ANRd79o",
21+
integrity: "sha256-RwYNyYLkMTjyYn8FRzVzQFtHXuHg9dpfkPCuf6j2XDM=",
2222
crossorigin: "anonymous") unless request.xhr?
2323
%>
2424

2525
<style>
26-
.ruby-comment { color: #6a737d;}
27-
.ruby-const { color: #e36209; }
28-
.ruby-embexpr-beg, .ruby-embexpr-end, .ruby-period { color: #24292e; }
29-
.ruby-ident, .ruby-symbeg { color: #6f42c1; }
30-
.ruby-ivar, .ruby-cvar, .ruby-gvar, .ruby-int, .ruby-imaginary, .ruby-float, .ruby-rational { color: #005cc5; }
31-
.ruby-kw { color: #d73a49; }
32-
.ruby-label, .ruby-tstring-beg, .ruby-tstring-content, .ruby-tstring-end { color: #032f62; }
26+
:root {
27+
--ruby-comment: #6a737d;
28+
--ruby-const: #e36209;
29+
--ruby-embexpr: #24292e;
30+
--ruby-ident: #6f42c1;
31+
--ruby-number: #005cc5;
32+
--ruby-keyword: #d73a49;
33+
--ruby-string: #032f62;
34+
--required-color: #ff6685;
35+
}
36+
37+
@media (prefers-color-scheme: dark) {
38+
:root {
39+
--ruby-comment: #8b949e;
40+
--ruby-const: #ffa657;
41+
--ruby-embexpr: #c9d1d9;
42+
--ruby-ident: #d2a8ff;
43+
--ruby-number: #79c0ff;
44+
--ruby-keyword: #ff7b72;
45+
--ruby-string: #a5d6ff;
46+
--required-color: #ff6685;
47+
}
48+
}
49+
50+
.ruby-comment { color: var(--ruby-comment); }
51+
.ruby-const { color: var(--ruby-const); }
52+
.ruby-embexpr-beg, .ruby-embexpr-end, .ruby-period { color: var(--ruby-embexpr); }
53+
.ruby-ident, .ruby-symbeg { color: var(--ruby-ident); }
54+
.ruby-ivar, .ruby-cvar, .ruby-gvar, .ruby-int, .ruby-imaginary, .ruby-float, .ruby-rational { color: var(--ruby-number); }
55+
.ruby-kw { color: var(--ruby-keyword); }
56+
.ruby-label, .ruby-tstring-beg, .ruby-tstring-content, .ruby-tstring-end { color: var(--ruby-string); }
3357

3458
.select, select { width: 100%; }
3559
summary { cursor: pointer; }
@@ -55,9 +79,16 @@
5579
box-shadow: 0 4px 6px -1px #0000001a,
5680
0 2px 4px -2px #0000001a;
5781
}
82+
83+
@media (prefers-color-scheme: dark) {
84+
.box {
85+
background-color: var(--bulma-scheme-main-bis);
86+
}
87+
}
88+
5889
.label.is-required:after {
5990
content: " (required)";
60-
color: #ff6685;
91+
color: var(--required-color);
6192
font-size: 12px;
6293
}
6394
</style>

0 commit comments

Comments
 (0)