Add dark mode; align table headers with numeric columns

Dark mode:
- Theme toggle in the header (System → Light → Dark); "System" follows
  the OS setting and its changes. The choice is kept per browser and
  applied before first paint, so there's no light flash.
- Implemented by remapping the palette under :root[data-theme=dark]:
  grays flip, color tints become translucent, dark colored text becomes
  its light counterpart. Page, surface, header and accent colors are
  semantic tokens. Native controls follow via color-scheme.
- Chart text and grid colors follow the theme.
- Public share pages get the toggle too.
- Contrast checked against WCAG 4.5:1 (primary button text and error
  text adjusted for dark).

Tables:
- Shared table style no longer forces header text left, so right-aligned
  numeric headers line up with their columns everywhere.
- Flight log: units in headers, muted dashes for empty cells, GPS marker
  beside the route instead of its own column.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-05 19:53:11 -05:00
1 parent 5bf682502b
commit 86aadfcf6c
13 files changed
+216 -25

No files matched your search

+1
View File
@@ -116,6 +116,7 @@ class PagesTest < ActionDispatch::IntegrationTest
test "flights tab shows flying stats" do
get aircraft_flight_logs_path(@a)
assert_select "th.text-right", text: "Fuel (gal)" # numeric headers align with their columns
assert_select "h2", text: "Flight hours by month"
assert_select "dt", text: "Airports visited"
end
+27
View File
@@ -0,0 +1,27 @@
require "test_helper"
class ThemeTest < ActionDispatch::IntegrationTest
test "pages set the theme before paint and offer a toggle" do
sign_in create_user
get root_path
head = response.body[/<head>.*?<\/head>/m]
assert_match "localStorage.getItem(\"theme\")", head
assert head.index("dataset.theme") < head.index("stylesheet"), "theme script must run before the stylesheet loads"
assert_select "header button[data-controller='theme']"
assert_select "html.bg-page"
end
test "shared (public) pages support dark mode too" do
owner = create_user
token = create_aircraft(owner: owner).share_tokens.create!(privilege: "status")
get shared_path(token.token)
assert_select "header button[data-controller='theme']"
assert_match "dataset.theme", response.body
end
test "stylesheet has the dark palette" do
css = Rails.root.join("app/assets/builds/tailwind.css").read
assert_match ":root[data-theme=dark]", css
assert_match "color-scheme:dark", css
end
end