/** * A link in running text: the icon (or the author's face, for words a person * wrote), the key, the title cut short, the status as its shape. Loading * keeps the icon, since the kind is known from the address; not available says * so in words. Hovering it shows its card; a tap opens it. */ import { Avatar } from './Avatar' import { InlineChip } from './InlineChip' import type { LinkState } from './linked' import { chosenOf } from './linked' import { LinkedIcon, LinkKey, StatusMark } from './LinkParts' import { LinkPreview } from './LinkPreview' import { SkeletonBar } from './Skeleton' export interface LinkChipProps { link: LinkState /** Hovering shows its card. Off where a card would cover what the reader is choosing from. */ preview?: boolean } export function LinkChip({ link, preview = true }: LinkChipProps) { if (link.state === 'loading') { return ( } aria-busy> ) } if (link.state === 'unavailable') { return ( }> {link.noun}, not available ) } const { linked } = link const status = chosenOf(linked.status) const said = linked.kind === 'message' && linked.author const chip = ( : } href={linked.href} className="max-w-[28ch]" > {linked.key && {linked.key}} {said ? `${said.name}: ${linked.body ?? linked.title}` : linked.title} {status?.colour && } ) return preview ? {chip} : chip }