From d6fa04e7b053f553170eb246bbe2d928595577aa Mon Sep 17 00:00:00 2001 From: Eric Bell Date: Tue, 17 Nov 2026 16:54:47 -0500 Subject: [PATCH] Move collapsed records up and down with arrow buttons Closes #17 Co-Authored-By: Claude Sonnet 5.5 --- src/app.js | 10 +++++++--- src/style.css | 2 +- src/version.js | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/app.js b/src/app.js index 49bda89..d881262 100644 --- a/src/app.js +++ b/src/app.js @@ -230,13 +230,17 @@ return [h('dt', {}, f.label), h('dd', {}, value)]; } - function viewRecord(r) { + function viewRecord(r, arr, i) { const closed = state.collapsed.has(r.id); const toggle = () => { state.collapsed[closed ? 'delete' : 'add'](r.id); render(); }; + const shift = (dir) => { move(arr, i, dir); changed(r); render(); }; return h('article', { class: 'card' + (closed ? ' collapsed' : '') }, h('div', { class: 'rechead' }, h('h3', {}, r.title, ' ', statusBadge(r.status)), - btn(closed ? 'Expand' : 'Collapse', toggle, 'small', { 'aria-expanded': String(!closed), 'aria-label': (closed ? 'Expand ' : 'Collapse ') + r.title })), + h('span', { class: 'tools' }, + closed && i > 0 ? btn('↑', () => shift(-1), 'icon', { 'aria-label': 'Move ' + r.title + ' up' }) : null, + closed && i < arr.length - 1 ? btn('↓', () => shift(1), 'icon', { 'aria-label': 'Move ' + r.title + ' down' }) : null, + btn(closed ? 'Expand' : 'Collapse', toggle, 'small', { 'aria-expanded': String(!closed), 'aria-label': (closed ? 'Expand ' : 'Collapse ') + r.title }))), closed ? null : [ r.fields.length ? h('dl', {}, r.fields.map(viewField)) : null, r.notes ? h('p', { class: 'notes' }, r.notes) : null, @@ -285,7 +289,7 @@ return [ s.intro ? h('p', { class: 'intro' }, s.intro) : null, s.kind === 'text' ? [h('p', { class: 'body' }, s.body), (s.sequences || []).map(viewSequence)] : null, - s.kind === 'records' ? [foldBar(s), s.records.map((r) => (isSequence(r) ? viewSequence(r) : viewRecord(r)))] : null, + s.kind === 'records' ? [foldBar(s), s.records.map((r, i) => (isSequence(r) ? viewSequence(r) : viewRecord(r, s.records, i)))] : null, s.kind === 'steps' ? h('ol', { class: 'items' }, s.items.map((i) => (isSequence(i) ? seqItem(i) : viewItem(i)))) : null, s.kind === 'checklist' ? h('ul', { class: 'items' }, s.items.map((i) => (isSequence(i) ? seqItem(i) : viewItem(i)))) : null, ]; diff --git a/src/style.css b/src/style.css index d539ba4..d1588ef 100644 --- a/src/style.css +++ b/src/style.css @@ -33,7 +33,7 @@ ol.items, ul.items { padding-left: 1.4rem; } .item { margin-bottom: .75rem; } .i input, select, textarea { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: .35rem; padding: .35rem .5rem; min-width: 0; } textarea { width: 100%; display: block; } label { display: block; margin-top: .5rem; } label.check { display: inline-flex; gap: .25rem; margin: 0; align-items: center; white-space: nowrap; } .row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .5rem; } .row input:not([type=checkbox]) { flex: 1 1 10rem; } -.rechead { display: flex; justify-content: space-between; align-items: center; gap: .75rem; } .rechead h3 { margin: 0; } .card.collapsed { padding-top: .5rem; padding-bottom: .5rem; } +.rechead { display: flex; justify-content: space-between; align-items: center; gap: .75rem; } .rechead h3 { margin: 0; } .rechead .tools { display: flex; gap: .35rem; flex: none; } .card.collapsed { padding-top: .5rem; padding-bottom: .5rem; } .btn { font: inherit; padding: .35rem .8rem; border-radius: .4rem; border: 1px solid var(--line); background: var(--card); color: inherit; cursor: pointer; } .btn.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); } .btn.link { border: 0; background: none; color: var(--accent); padding: 0 .5rem; text-decoration: underline; } diff --git a/src/version.js b/src/version.js index 5e48b47..76309fc 100644 --- a/src/version.js +++ b/src/version.js @@ -2,7 +2,7 @@ // YYMMDD is the date, X the iteration that day (A first, B second, ...). // Bump with `npm run bump` (see bump-version.js). build.js strips `export`. -export const APP_VERSION = '261117A'; +export const APP_VERSION = '261117B'; const VERSION_RE = /^(\d{6})([A-Z])$/; export const isVersion = (v) => typeof v === 'string' && VERSION_RE.test(v);