Hover Card

View as Markdown

A preview of what a link leads to, on hover or focus, such as the person behind a mention.

Refunds over $500 still need a second approver. @Ada Lovelace can you check the ledger side, and @Ben Okafor the confirmation screen? @Priya Raman for the rollout date.

When to use

A preview of what a link leads to, on hover or focus, such as the person behind a mention. Use Tooltip instead when the hint is one short line.

Usage

import { HoverCard, HoverCardState } from "./ui/uicontext/components/HoverCard.ts"
const Message = UiSchema.TaggedEnum({ ChangedPreview: { preview: HoverCardState } })export const Mention = (h: Html.H<typeof Message.Type>, preview: HoverCardState) =>	HoverCard(h, {		state: preview,		onState: (next) => Message.ChangedPreview({ preview: next }),		card: () => h.div.children("Ada Lovelace · Staff engineer"),		view: (link) => h.p.children("Thanks ", link(h.a.attr("href", "/people/ada"), "ada").children("@Ada"), "!"),	})

Examples

Issues in release notes

A shorter delay suits a list of links people scan. Moving to the next link moves the open card at once.

  • Coupons with spaces apply again (ENG-142)
  • Invoices download as CSV from Billing (ENG-139)
  • Known issue: Québec tax on large orders (ENG-128)

API reference

Options

HoverCard options
NameTypeDefaultDescription
keystring—Names the card among others in the same view; needed for more than one.
staterequiredHoverCardState——
onStaterequired(state: HoverCardState) => Message——
cardrequired(target: string) => View.Content—What the card shows for the link with this id.
viewrequired(link: HoverCardLink) => View.Content—Draws the page; link(h.a.attr("href", …), id) marks a link that opens the card.
side"top" | "bottom"—Where the card sits; below the link by default.
delaynumber600Milliseconds the pointer rests before it opens; 600 by default.
styleStyle—StyleX styles for the card, after its own: a wider one for a pull request.

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/hover-card

Source