#254
Chat history
A windowed chat history of 40 messages that loads 30 older ones at the top without moving the view.
Hand this to your AI. It names the exact library parts, timings and accessibility promises of this demo.
Build the "Chat history" pattern (@codeatlasdev/ui demo #254, display/virtual-list) in my app.
Call get_demo({ ids: ["#254"] }) first and keep its structure. It needs @codeatlasdev/[email protected].
Use: Long conversations where older messages load on scroll and the scroll position must be preserved.
Keep these library parts, with the props and tokens the demo uses:
- Button, Stack, VirtualList from "@codeatlasdev/ui"
Behaviour to keep:
- `<VirtualList {items} getKey={(m) => m.id} label="Conversation" height="18rem" {hasMore} loadingMore={loading} onloadmore={loadOlder}>`
- `async function loadOlder()` prepends a page of 30 messages with `items = [...page, ...items];`
- `<Button size="sm" variant="outlined" onclick={add}>Receive a message</Button>` appends a new row
Reduced motion: the demo handles it; keep that branch.
Keyboard: operable; keep the focus order and key handling.
Change only the copy and the data. Use the theme tokens (--ca-*), never raw colours. Library parts
- Button
@codeatlasdev/ui - Stack
@codeatlasdev/ui - VirtualList
@codeatlasdev/ui
How it is built
- `<VirtualList {items} getKey={(m) => m.id} label="Conversation" height="18rem" {hasMore} loadingMore={loading} onloadmore={loadOlder}>`
- `async function loadOlder()` prepends a page of 30 messages with `items = [...page, ...items];`
- `<Button size="sm" variant="outlined" onclick={add}>Receive a message</Button>` appends a new row
Related
Loading source.