mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
Markdown notes and a phone-friendly layout
- Notes render GitHub-flavored Markdown (commonmarker, sanitized), with a Write/Preview editor; overview shows a plain-text excerpt - Phone header collapses into a menu; aircraft sections use a dropdown - Tables stack into labelled cards under 640px (opt out with .table-keep) - Fix horizontal overflow on overview and logbook; bigger touch targets; 16px inputs to stop iOS zoom Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1c6c2f88c0
commit
230a569b77
19 files changed
+331
-15
No files matched your search
@@ -90,7 +90,7 @@
|
||||
<ul class="divide-y divide-slate-100">
|
||||
<% @notes.each do |note| %>
|
||||
<li class="px-4 py-2 text-sm">
|
||||
<div><%= note.text.truncate(200) %></div>
|
||||
<div><%= markdown_excerpt note.text %></div>
|
||||
<div class="text-xs text-slate-500"><%= note.user&.display_name %> · <%= time_ago_in_words(note.created_at) %> ago <%= "· public" if note.public? %></div>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
@@ -22,11 +22,30 @@
|
||||
<body class="min-h-full text-slate-800">
|
||||
<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
|
||||
<%= link_to root_path, class: "flex items-center gap-2 font-semibold tracking-tight whitespace-nowrap" do %>
|
||||
<span class="text-xl">✈</span> <span class="hidden sm:inline">Simple Aircraft Manager</span><span class="sm:hidden" aria-label="Simple Aircraft Manager">SAM</span>
|
||||
<% end %>
|
||||
<% if current_user %>
|
||||
<nav class="flex items-center gap-4 text-sm">
|
||||
<%# Phones: Fleet, theme and one menu for the rest. %>
|
||||
<nav class="flex items-center gap-1 text-sm sm:hidden" aria-label="Main">
|
||||
<%= link_to "Fleet", root_path, class: "rounded px-3 py-2 hover:bg-white/10" %>
|
||||
<%= render "shared/theme_toggle" %>
|
||||
<details class="relative" data-controller="dropdown" data-action="click@window->dropdown#closeOutside keydown.esc@window->dropdown#close">
|
||||
<summary class="flex cursor-pointer list-none items-center rounded px-3 py-2 text-lg leading-none hover:bg-white/10 [&::-webkit-details-marker]:hidden" aria-label="Menu">☰</summary>
|
||||
<div class="absolute right-0 z-30 mt-2 w-56 rounded-md bg-surface py-1 text-slate-700 shadow-lg ring-1 ring-slate-200">
|
||||
<p class="truncate px-4 pt-2 pb-1 text-xs text-slate-500"><%= current_user.email_address %></p>
|
||||
<%= link_to "Profile", edit_profile_path, class: "block px-4 py-2.5 hover:bg-slate-100" %>
|
||||
<% if current_user.admin? %>
|
||||
<p class="border-t border-slate-100 px-4 pt-2 pb-1 text-xs font-semibold text-slate-500">Admin</p>
|
||||
<% [ [ "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.5 hover:bg-slate-100" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="border-t border-slate-100"><%= button_to "Sign out", session_path, method: :delete, class: "block w-full px-4 py-2.5 text-left hover:bg-slate-100" %></div>
|
||||
</div>
|
||||
</details>
|
||||
</nav>
|
||||
<nav class="hidden items-center gap-4 text-sm sm:flex" aria-label="Main">
|
||||
<%= link_to "Fleet", root_path, class: "hover:text-sky-300" %>
|
||||
<% if current_user.admin? %>
|
||||
<details class="relative" data-controller="dropdown" data-action="click@window->dropdown#closeOutside keydown.esc@window->dropdown#close">
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
<div class="card-header">
|
||||
<h2 class="card-title">Maintenance Logbook</h2>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<%= form_with url: aircraft_logbook_entries_path(@aircraft), method: :get, class: "flex gap-2" do |f| %>
|
||||
<%= f.search_field :q, value: @query, placeholder: "Search entries…", class: "input w-48" %>
|
||||
<%= form_with url: aircraft_logbook_entries_path(@aircraft), method: :get, class: "flex w-full flex-wrap gap-2 sm:w-auto" do |f| %>
|
||||
<%= f.search_field :q, value: @query, placeholder: "Search entries…", class: "input min-w-0 flex-1 sm:w-48 sm:flex-none" %>
|
||||
<%= f.select :log_type, LogbookEntry::LOG_TYPES.invert, { include_blank: "All logs", selected: @log_type }, class: "input w-32" %>
|
||||
<%= f.submit "Filter", class: "btn-secondary" %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,6 +1,19 @@
|
||||
<%= form_with model: note, url: note.new_record? ? aircraft_notes_path(aircraft) : aircraft_note_path(aircraft, note), class: "card card-body space-y-4 max-w-2xl" do |f| %>
|
||||
<%= f.errors_summary %>
|
||||
<%= f.field :text, as: :textarea, label: "Note", rows: 5, autofocus: true %>
|
||||
<div data-controller="markdown-editor" data-markdown-editor-url-value="<%= preview_aircraft_notes_path(aircraft) %>">
|
||||
<div class="mb-1 flex items-end justify-between gap-2">
|
||||
<%= f.label :text, "Note", class: "block text-sm font-medium text-slate-700" %>
|
||||
<div class="flex gap-1 text-xs" role="tablist">
|
||||
<button type="button" role="tab" data-markdown-editor-target="writeTab" data-action="markdown-editor#write" class="rounded px-2 py-1 font-medium">Write</button>
|
||||
<button type="button" role="tab" data-markdown-editor-target="previewTab" data-action="markdown-editor#preview" class="rounded px-2 py-1 font-medium">Preview</button>
|
||||
</div>
|
||||
</div>
|
||||
<%= f.text_area :text, rows: 8, autofocus: true, class: "input font-mono text-sm", data: { markdown_editor_target: "input" },
|
||||
placeholder: "**Bold**, *italic*, - lists, - [ ] checklists, [links](https://…), | tables |" %>
|
||||
<div data-markdown-editor-target="output" hidden class="min-h-[10rem] rounded-md p-3 text-sm ring-1 ring-slate-300"></div>
|
||||
<% if note.errors[:text].any? %><p class="mt-1 text-sm text-red-600"><%= note.errors.full_messages_for(:text).to_sentence %></p><% end %>
|
||||
<p class="hint mt-1">Markdown works: **bold**, *italic*, # headings, lists, - [ ] checklists, links, `code` and tables.</p>
|
||||
</div>
|
||||
<%= f.field :public, as: :checkbox, label: "Show on share links" %>
|
||||
<div class="flex gap-2"><%= f.submit "Save Note" %><%= link_to "Cancel", aircraft_notes_path(aircraft), class: "btn-secondary" %></div>
|
||||
<% end %>
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<ul class="divide-y divide-slate-100">
|
||||
<% @notes.each do |note| %>
|
||||
<li class="flex items-start justify-between gap-4 px-4 py-3">
|
||||
<div>
|
||||
<div class="text-sm"><%= simple_format note.text %></div>
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="text-sm"><%= markdown note.text %></div>
|
||||
<div class="mt-1 text-xs text-slate-500">
|
||||
<%= note.user&.display_name || "Unknown" %> · <%= l note.created_at, format: :short %>
|
||||
<%= "· edited" if note.edited_at %>
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<div class="card-header"><h2 class="card-title">Results (ppm)</h2>
|
||||
<span class="text-xs text-slate-500">Lab average for similar engines in (parentheses); <span class="font-semibold text-red-700">red</span> is <%= OilAnalysis::FLAG_RATIO %>× or more above it.</span></div>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="table">
|
||||
<table class="table table-keep">
|
||||
<thead>
|
||||
<tr><th>Element</th>
|
||||
<% recent.each do |a| %><th class="text-right whitespace-nowrap"><%= link_to fmt_date(a.sample_date), aircraft_oil_analysis_path(@aircraft, a), class: "link" %></th><% end %></tr>
|
||||
|
||||
@@ -18,13 +18,28 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<div class="flex w-full gap-2 sm:w-auto [&>*]:flex-1 [&>*]:justify-center sm:[&>*]:flex-none">
|
||||
<%= link_to "Log Flight", new_aircraft_flight_log_path(aircraft), class: "btn-primary" %>
|
||||
<%= link_to "Report Squawk", new_aircraft_squawk_path(aircraft), class: "btn-secondary" %>
|
||||
</div>
|
||||
</div>
|
||||
<nav class="mb-5 flex overflow-x-auto border-b border-slate-200">
|
||||
<% aircraft_tabs(aircraft).each do |label, path, names| %>
|
||||
<% tabs = aircraft_tabs(aircraft) %>
|
||||
<% current_tab = tabs.find { |_, _, names| names.include?(controller_name) } %>
|
||||
<%# Phones: the current section, with every section a tap away. %>
|
||||
<details class="relative mb-5 md:hidden" data-controller="dropdown" data-action="click@window->dropdown#closeOutside keydown.esc@window->dropdown#close">
|
||||
<summary class="flex cursor-pointer list-none items-center justify-between rounded-md bg-surface px-4 py-3 font-medium shadow-sm ring-1 ring-slate-200 [&::-webkit-details-marker]:hidden">
|
||||
<span><span class="text-xs font-normal text-slate-500">Section</span><br><%= current_tab&.first || "Overview" %></span>
|
||||
<span aria-hidden="true" class="text-slate-500">▾</span>
|
||||
</summary>
|
||||
<nav class="absolute inset-x-0 z-30 mt-2 grid grid-cols-2 gap-1 rounded-md bg-surface p-2 shadow-lg ring-1 ring-slate-200" aria-label="Aircraft sections">
|
||||
<% tabs.each do |label, path, names| %>
|
||||
<%= link_to label, path, class: [ "rounded px-3 py-2.5 text-sm hover:bg-slate-100", (names.include?(controller_name) ? "bg-slate-100 font-semibold text-sky-700" : "text-slate-700") ],
|
||||
aria: { current: (names.include?(controller_name) ? "page" : nil) } %>
|
||||
<% end %>
|
||||
</nav>
|
||||
</details>
|
||||
<nav class="mb-5 hidden flex-wrap border-b border-slate-200 md:flex" aria-label="Aircraft sections">
|
||||
<% tabs.each do |label, path, names| %>
|
||||
<%= nav_tab label, path, names.include?(controller_name) %>
|
||||
<% end %>
|
||||
</nav>
|
||||
@@ -65,7 +65,7 @@
|
||||
|
||||
<% if @notes.any? %>
|
||||
<section class="card"><div class="card-header"><h2 class="card-title">Notes</h2></div>
|
||||
<ul class="divide-y divide-slate-100"><% @notes.each do |n| %><li class="px-4 py-2 text-sm"><%= simple_format n.text %><div class="text-xs text-slate-500"><%= n.created_at.to_date %></div></li><% end %></ul></section>
|
||||
<ul class="divide-y divide-slate-100"><% @notes.each do |n| %><li class="px-4 py-2 text-sm"><%= markdown n.text %><div class="text-xs text-slate-500"><%= n.created_at.to_date %></div></li><% end %></ul></section>
|
||||
<% end %>
|
||||
|
||||
<% if @documents.any? %>
|
||||
|
||||
Reference in new issue
Block a user