Pages kept in a tree, each opening beside it
The list's tree option
The tree option of docs/screen-list.md, for records kept inside one another (pages under pages, folders and files, categories): not in place of the list, a page of its own beside it (src/screens/pages.tsx, its route /pages, the same frame). It draws ListPage arrangement="plain"; the chooser (agent/layout-chooser.md) names the others, the same slots. By hand: copy the file below whole, then add the two lines of the app block to App.tsx (its import beside the screens', its route after the last) and the frame block's row to the frame's NAVIGATION (docs/screen-frame.md), before Settings. node goop/agent/start.mjs list:tree does all three.
tree: the pages in a TreeView, the chosen one beside it
The page's heading over the theme's TreeView (docs/data-parts.md): a row a page, a page holding others a folder (its folder icon, folder-open while it is open, and its count of pages as meta); the first level opens at first. Choosing a row (a press, or Enter or Space on it) opens that page in a RecordPeek beside the tree, kept in the URL (?peek=<id>; your router: useRecordPeek({ adapter })), its row marked chosen; choosing it again closes it, ↑ ↓ in the panel step through the pages in the tree's order. The tree's own keys move and fold it (the arrows, Home, End, a typed letter, *): never nested lists or collapsibles of your own. A page's full page is a record you write from docs/screen-record.md (its column arrangement for long text); light, dark, phone and desktop are the parts' own: add no class for them.
`tsx tree // src/screens/pages.tsx: the pages in a tree, the one chosen open beside it import { ListPage } from '@/components/goop/patterns/list-page'; import { pageRoles } from '@/components/goop/patterns/page-body'; import { RecordPeekBody, RecordPeekHeader, RecordPeekPanel, useRecordPeek, } from '@/components/goop/patterns/record-peek'; import { MetaFacts, MetaFactsItem, MetaFactsLabel, MetaFactsValue } from '@/components/ui/goop/meta-facts'; import { PageHeader, PageHeaderTitle } from '@/components/ui/goop/page-header'; import { Prose } from '@/components/ui/goop/prose'; import { TreeView, type TreeViewItem } from '@/components/ui/goop/tree-view'; import { ScreenFrame, ScreenTopBar } from './frame';
// ---- the sample data: swap it for yours interface Page { id: string; title: string; editedBy: string; edited: string; summary: string; pages?: Page[]; } const PAGES: Page[] = [ { id: 'handbook', title: 'Handbook', editedBy: 'Teodora Valk', edited: '3 days ago', summary: 'How the team works: the week, the reviews and where things are kept.', pages: [ { id: 'how-we-plan', title: 'How we plan', editedBy: 'Teodora Valk', edited: '3 days ago', summary: 'The Monday plan, the Thursday review and who decides what.', }, { id: 'interview-guide', title: 'Interview guide', editedBy: 'Dagny Holm', edited: 'Last week', summary: 'Before, during and after an interview: consent, notes and tags.', }, ], }, { id: 'studies', title: 'Studies', editedBy: 'Ngozi Ilori', edited: 'Yesterday', summary: 'One page a study: its question, its people and what it found.', pages: [ { id: 'eastgate-library', title: 'Eastgate Library', editedBy: 'Ngozi Ilori', edited: 'Yesterday', summary: 'Eight visitors on how they find a book they cannot name.', }, { id: 'diallo-dental', title: 'Diallo Dental', editedBy: 'Cormac Foley', edited: '2 weeks ago', summary: 'Front-desk staff on booking, reminders and missed visits.', }, ], }, { id: 'release-notes', title: 'Release notes', editedBy: 'Bilal Rashed', edited: 'Today', summary: 'What changed in each release, newest first.', }, ];
// ---- the tree / The pages as the tree's rows: a page holding others is a folder, its count of pages after its name. */ const rowsOf = (pages: readonly Page[]): TreeViewItem[] => pages.map((page) => page.pages ? { id: page.id, label: page.title, icon: 'folder', openIcon: 'folder-open', meta: String(page.pages.length), children: rowsOf(page.pages), } : { id: page.id, label: page.title, icon: 'file-text' }, ); / Every page, in the tree's order. */ const everyPage = (pages: readonly Page[]): Page[] => pages.flatMap((page) => [page, ...everyPage(page.pages ?? [])]); const ALL = everyPage(PAGES);
export default function PagesScreen() { const peek = useRecordPeek(); const open = ALL.find((page) => page.id === peek.id); return ( <ScreenFrame current="/pages"> <ListPage arrangement="plain" header={<ScreenTopBar title="Pages" />} heading={ <PageHeader> <PageHeaderTitle asChild> <h1>Pages</h1> </PageHeaderTitle> </PageHeader> } collection={ // the tree on the page gutter, its rows under the heading <div className={pageRoles.inset}> <TreeView aria-label="Pages" items={rowsOf(PAGES)} defaultExpanded={PAGES.filter((page) => page.pages).map((page) => page.id)} value={peek.id ?? ''} onValueChange={(id) => (id === peek.id ? peek.close() : peek.open(id))} /> </div> } peek={{ open: open !== undefined, onOpenChange: (next) => { if (!next) peek.close(); }, records: ALL.map((page) => page.id), value: peek.id, onValueChange: peek.step, storageKey: 'pages:peek', }} record={ <RecordPeekPanel> <RecordPeekHeader title={open?.title ?? ''} /> <RecordPeekBody> {open ? ( <> <MetaFacts aria-label="Page details"> <MetaFactsItem> <MetaFactsLabel>Edited</MetaFactsLabel> <MetaFactsValue>{${open.edited} by ${open.editedBy}}</MetaFactsValue> </MetaFactsItem> {open.pages ? ( <MetaFactsItem> <MetaFactsLabel>Pages in it</MetaFactsLabel> <MetaFactsValue>{String(open.pages.length)}</MetaFactsValue> </MetaFactsItem> ) : null} </MetaFacts> <Prose>{open.summary}</Prose> </> ) : null} </RecordPeekBody> </RecordPeekPanel> } /> </ScreenFrame> ); }
```tsx app
import PagesScreen from './screens/pages';
if (page === 'pages') return <PagesScreen />;`tsx frame { words: 'Pages', path: '/pages', icon: 'file-text' },