import { SizableText, XStack, YStack } from '@hanzo/gui' import type { ReactNode } from 'react' import { away, useWalk } from './link' import { paint } from '../material/paint' /** * A drawing and a name, and the whole of it is the link. * * A row of these sits under an empty screen, which is the moment a person is * deciding where to go rather than reading anything. A word on its own gives * them nothing to aim at; the square is what the eye lands on and the whole box * is what the finger presses. * * The drawing is handed in rather than named, because what a tile is about * belongs to the screen and how a tile is built belongs here. Nothing in this * file knows what a treasury or a role looks like, and nothing there restates a * height, a corner or a gap. */ const { plain } = paint /** * The drawing is a square, and the square is the height. * * One number, because the two are the same measurement: a picture set flush * into the leading edge of a box is as tall as the box or it leaves a sliver of * ground beside it that reads as a mistake. * * Exported because whoever draws the mark has to draw it at this size, and a * second 72 written where the drawing is made is the same measurement kept in * two places. */ export const SQUARE = 72 export function Tile({ href, mark, children, }: { href: string /** The drawing, at `SQUARE` across. */ mark: ReactNode /** What it is called. */ children: ReactNode }) { const walk = useWalk() const out = away(href) return ( ) : ( ) } alignItems="center" gap="$4" height={SQUARE} // The drawing runs to the leading edge, so the corner has to cut it. overflow="hidden" borderRadius={paint.corner} // The line is what draws the tile, so the line is what answers the // pointer and the finger both. An entry in a list already makes this // move; a tile that only answered a pointer left a touch with no // acknowledgement at all. cursor="pointer" hoverStyle={paint.lift} pressStyle={paint.lift} focusVisibleStyle={paint.focus} {...paint.card} > {/* No ground of its own: the drawing covers the square, and a colour under it is one only a failed fetch could show. */} {mark} {/* Flexible and floored at nothing, which is what lets a long name wrap instead of widening its own column and dragging the row out of true. */} {children} ) }