Move collapsed records up and down with arrow buttons
Closes #17 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
10
src/app.js
10
src/app.js
@@ -230,13 +230,17 @@
|
|||||||
return [h('dt', {}, f.label), h('dd', {}, value)];
|
return [h('dt', {}, f.label), h('dd', {}, value)];
|
||||||
}
|
}
|
||||||
|
|
||||||
function viewRecord(r) {
|
function viewRecord(r, arr, i) {
|
||||||
const closed = state.collapsed.has(r.id);
|
const closed = state.collapsed.has(r.id);
|
||||||
const toggle = () => { state.collapsed[closed ? 'delete' : 'add'](r.id); render(); };
|
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' : '') },
|
return h('article', { class: 'card' + (closed ? ' collapsed' : '') },
|
||||||
h('div', { class: 'rechead' },
|
h('div', { class: 'rechead' },
|
||||||
h('h3', {}, r.title, ' ', statusBadge(r.status)),
|
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 : [
|
closed ? null : [
|
||||||
r.fields.length ? h('dl', {}, r.fields.map(viewField)) : null,
|
r.fields.length ? h('dl', {}, r.fields.map(viewField)) : null,
|
||||||
r.notes ? h('p', { class: 'notes' }, r.notes) : null,
|
r.notes ? h('p', { class: 'notes' }, r.notes) : null,
|
||||||
@@ -285,7 +289,7 @@
|
|||||||
return [
|
return [
|
||||||
s.intro ? h('p', { class: 'intro' }, s.intro) : null,
|
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 === '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 === '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,
|
s.kind === 'checklist' ? h('ul', { class: 'items' }, s.items.map((i) => (isSequence(i) ? seqItem(i) : viewItem(i)))) : null,
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -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; }
|
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; }
|
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; }
|
.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 { 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.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; }
|
.btn.link { border: 0; background: none; color: var(--accent); padding: 0 .5rem; text-decoration: underline; }
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// YYMMDD is the date, X the iteration that day (A first, B second, ...).
|
// 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`.
|
// 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])$/;
|
const VERSION_RE = /^(\d{6})([A-Z])$/;
|
||||||
export const isVersion = (v) => typeof v === 'string' && VERSION_RE.test(v);
|
export const isVersion = (v) => typeof v === 'string' && VERSION_RE.test(v);
|
||||||
|
|||||||
Reference in New Issue
Block a user