A list
Notes in groups, views with counts, a new-note field, a note opening in a card beside its row
This recipe draws ListPage arrangement="plain", the one arrangement Meadow draws: every control on the page's own lines, no filter row of its own.
Copy the file below whole (src/screens/notes.tsx) beside frame.tsx (docs/screen-frame.md) and swap the words for your records; keep the parts and their props. The rows are the app's notes, read from the store (docs/screen-app.md), so a note pinned or added here shows on every screen. ListPage draws, one line under the other: the views (a ToggleGroup of pills, each counting the rows it would show), the heading (the open view's name and its count) with the search and the Display menu (the order) at its end, the new-note field (CreateRow: a title and Enter add a note, which lands tinted and focused), then the notes in groups that fold (ListGroup: the pinned first). A row's title opens the note in a card beside it (RecordPeek: previous and next, the full page, Escape closes it); its … menu pins or unpins it. Light, dark, phone and desktop are the parts' own: add no class for them. Nothing found is an Empty in the list's place.
Show the code213 lines
// src/screens/notes.tsx: the notes, in groups, a note opening in a card beside its row
import { useState } from 'react';
import { ListPage } from '@/components/goop/patterns/list-page';
import {
RecordPeekBody,
RecordPeekGroup,
RecordPeekHeader,
RecordPeekItem,
RecordPeekPanel,
RecordPeekTrigger,
} from '@/components/goop/patterns/record-peek';
import { Badge } from '@/components/ui/goop/badge';
import { Button, ButtonIcon } from '@/components/ui/goop/button';
import { CreateRow, useCreateRow } from '@/components/ui/goop/create-row';
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuRadioGroup,
DropdownMenuRadioItem,
DropdownMenuTrigger,
} from '@/components/ui/goop/dropdown-menu';
import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from '@/components/ui/goop/empty';
import { IconButton, IconButtonIcon } from '@/components/ui/goop/icon-button';
import { Item, ItemContent, ItemEnd } from '@/components/ui/goop/item';
import { ListGroup, ListGroupContent, ListGroupHeader, ListGroupTitle } from '@/components/ui/goop/list-group';
import { PageHeader, PageHeaderContent, PageHeaderTitle } from '@/components/ui/goop/page-header';
import { SearchInput } from '@/components/ui/goop/search-input';
import { ToggleGroup, ToggleGroupItem } from '@/components/ui/goop/toggle-group';
import { ScreenFrame, ScreenTopBar } from './frame';
import { hrefOf } from './router';
import type { Note } from './sample';
import { useStore } from './store';
// ---- the words: swap them for yours
const ME = 'Teodora Valk';
const VIEWS = [
{ value: 'all', words: 'All' },
{ value: 'pinned', words: 'Pinned' },
{ value: 'mine', words: 'Yours' },
] as const;
type View = (typeof VIEWS)[number]['value'];
const inView = (view: View, note: Note) =>
view === 'all' || (view === 'pinned' ? note.pinned : note.owner === ME);
/** A day as a row shows it: `2026-11-23` is "23 Nov". */
const dayOf = (day: string) =>
new Date(`${day}T00:00:00Z`).toLocaleDateString('en-GB', { day: 'numeric', month: 'short', timeZone: 'UTC' });
/** The heading's count after the view's name: the quiet grey, 4 px off. */
const HEADING_COUNT = 'ms-1 font-normal text-muted-foreground';
/** A note's title, its card's trigger: the row's words, the card hanging beside them, cut where too long. */
const NOTE_TITLE = 'w-fit max-w-full min-w-0 text-lg leading-5 text-foreground';
/** A row whose note is open in the card keeps the accent wash. */
const NOTE_ROW = 'has-[[data-record-peek-item][data-state=open]]:before:bg-accent';
export default function NotesScreen() {
const { notes, updateNote, addNote } = useStore();
const [view, setView] = useState<View>('all');
const [query, setQuery] = useState('');
const [order, setOrder] = useState('changed');
const [openId, setOpenId] = useState<string | null>(null);
const create = useCreateRow({
noun: 'Note',
onCreate: ({ title }) => {
const id = `FW-${Math.max(0, ...notes.map((note) => Number(note.id.replace(/\D/g, '')) || 0)) + 1}`;
addNote({ id, title, updated: new Date().toISOString().slice(0, 10), owner: ME, pinned: false });
return id;
},
// a note the view or the search hides: the toast's View shows it
onView: () => {
setView('all');
setQuery('');
},
});
const words = query.trim().toLowerCase();
const found = notes.filter((note) => note.title.toLowerCase().includes(words));
const shown = found
.filter((note) => inView(view, note))
.sort((a, b) => (order === 'title' ? a.title.localeCompare(b.title) : b.updated.localeCompare(a.updated)));
const groups = [
{ id: 'pinned', words: 'Pinned', rows: shown.filter((note) => note.pinned) },
{ id: 'notes', words: 'Notes', rows: shown.filter((note) => !note.pinned) },
].filter((group) => group.rows.length > 0);
const open = notes.find((note) => note.id === openId);
return (
<ScreenFrame>
<ListPage
arrangement="plain"
aria-label="Notes"
header={<ScreenTopBar title="Notes" />}
views={
<ToggleGroup
type="single"
fit
aria-label="Views"
value={view}
onValueChange={(next) => next && setView(next as View)}
>
{VIEWS.map((each) => (
<ToggleGroupItem
key={each.value}
value={each.value}
count={found.filter((note) => inView(each.value, note)).length}
>
{each.words}
</ToggleGroupItem>
))}
</ToggleGroup>
}
heading={
<PageHeader>
<PageHeaderContent>
<PageHeaderTitle asChild>
<h1>
{VIEWS.find((each) => each.value === view)?.words}
<span className={HEADING_COUNT}>{shown.length}</span>
</h1>
</PageHeaderTitle>
</PageHeaderContent>
</PageHeader>
}
filters={
<>
<SearchInput
label="Search notes"
placeholder="Search"
value={query}
onChange={(event) => setQuery(event.currentTarget.value)}
/>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost">
<ButtonIcon icon="sliders-horizontal" />
Display
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" aria-label="Display">
<DropdownMenuRadioGroup value={order} onValueChange={setOrder}>
<DropdownMenuRadioItem value="changed">Last changed first</DropdownMenuRadioItem>
<DropdownMenuRadioItem value="title">By title</DropdownMenuRadioItem>
</DropdownMenuRadioGroup>
</DropdownMenuContent>
</DropdownMenu>
</>
}
primaryAction={<CreateRow {...create.row} open label="New note" placeholder="New note" hideIcon />}
collection={
groups.length === 0 ? (
<Empty variant="outline">
<EmptyHeader>
<EmptyTitle>No note matches.</EmptyTitle>
<EmptyDescription>Try other words, or all notes.</EmptyDescription>
</EmptyHeader>
</Empty>
) : (
groups.map((group) => (
<ListGroup key={group.id} collapsible caretLabel={`Fold ${group.words}`}>
<ListGroupHeader>
<ListGroupTitle>{group.words}</ListGroupTitle>
</ListGroupHeader>
<ListGroupContent role="list" aria-label={group.words}>
{group.rows.map((note) => (
<Item key={note.id} variant="line" role="listitem" {...create.landed(note.id, NOTE_ROW)}>
<ItemContent>
<RecordPeekItem value={note.id} asChild>
<RecordPeekTrigger className={NOTE_TITLE}>
<span className="min-w-0 truncate">{note.title}</span>
</RecordPeekTrigger>
</RecordPeekItem>
</ItemContent>
<ItemEnd>
<Badge variant="plain">{dayOf(note.updated)}</Badge>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<IconButton variant="ghost" size="sm" aria-label={`Actions for ${note.title}`}>
<IconButtonIcon icon="ellipsis" />
</IconButton>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" aria-label={`Actions for ${note.title}`}>
<DropdownMenuItem onSelect={() => updateNote(note.id, { pinned: !note.pinned })}>
{note.pinned ? 'Unpin' : 'Pin to the top'}
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</ItemEnd>
</Item>
))}
</ListGroupContent>
</ListGroup>
))
)
}
record={
<RecordPeekPanel>
<RecordPeekHeader title={open?.title ?? ''} description={open?.id} />
<RecordPeekBody>
<RecordPeekGroup icon="user">{open?.owner}</RecordPeekGroup>
<RecordPeekGroup icon="calendar">{open ? `Changed ${dayOf(open.updated)}` : null}</RecordPeekGroup>
</RecordPeekBody>
</RecordPeekPanel>
}
peek={{
open: open !== undefined,
onOpenChange: (next) => next || setOpenId(null),
records: shown.map((note) => note.id),
value: openId,
onValueChange: setOpenId,
href: open ? hrefOf(`/notes/${open.id}`) : undefined,
}}
/>
</ScreenFrame>
);
}