import { Heading, Paragraph, SizableText, YStack } from '@hanzo/gui' import type { ReactNode } from 'react' import { measure } from './panel' import { paint } from '../material/paint' const { plain, quiet } = paint /** * A drawing, and the box to hold for it before it arrives. * * Three values because an image needs all three: the file, and the * proportions that reserve its space so nothing under it moves when it loads. * Which file is the caller's — the drawing that reads on black does not read * on white, and only the app knows which ground it is on. */ export type Art = { src: string; width: number; height: number } /** * The column the screen is set in, and how far the picture is held off its * edges. * * Measured on the reference at 360, 390, 480, 600, 640, 641, 700, 767, 768, * 900, 1024, 1200 and 1440: the column is 510 or whatever there is room for, * and the picture keeps 75 either side of it at every one of them — 360 across * in a full column. What narrows on a phone is the column, and the column is * the page's, not this screen's. */ const FRAME = 510 const INSET = 75 /** * How much deeper than an ordinary page this one starts. The reference puts * the first line 64 below the header and a page already spends 24, so this is * the difference. */ const CREST = 40 /** * The picture from the words over it, the way out from both, and the sentence * from the heading it explains. The reference's thirty, fifty and twenty. */ const APART = 30 const ROOM = 50 const UNDER = 20 /** * The line box each line sits in. * * The reference sets a status's sentence on 44 and lets the face decide the * status's own, which comes out at 57 in Zen; a heading without a status sits * on 40 and the sentence under it on 29. Said here because there is nowhere * else it can be: the engine keys leading to the size rung from a table of its * own and reads none of the ramp's `--leading-*` names. */ const LEADING = { status: 57, under: 44, heading: 40, note: 29 } /** * How wide the sentence under a heading runs. Three quarters of the * reference's column at every width it was measured at — 781 of 1042 on a * desktop, 576 of 768 at the tablet rung. Below it the sentence takes what * there is. */ const WIDE = 781 /** * A link into a screen that addresses nothing the screen serves. * * Several screens are reached by a link carrying what to read — a position, a * pool, an auction, a lot — and each answers a family of paths rather than * one. A path in the family that names nothing matches no page at all and * leaves an empty `
`: a heading, a footer and nothing between them, * which reads as a venue with nothing in it rather than as a link that does * not resolve. * * A blank page is also the one failure a sweep cannot see. An empty document * reports the same width as a full one and raises no layout complaint, so * every measurement passes on it. Saying so on screen is what turns it back * into something a person and a test both notice. * * Words, drawing and way out are the caller's. What is missing is a fact about * the caller's subject, and the sentence naming it moves with the noun in most * languages this ships in — the article, the gender and the negative all — * so there is no phrase to assemble here that would survive translation. * * The way out decides the shape. A screen that replaces the page has to offer * one, or the reader is stuck on it; a block inside a page does not, because * the page around it already has its own. So with `back` this is the whole * screen — the words centred, the drawing under them, the way out under that — * and without it a heading and a sentence in the reading column. * * The drawing is separate from that, and optional inside it: a build missing * the file still draws the screen, and drawing the block instead would be a * page changing shape over an asset a reader cannot see. */ export function Nowhere({ status, title, note, art, back, }: { /** * What the address itself answered, drawn as the largest thing on the * screen — 404, most often. Not the heading: the sentence under it is what * names the page to anybody who cannot see the size. */ status?: ReactNode title: ReactNode note?: ReactNode art?: Art /** The way back off the screen. Present, this is the screen. */ back?: ReactNode }) { if (!back) return ( // A block inside a page, so the page's own heading is already spoken for // and this one ranks under it. The screen below is the page and takes the // `h1`; a block that also claimed one would give the document two, and a // reader moving by heading would find the same page named twice. {title} {note ? ( {note} ) : null} ) return ( {status ? ( {status} ) : null} {title} {note ? ( {note} ) : null} {art ? ( /* Decorative, and said so. The lines above carry the whole of what the screen says; a drawing's name tells somebody who cannot see it nothing about where they are. The frame is its own rather than the column's, because a screen with a status and a screen without set their words in columns of different widths and draw the same picture at the same size between them. The inset is the picture's own padding: one element whose box is the frame and whose content box is the picture, so the band a reader sees and the band a measurement finds are the same band. */ ) : null} {back} ) }