mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
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:
1 parent
5bf682502b
commit
86aadfcf6c
13 files changed
+216
-25
No files matched your search
@@ -48,7 +48,7 @@
|
||||
data: { airport_autocomplete_target: "input",
|
||||
action: "input->airport-autocomplete#search keydown->airport-autocomplete#keydown blur->airport-autocomplete#blur" } %>
|
||||
<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>
|
||||
</div>
|
||||
<% if u.suggestion %><div class="mt-2 text-xs text-sky-800">Suggested: <%= u.suggestion.name %>, <%= u.suggestion.place %> (letters swapped?)</div><% end %>
|
||||
|
||||
@@ -6,18 +6,21 @@
|
||||
<% if @flight_logs.any? %>
|
||||
<div class="overflow-x-auto">
|
||||
<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>
|
||||
<% blank = tag.span("—", class: "text-slate-300") %>
|
||||
<% @flight_logs.each do |fl| %>
|
||||
<tr>
|
||||
<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="text-right tabular-nums"><%= hours(fl.tach_time) %></td>
|
||||
<td class="text-right tabular-nums"><%= hours(fl.hobbs_time) %></td>
|
||||
<td class="text-right tabular-nums"><%= fl.oil_added ? "#{fl.oil_added} qt" : "" %></td>
|
||||
<td class="text-right tabular-nums"><%= fl.fuel_added ? "#{fl.fuel_added} gal" : "" %></td>
|
||||
<td class="text-xs"><%= fl.user&.display_name %></td>
|
||||
<td class="text-right"><%= "📍" if fl.track_log.attached? %></td>
|
||||
<td class="whitespace-nowrap">
|
||||
<%= fl.route_summary.presence || blank %>
|
||||
<% if fl.track_log.attached? %><span class="ml-1" title="GPS track attached" aria-label="GPS track attached">📍</span><% end %>
|
||||
</td>
|
||||
<td class="text-right tabular-nums"><%= fl.tach_time ? hours(fl.tach_time) : blank %></td>
|
||||
<td class="text-right tabular-nums"><%= fl.hobbs_time ? hours(fl.hobbs_time) : blank %></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>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="h-full bg-slate-100">
|
||||
<html class="h-full bg-page">
|
||||
<head>
|
||||
<%= render "shared/theme_script" %>
|
||||
<title><%= [content_for(:title), "Simple Aircraft Manager"].compact.join(" · ") %></title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
@@ -16,7 +17,7 @@
|
||||
</head>
|
||||
|
||||
<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">
|
||||
<%= link_to root_path, class: "flex items-center gap-2 font-semibold tracking-tight" do %>
|
||||
<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">
|
||||
Admin <span aria-hidden="true" class="text-xs">▾</span>
|
||||
</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| %>
|
||||
<%= 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 %>
|
||||
</div>
|
||||
</details>
|
||||
<% end %>
|
||||
<%= link_to current_user.display_name, edit_profile_path, class: "text-slate-300 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" %>
|
||||
<%= link_to current_user.display_name, edit_profile_path, class: "text-white/70 hover:text-sky-300 hidden sm:inline" %>
|
||||
<%= 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>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="h-full bg-slate-100">
|
||||
<html class="h-full bg-page">
|
||||
<head>
|
||||
<%= render "shared/theme_script" %>
|
||||
<title><%= [content_for(:title), "Simple Aircraft Manager"].compact.join(" · ") %></title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<meta name="robots" content="noindex, nofollow">
|
||||
@@ -11,8 +12,8 @@
|
||||
<%= javascript_importmap_tags %>
|
||||
</head>
|
||||
<body class="min-h-full text-slate-800">
|
||||
<header class="bg-slate-900 text-white">
|
||||
<div class="mx-auto max-w-7xl px-4 py-3 font-semibold"><span class="text-xl">✈</span> Simple Aircraft Manager</div>
|
||||
<header class="bg-header text-white">
|
||||
<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>
|
||||
<main class="mx-auto max-w-7xl px-4 py-6">
|
||||
<%= render "shared/flash" %>
|
||||
|
||||
@@ -6,6 +6,6 @@
|
||||
data: { airport_autocomplete_target: "input",
|
||||
action: "input->airport-autocomplete#search keydown->airport-autocomplete#keydown blur->airport-autocomplete#blur" } %>
|
||||
<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>
|
||||
</div>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
Reference in new issue
Block a user