A record's page
A note: its title and words edited in place, its facts a band over them, its history
This recipe draws RecordPage arrangement="band", the one arrangement Meadow draws: the record's facts a band above its body in the one reading column, never a side panel.
Copy the file below whole (src/screens/note.tsx) beside frame.tsx (docs/screen-frame.md); its route is a note's own page (/notes/FW-121, the list's "Open full page"), read from the store (docs/screen-app.md), so a change here shows on every screen. Swap the words for your record's; keep the parts and their props. RecordPage: the trail back to the notes and the one main action (Pin, Unpin) in the page's top bar, then the title in the display type, the facts as a band (Properties variant="band": the owner a quiet Select, the day it changed in words), the note's words, then its history (Timeline, by day). The title and the words are InlineEdits: a click, Enter or F2 edits them in place, Enter (Shift+Enter breaks a line in the words) or the focus leaving keeps them, Escape puts them back. Each change joins the history at its top. A route whose note is gone says so, with the way back. Light, dark, phone and desktop are the parts' own: add no class for them.
Show the code172 lines
// src/screens/note.tsx: one note's page, its facts a band over its words, its history under them
import { useState } from 'react';
import { AppFramePanel } from '@/components/goop/patterns/app-frame';
import { PageBody } from '@/components/goop/patterns/page-body';
import { RecordPage } from '@/components/goop/patterns/record-page';
import { ActivityItemAside, ActivityItemContent, ActivityItemMedia } from '@/components/ui/goop/activity-item';
import { Button } from '@/components/ui/goop/button';
import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyTitle } from '@/components/ui/goop/empty';
import { InlineEdit } from '@/components/ui/goop/inline-edit';
import { Properties, PropertyRow } from '@/components/ui/goop/properties';
import {
Select,
SelectContent,
SelectIcon,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/ui/goop/select';
import {
groupByDay,
Timeline,
TimelineDay,
type TimelineEventKind,
TimelineEventIcon,
TimelineItem,
} from '@/components/ui/goop/timeline';
import { TopBarButton, TopBarCrumb, TopBarCrumbs } from '@/components/ui/goop/top-bar';
import { ScreenFrame, ScreenTopBar } from './frame';
import { go, hrefOf, useRoute } from './router';
import { type Note, PEOPLE } from './sample';
import { useStore } from './store';
// ---- the words: swap them for yours
interface Change {
id: string;
kind: TimelineEventKind;
words: string;
at: Date;
}
/** A day as the band shows it: `2026-11-23` is "23 Nov 2026". */
const dayOf = (day: string) =>
new Date(`${day}T00:00:00Z`).toLocaleDateString('en-GB', { dateStyle: 'medium', timeZone: 'UTC' });
/** The history a note opens with: the day it was last changed. */
const historyOf = (note: Note): Change[] => [
{ id: 'changed', kind: 'other', words: `${note.owner} changed the note`, at: new Date(`${note.updated}T09:00:00`) },
];
export default function NoteScreen() {
const id = useRoute().split('/')[2];
const { notes, updateNote } = useStore();
const note = notes.find((one) => one.id === id);
const [history, setHistory] = useState<Change[]>(() => (note ? historyOf(note) : []));
if (!note) return <NoNote />;
// a change saved to the store, and said at the top of the history
const change = (next: Partial<Omit<Note, 'id'>>, kind: TimelineEventKind, words: string) => {
updateNote(note.id, { ...next, updated: new Date().toISOString().slice(0, 10) });
setHistory((all) => [{ id: `c${all.length + 1}`, kind, words, at: new Date() }, ...all]);
};
return (
<ScreenFrame>
<RecordPage
arrangement="band"
header={<ScreenTopBar title={note.title} />}
trail={
<TopBarCrumbs>
<TopBarCrumb href={hrefOf('/notes')}>Notes</TopBarCrumb>
</TopBarCrumbs>
}
primaryAction={
<TopBarButton
variant="primary"
onClick={() =>
change({ pinned: !note.pinned }, 'other', note.pinned ? 'You unpinned it' : 'You pinned it to the top')
}
>
{note.pinned ? 'Unpin' : 'Pin'}
</TopBarButton>
}
title={
<InlineEdit
as="span"
variant="title"
multiline
label="Title"
value={note.title}
onValueChange={(words) => words.trim() && change({ title: words.trim() }, 'other', 'You renamed it')}
/>
}
properties={
<Properties variant="band" aria-label="Note">
<PropertyRow label="Owner">
{(control) => (
<Select
value={note.owner}
onValueChange={(next) =>
change({ owner: next as Note['owner'] }, 'assigned', `You gave it to ${next}`)
}
>
<SelectTrigger {...control} variant="ghost">
<SelectValue />
<SelectIcon />
</SelectTrigger>
<SelectContent searchLabel="Owner">
{PEOPLE.map((person) => (
<SelectItem key={person} value={person}>
{person}
</SelectItem>
))}
</SelectContent>
</Select>
)}
</PropertyRow>
<PropertyRow label="Changed">{dayOf(note.updated)}</PropertyRow>
</Properties>
}
body={
<InlineEdit
multiline
label="Words"
placeholder="Write the note…"
value={note.text ?? ''}
onValueChange={(words) => change({ text: words }, 'other', 'You changed its words')}
/>
}
activity={
<Timeline aria-label="History">
{groupByDay(history, { date: (one) => one.at }).map((day) => (
<TimelineDay key={day.key} label={day.label} dateTime={day.dateTime}>
{day.items.map((one) => (
<TimelineItem key={one.id}>
<ActivityItemMedia>
<TimelineEventIcon kind={one.kind} />
</ActivityItemMedia>
<ActivityItemContent>{one.words}</ActivityItemContent>
<ActivityItemAside>
<time dateTime={one.at.toISOString()}>
{one.at.toLocaleTimeString('en-GB', { timeStyle: 'short' })}
</time>
</ActivityItemAside>
</TimelineItem>
))}
</TimelineDay>
))}
</Timeline>
}
/>
</ScreenFrame>
);
}
/** A note's page whose note is gone (deleted, or an old link): said in the frame, with the way back to the notes. */
function NoNote() {
return (
<ScreenFrame current="/notes">
<AppFramePanel header={<ScreenTopBar title="Notes" />}>
<PageBody variant="wide">
<Empty>
<EmptyHeader>
<EmptyTitle asChild>
<h1>No note here</h1>
</EmptyTitle>
<EmptyDescription>It may have been deleted, or the link is old.</EmptyDescription>
</EmptyHeader>
<EmptyContent>
<Button onClick={() => go('/notes')}>Back to the notes</Button>
</EmptyContent>
</Empty>
</PageBody>
</AppFramePanel>
</ScreenFrame>
);
}