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

+79 -6
View File
@@ -1,25 +1,36 @@
@import "tailwindcss"; @import "tailwindcss";
/* Semantic colors that differ by theme (dark values are set further down). */
@theme {
--color-page: oklch(96.8% 0.007 247.896); /* slate-100 */
--color-surface: oklch(100% 0 0); /* white: cards, inputs, menus */
--color-header: oklch(20.8% 0.042 265.755); /* slate-900: top bar, dark in both themes */
--color-accent: oklch(50% 0.134 242.749); /* sky-700: primary buttons */
--color-accent-hover: oklch(44.3% 0.11 240.79); /* sky-800 */
}
@utility btn { @apply inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium shadow-sm transition cursor-pointer disabled:opacity-50; } @utility btn { @apply inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium shadow-sm transition cursor-pointer disabled:opacity-50; }
@utility btn-primary { @apply btn bg-sky-700 text-white hover:bg-sky-800; } @utility btn-primary { @apply btn bg-accent text-white hover:bg-accent-hover; }
@utility btn-secondary { @apply btn bg-white text-slate-700 ring-1 ring-slate-300 ring-inset hover:bg-slate-50; } @utility btn-secondary { @apply btn bg-surface text-slate-700 ring-1 ring-slate-300 ring-inset hover:bg-slate-50; }
@utility btn-danger { @apply btn bg-white text-red-700 ring-1 ring-red-300 ring-inset hover:bg-red-50; } @utility btn-danger { @apply btn bg-surface text-red-700 ring-1 ring-red-300 ring-inset hover:bg-red-50; }
@utility btn-sm { @apply px-2 py-1 text-xs; } @utility btn-sm { @apply px-2 py-1 text-xs; }
@utility link { @apply text-sky-700 hover:underline; } @utility link { @apply text-sky-700 hover:underline; }
@utility card { @apply rounded-lg bg-white shadow-sm ring-1 ring-slate-200; } @utility card { @apply rounded-lg bg-surface shadow-sm ring-1 ring-slate-200; }
@utility card-header { @apply flex flex-wrap items-center justify-between gap-3 border-b border-slate-200 px-4 py-3; } @utility card-header { @apply flex flex-wrap items-center justify-between gap-3 border-b border-slate-200 px-4 py-3; }
@utility card-title { @apply text-base font-semibold text-slate-900; } @utility card-title { @apply text-base font-semibold text-slate-900; }
@utility card-body { @apply p-4; } @utility card-body { @apply p-4; }
@utility label { @apply block text-sm font-medium text-slate-700 mb-1; } @utility label { @apply block text-sm font-medium text-slate-700 mb-1; }
@utility input { @apply block w-full rounded-md border-0 px-2.5 py-1.5 text-sm text-slate-900 shadow-sm ring-1 ring-slate-300 ring-inset placeholder:text-slate-400 focus:ring-2 focus:ring-sky-600 focus:outline-none bg-white; } @utility input { @apply block w-full rounded-md border-0 px-2.5 py-1.5 text-sm text-slate-900 shadow-sm ring-1 ring-slate-300 ring-inset placeholder:text-slate-400 focus:ring-2 focus:ring-sky-600 focus:outline-none bg-surface; }
@utility hint { @apply mt-1 text-xs text-slate-500; } @utility hint { @apply mt-1 text-xs text-slate-500; }
@utility field-error { @apply mt-1 text-xs text-red-600; } @utility field-error { @apply mt-1 text-xs text-red-600; }
@utility table { @utility table {
@apply min-w-full text-sm; @apply min-w-full text-sm;
& th { @apply px-3 py-2 text-left text-xs font-semibold uppercase tracking-wide text-slate-500 bg-slate-50; } & th { @apply px-3 py-2 text-xs font-semibold uppercase tracking-wide text-slate-500 bg-slate-50; }
/* Left by default, but let text-right/text-center on a header win (numeric columns). */
& th:not(.text-right, .text-center) { text-align: left; }
& td { @apply px-3 py-2 align-top text-slate-700; } & td { @apply px-3 py-2 align-top text-slate-700; }
& tbody tr { @apply border-t border-slate-100; } & tbody tr { @apply border-t border-slate-100; }
& tbody tr:hover { @apply bg-slate-50; } & tbody tr:hover { @apply bg-slate-50; }
@@ -34,3 +45,65 @@
@utility tab { @apply whitespace-nowrap border-b-2 border-transparent px-3 py-2 text-sm font-medium text-slate-500 hover:border-slate-300 hover:text-slate-700; } @utility tab { @apply whitespace-nowrap border-b-2 border-transparent px-3 py-2 text-sm font-medium text-slate-500 hover:border-slate-300 hover:text-slate-700; }
@utility tab-active { @apply border-sky-700 text-sky-700; } @utility tab-active { @apply border-sky-700 text-sky-700; }
/* ---------------------------------------------------------------------------
Dark theme: remap the palette instead of adding dark: variants everywhere.
Grays flip (light backgrounds become dark, dark text becomes light),
pale color tints become dim translucent ones, and dark colored text
(e.g. red-700) becomes its light counterpart. Set by the theme script in
the layout (<html data-theme="dark">).
------------------------------------------------------------------------- */
:root[data-theme="dark"] {
color-scheme: dark;
--color-page: oklch(15.5% 0.035 264);
--color-surface: oklch(20.8% 0.042 265.755);
--color-header: oklch(12.9% 0.042 264.695);
--color-accent: oklch(50% 0.134 242.749); /* same blue: white text stays ≥ 4.5:1 */
--color-accent-hover: oklch(54% 0.15 242);
--color-slate-50: oklch(24.5% 0.042 262);
--color-slate-100: oklch(26.5% 0.042 261);
--color-slate-200: oklch(31% 0.042 259);
--color-slate-300: oklch(42% 0.043 257.3);
--color-slate-400: oklch(58% 0.045 257);
--color-slate-500: oklch(68% 0.04 256.8);
--color-slate-600: oklch(77% 0.03 255);
--color-slate-700: oklch(86.9% 0.022 252.894);
--color-slate-800: oklch(92.9% 0.013 255.508);
--color-slate-900: oklch(96.8% 0.007 247.896);
--color-slate-950: oklch(98.4% 0.003 247.858);
--color-red-50: color-mix(in oklab, oklch(63.7% 0.237 25.331) 14%, transparent);
--color-red-100: color-mix(in oklab, oklch(63.7% 0.237 25.331) 22%, transparent);
--color-red-200: color-mix(in oklab, oklch(63.7% 0.237 25.331) 35%, transparent);
--color-red-600: oklch(70.4% 0.191 22.216); /* error text: readable on dark cards */
--color-red-700: oklch(80.8% 0.114 19.571);
--color-red-800: oklch(88.5% 0.062 18.334);
--color-red-900: oklch(93.6% 0.032 17.717);
--color-amber-50: color-mix(in oklab, oklch(76.9% 0.188 70.08) 12%, transparent);
--color-amber-100: color-mix(in oklab, oklch(76.9% 0.188 70.08) 20%, transparent);
--color-amber-200: color-mix(in oklab, oklch(76.9% 0.188 70.08) 32%, transparent);
--color-amber-700: oklch(87.9% 0.169 91.605);
--color-amber-800: oklch(92.4% 0.12 95.746);
--color-amber-900: oklch(96.2% 0.059 95.617);
--color-emerald-50: color-mix(in oklab, oklch(69.6% 0.17 162.48) 13%, transparent);
--color-emerald-100: color-mix(in oklab, oklch(69.6% 0.17 162.48) 21%, transparent);
--color-emerald-200: color-mix(in oklab, oklch(69.6% 0.17 162.48) 33%, transparent);
--color-emerald-700: oklch(84.5% 0.143 164.978);
--color-emerald-800: oklch(90.5% 0.093 164.15);
--color-emerald-900: oklch(95% 0.052 163.051);
--color-sky-50: color-mix(in oklab, oklch(68.5% 0.169 237.323) 14%, transparent);
--color-sky-100: color-mix(in oklab, oklch(68.5% 0.169 237.323) 22%, transparent);
--color-sky-200: color-mix(in oklab, oklch(68.5% 0.169 237.323) 35%, transparent);
--color-sky-700: oklch(82.8% 0.111 230.318);
--color-sky-800: oklch(90.1% 0.058 230.902);
--color-sky-900: oklch(95.1% 0.026 236.824);
--color-blue-50: color-mix(in oklab, oklch(62.3% 0.214 259.815) 14%, transparent);
--color-blue-100: color-mix(in oklab, oklch(62.3% 0.214 259.815) 22%, transparent);
--color-blue-700: oklch(80.9% 0.105 251.813);
}
+1 -1
View File
@@ -3,7 +3,7 @@ class FlightLogsController < ApplicationController
before_action :require_owner!, only: :destroy before_action :require_owner!, only: :destroy
def index def index
@flight_logs = @aircraft.flight_logs.recent_first.includes(:user) @flight_logs = @aircraft.flight_logs.recent_first.includes(:user).with_attached_track_log
@stats = FlightStats.new(@aircraft) @stats = FlightStats.new(@aircraft)
end end
+16
View File
@@ -3,3 +3,19 @@ import "@hotwired/turbo-rails"
import "controllers" import "controllers"
import "chartkick" import "chartkick"
import "Chart.bundle" import "Chart.bundle"
// Chart text and grid colors follow the light/dark theme.
function styleCharts() {
if (!window.Chart) return
const dark = document.documentElement.dataset.theme === "dark"
window.Chart.defaults.color = dark ? "#a3b1c6" : "#64748b"
window.Chart.defaults.borderColor = dark ? "rgba(148, 163, 184, 0.18)" : "rgba(100, 116, 139, 0.15)"
}
function restyleCharts() {
styleCharts()
if (window.Chartkick) window.Chartkick.eachChart((chart) => chart.redraw())
}
styleCharts()
// Charts can be created before this module runs, so restyle after each page load too.
document.addEventListener("turbo:load", restyleCharts)
window.addEventListener("theme:change", restyleCharts)
@@ -0,0 +1,50 @@
import { Controller } from "@hotwired/stimulus"
const CHOICES = ["system", "light", "dark"]
const LABELS = { system: "System", light: "Light", dark: "Dark" }
// Light / dark / follow-the-OS theme toggle. The choice is kept in
// localStorage; the layout's inline script applies it before first paint.
export default class extends Controller {
static targets = ["button"]
connect() {
this.media = window.matchMedia("(prefers-color-scheme: dark)")
this.onSystemChange = () => { if (this.choice === "system") this.apply() }
this.media.addEventListener("change", this.onSystemChange)
this.apply()
}
disconnect() {
this.media.removeEventListener("change", this.onSystemChange)
}
cycle() {
this.choice = CHOICES[(CHOICES.indexOf(this.choice) + 1) % CHOICES.length]
this.apply()
}
get choice() {
try { return localStorage.getItem("theme") || "system" } catch { return "system" }
}
set choice(value) {
try { localStorage.setItem("theme", value) } catch {}
}
apply() {
const choice = this.choice
const dark = choice === "dark" || (choice === "system" && this.media.matches)
const theme = dark ? "dark" : "light"
const changed = document.documentElement.dataset.theme !== theme
document.documentElement.dataset.theme = theme
this.element.querySelectorAll("[data-theme-icon]").forEach((icon) => {
icon.classList.toggle("hidden", icon.dataset.themeIcon !== choice)
})
const label = `Theme: ${LABELS[choice]}${choice === "system" ? ` (${theme})` : ""}`
this.element.title = label
this.element.setAttribute("aria-label", label)
if (changed) window.dispatchEvent(new CustomEvent("theme:change", { detail: { theme } }))
}
}
+1 -1
View File
@@ -48,7 +48,7 @@
data: { airport_autocomplete_target: "input", data: { airport_autocomplete_target: "input",
action: "input->airport-autocomplete#search keydown->airport-autocomplete#keydown blur->airport-autocomplete#blur" } %> action: "input->airport-autocomplete#search keydown->airport-autocomplete#keydown blur->airport-autocomplete#blur" } %>
<ul data-airport-autocomplete-target="list" role="listbox" hidden <ul data-airport-autocomplete-target="list" role="listbox" hidden
class="absolute z-20 mt-1 max-h-72 w-[min(28rem,90vw)] overflow-auto rounded-md bg-white py-1 shadow-lg ring-1 ring-slate-200"></ul> class="absolute z-20 mt-1 max-h-72 w-[min(28rem,90vw)] overflow-auto rounded-md bg-surface py-1 shadow-lg ring-1 ring-slate-200"></ul>
<p class="hint min-h-4" data-airport-autocomplete-target="hint"></p> <p class="hint min-h-4" data-airport-autocomplete-target="hint"></p>
</div> </div>
<% if u.suggestion %><div class="mt-2 text-xs text-sky-800">Suggested: <%= u.suggestion.name %>, <%= u.suggestion.place %> (letters swapped?)</div><% end %> <% if u.suggestion %><div class="mt-2 text-xs text-sky-800">Suggested: <%= u.suggestion.name %>, <%= u.suggestion.place %> (letters swapped?)</div><% end %>
+11 -8
View File
@@ -6,18 +6,21 @@
<% if @flight_logs.any? %> <% if @flight_logs.any? %>
<div class="overflow-x-auto"> <div class="overflow-x-auto">
<table class="table"> <table class="table">
<thead><tr><th>Date</th><th>Route</th><th class="text-right">Tach</th><th class="text-right">Hobbs</th><th class="text-right">Oil</th><th class="text-right">Fuel</th><th>Pilot</th><th></th></tr></thead> <thead><tr><th>Date</th><th>Route</th><th class="text-right">Tach</th><th class="text-right">Hobbs</th><th class="text-right">Oil (qt)</th><th class="text-right">Fuel (gal)</th><th class="pl-6">Pilot</th></tr></thead>
<tbody> <tbody>
<% blank = tag.span("—", class: "text-slate-300") %>
<% @flight_logs.each do |fl| %> <% @flight_logs.each do |fl| %>
<tr> <tr>
<td class="whitespace-nowrap"><%= link_to fl.date, aircraft_flight_log_path(@aircraft, fl), class: "link" %></td> <td class="whitespace-nowrap"><%= link_to fl.date, aircraft_flight_log_path(@aircraft, fl), class: "link" %></td>
<td><%= fl.route_summary.presence || "—" %></td> <td class="whitespace-nowrap">
<td class="text-right tabular-nums"><%= hours(fl.tach_time) %></td> <%= fl.route_summary.presence || blank %>
<td class="text-right tabular-nums"><%= hours(fl.hobbs_time) %></td> <% if fl.track_log.attached? %><span class="ml-1" title="GPS track attached" aria-label="GPS track attached">📍</span><% end %>
<td class="text-right tabular-nums"><%= fl.oil_added ? "#{fl.oil_added} qt" : "" %></td> </td>
<td class="text-right tabular-nums"><%= fl.fuel_added ? "#{fl.fuel_added} gal" : "" %></td> <td class="text-right tabular-nums"><%= fl.tach_time ? hours(fl.tach_time) : blank %></td>
<td class="text-xs"><%= fl.user&.display_name %></td> <td class="text-right tabular-nums"><%= fl.hobbs_time ? hours(fl.hobbs_time) : blank %></td>
<td class="text-right"><%= "📍" if fl.track_log.attached? %></td> <td class="text-right tabular-nums"><%= fl.oil_added ? number_with_precision(fl.oil_added, precision: 2, strip_insignificant_zeros: true) : blank %></td>
<td class="text-right tabular-nums"><%= fl.fuel_added ? number_with_precision(fl.fuel_added, precision: 2, strip_insignificant_zeros: true) : blank %></td>
<td class="pl-6 text-slate-600"><%= fl.user&.display_name || blank %></td>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>
+7 -5
View File
@@ -1,6 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html class="h-full bg-slate-100"> <html class="h-full bg-page">
<head> <head>
<%= render "shared/theme_script" %>
<title><%= [content_for(:title), "Simple Aircraft Manager"].compact.join(" · ") %></title> <title><%= [content_for(:title), "Simple Aircraft Manager"].compact.join(" · ") %></title>
<meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
@@ -16,7 +17,7 @@
</head> </head>
<body class="min-h-full text-slate-800"> <body class="min-h-full text-slate-800">
<header class="bg-slate-900 text-white"> <header class="bg-header text-white">
<div class="mx-auto flex max-w-7xl items-center justify-between gap-4 px-4 py-3"> <div class="mx-auto flex max-w-7xl items-center justify-between gap-4 px-4 py-3">
<%= link_to root_path, class: "flex items-center gap-2 font-semibold tracking-tight" do %> <%= link_to root_path, class: "flex items-center gap-2 font-semibold tracking-tight" do %>
<span class="text-xl">✈</span> Simple Aircraft Manager <span class="text-xl">✈</span> Simple Aircraft Manager
@@ -29,15 +30,16 @@
<summary class="flex cursor-pointer list-none items-center gap-1 hover:text-sky-300 [&::-webkit-details-marker]:hidden"> <summary class="flex cursor-pointer list-none items-center gap-1 hover:text-sky-300 [&::-webkit-details-marker]:hidden">
Admin <span aria-hidden="true" class="text-xs">▾</span> Admin <span aria-hidden="true" class="text-xs">▾</span>
</summary> </summary>
<div class="absolute right-0 z-30 mt-2 w-48 rounded-md bg-white py-1 text-slate-700 shadow-lg ring-1 ring-slate-200"> <div class="absolute right-0 z-30 mt-2 w-48 rounded-md bg-surface py-1 text-slate-700 shadow-lg ring-1 ring-slate-200">
<% [ [ "Users", admin_users_path ], [ "Component Types", admin_component_types_path ], [ "Airports", admin_airports_path ] ].each do |label, path| %> <% [ [ "Users", admin_users_path ], [ "Component Types", admin_component_types_path ], [ "Airports", admin_airports_path ] ].each do |label, path| %>
<%= link_to label, path, class: [ "block px-4 py-2 text-sm hover:bg-slate-100", ("font-semibold text-sky-700" if current_page?(path)) ] %> <%= link_to label, path, class: [ "block px-4 py-2 text-sm hover:bg-slate-100", ("font-semibold text-sky-700" if current_page?(path)) ] %>
<% end %> <% end %>
</div> </div>
</details> </details>
<% end %> <% end %>
<%= link_to current_user.display_name, edit_profile_path, class: "text-slate-300 hover:text-sky-300 hidden sm:inline" %> <%= link_to current_user.display_name, edit_profile_path, class: "text-white/70 hover:text-sky-300 hidden sm:inline" %>
<%= button_to "Sign out", session_path, method: :delete, class: "rounded bg-slate-700 px-2 py-1 hover:bg-slate-600" %> <%= render "shared/theme_toggle" %>
<%= button_to "Sign out", session_path, method: :delete, class: "rounded bg-white/10 px-2 py-1 hover:bg-white/20" %>
</nav> </nav>
<% end %> <% end %>
</div> </div>
+4 -3
View File
@@ -1,6 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html class="h-full bg-slate-100"> <html class="h-full bg-page">
<head> <head>
<%= render "shared/theme_script" %>
<title><%= [content_for(:title), "Simple Aircraft Manager"].compact.join(" · ") %></title> <title><%= [content_for(:title), "Simple Aircraft Manager"].compact.join(" · ") %></title>
<meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="robots" content="noindex, nofollow"> <meta name="robots" content="noindex, nofollow">
@@ -11,8 +12,8 @@
<%= javascript_importmap_tags %> <%= javascript_importmap_tags %>
</head> </head>
<body class="min-h-full text-slate-800"> <body class="min-h-full text-slate-800">
<header class="bg-slate-900 text-white"> <header class="bg-header text-white">
<div class="mx-auto max-w-7xl px-4 py-3 font-semibold"><span class="text-xl">✈</span> Simple Aircraft Manager</div> <div class="mx-auto flex max-w-7xl items-center justify-between px-4 py-3"><span class="font-semibold"><span class="text-xl">✈</span> Simple Aircraft Manager</span><%= render "shared/theme_toggle" %></div>
</header> </header>
<main class="mx-auto max-w-7xl px-4 py-6"> <main class="mx-auto max-w-7xl px-4 py-6">
<%= render "shared/flash" %> <%= render "shared/flash" %>
+1 -1
View File
@@ -6,6 +6,6 @@
data: { airport_autocomplete_target: "input", data: { airport_autocomplete_target: "input",
action: "input->airport-autocomplete#search keydown->airport-autocomplete#keydown blur->airport-autocomplete#blur" } %> action: "input->airport-autocomplete#search keydown->airport-autocomplete#keydown blur->airport-autocomplete#blur" } %>
<ul data-airport-autocomplete-target="list" role="listbox" hidden <ul data-airport-autocomplete-target="list" role="listbox" hidden
class="absolute z-20 mt-1 max-h-72 w-[min(28rem,90vw)] overflow-auto rounded-md bg-white py-1 shadow-lg ring-1 ring-slate-200"></ul> class="absolute z-20 mt-1 max-h-72 w-[min(28rem,90vw)] overflow-auto rounded-md bg-surface py-1 shadow-lg ring-1 ring-slate-200"></ul>
<p class="hint min-h-4" data-airport-autocomplete-target="hint"></p> <p class="hint min-h-4" data-airport-autocomplete-target="hint"></p>
</div> </div>
+11
View File
@@ -0,0 +1,11 @@
<%# Applies the saved theme before the page paints (no light flash in dark mode).
"system" (default) follows the OS setting. Set by theme_controller.js. %>
<script>
(function () {
try {
var choice = localStorage.getItem("theme") || "system";
var dark = choice === "dark" || (choice === "system" && window.matchMedia("(prefers-color-scheme: dark)").matches);
document.documentElement.dataset.theme = dark ? "dark" : "light";
} catch (e) {}
})();
</script>
+7
View File
@@ -0,0 +1,7 @@
<%# Cycles System → Light → Dark. Icons are swapped by theme_controller.js. %>
<button type="button" data-controller="theme" data-action="theme#cycle" data-theme-target="button"
class="rounded p-1 text-white/80 hover:bg-white/10 hover:text-white" title="Theme: System" aria-label="Theme: System">
<svg data-theme-icon="system" class="h-5 w-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><rect x="3" y="4" width="18" height="12" rx="2"/><path d="M8 20h8M12 16v4"/></svg>
<svg data-theme-icon="light" class="hidden h-5 w-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>
<svg data-theme-icon="dark" class="hidden h-5 w-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/></svg>
</button>
+1
View File
@@ -116,6 +116,7 @@ class PagesTest < ActionDispatch::IntegrationTest
test "flights tab shows flying stats" do test "flights tab shows flying stats" do
get aircraft_flight_logs_path(@a) 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 "h2", text: "Flight hours by month"
assert_select "dt", text: "Airports visited" assert_select "dt", text: "Airports visited"
end 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