read.contract holds everything the Read tab draws. It declares no resources or mutations (Exact allows those only in the root), so each screen receives its data and actions as props from app.contract. The state and actions behind those props are in Root contract wiring; the open-site sheet is in Open a site by URL.
Shapes
DocItem, DocBlock, Person, DocPage, DirItem, DirPage, AuthorPage and ReadOpenReply (L9-L88, L441-L443) mirror the TypeScript types in load.ts and markdown.ts field for field. A shape is how Contract types a source's answer, so a field added on one side must be added on the other.
Helper functions
Function | Result |
|---|---|
| |
| |
The loader's | |
Names joined with commas, each name once ("Two accounts may share a name"). | |
|
now and utc arrive by injection as readNow and readUtc, provided by the root from its minute tick. Sources never read a clock.
Components
Component | Props | Renders |
|---|---|---|
| Up to three overlapping 20 pt avatars and | |
| The messages symbol and the count, nothing at 0. | |
| A link row: 48 pt image, title, two-line summary, author names, relative date, comment count, chevron. TestIds | |
| A query result card: cover (200 pt for a banner, else 120), title, summary, face pile, date, comment count. TestIds | |
| One | |
| Injects | |
| The document page. | |
| The space tree as a modal sheet. | |
| An account's profile. |
Shared pieces Avatar and StatusLine (whose Retry button has testId retry) come from ui.contract, see Shared components and visual design.
DocBlockView by kind
Depth indents by 16 pt per level; a marker is drawn before the content; quote adds a 3 pt left border. text, heading, table and image captions use markup="markdown". code and math use the type.code font in a rounded box (testId code-block). image is doc-image. embed is a brand-bordered card (embed-card, embed-title, embed-faces). query (query-block) shows No documents yet. or the loader's error (query-empty), a card grid for the Card style (query-cards, query-banner, query-grid, query-card-{j}) or plain rows otherwise (query-item-{j}). Cards wrap on a 200 pt basis, capped by columns; zero-height spacers keep an odd last card at one column's width. button and media are links. Font and colour tokens are in Tamber design tokens.
DocScreen
Finds its page with docs.filter(d => d.ref == ref); loaded requires no error and a uid. The title falls back to Seed (home) or Document.
Header: title as a level 1 heading (doc-title; iOS draws it as the large title), open-site, open-directory, open-discussion (with the comment count from discussions), share-doc (Exact's share with page.shareUrl).
Body: a list with pull to refresh (doc-content). Not loaded: StatusLine and doc-error, or doc-loading. Loaded: doc-summary, author avatars as 44 pt links (doc-author-{k}), doc-date, doc-comment-count, doc-empty or the blocks, doc-children with child-{j} rows under "In this space", then the discussion slot.
Content is capped at 40rem wide and centred.
DirectoryScreen and AuthorScreen
The directory filters dir.items by title on the client, hides indentation while searching, and marks the row whose id equals current. It shows the spinner until dir.uid == uid, so a previous space's tree never appears under a new title. TestIds: directory-close, directory-title, directory-search, directory-list, directory-loading, directory-empty, dir-row-{i}.
The author screen shows avatar, name, short id, summary, a Home document link and a Documents section. TestIds: author-title, author-loading, author-name, author-home, author-doc-{j}.
Contract tests
read.test.contract has 12 tests against live https://hyper.media, read-only. "Assertions are structural (a title, blocks, rows exist) so edits to the published docs don't break them". They cover: the home loading; pushing a child and Back; directory open, search and row open; an author chip; an embed card and a query list; a Card query grid with face piles; rows naming authors; a failed load recovering through Retry (fail fetch then pass fetch); an hm deep link, a site URL deep link, a link that is not a document; and the document date. How these run is in Contract UI tests.
Do you like what you are reading? Subscribe to receive updates.
Unsubscribe anytime