From ff4feeca4da065bf4ff63d3c2b9215c7d30b32af Mon Sep 17 00:00:00 2001 From: David Mann Date: Tue, 17 Nov 2026 00:00:58 +0100 Subject: [PATCH] Tooltips open at once and take rich content; item icons say what they mean on hover The app's Tooltip replaces the browser title: no delay, an optional bold title over any content, TipLines for a few lines of detail, and it stays on screen at the edges. Co-Authored-By: Claude Opus 5.5 --- web/src/main.tsx | 2 +- web/src/ui/atoms/ItemIcon.tsx | 32 ++++++++++++++++---------- web/src/ui/atoms/Tooltip.tsx | 42 ++++++++++++++++++++++++++++++++--- 3 files changed, 60 insertions(+), 16 deletions(-) diff --git a/web/src/main.tsx b/web/src/main.tsx index f222b4f3..e7f9a4c8 100644 --- a/web/src/main.tsx +++ b/web/src/main.tsx @@ -47,7 +47,7 @@ function App({ api }: { api: Api }) { - + diff --git a/web/src/ui/atoms/ItemIcon.tsx b/web/src/ui/atoms/ItemIcon.tsx index 91dd877e..19ed70d3 100644 --- a/web/src/ui/atoms/ItemIcon.tsx +++ b/web/src/ui/atoms/ItemIcon.tsx @@ -1,24 +1,32 @@ import { CheckCircleIcon, CircleIcon, GitMergeIcon, GitPullRequestIcon, RadioButtonIcon, type Icon as PhosphorIcon } from "@phosphor-icons/react"; import type { ItemKind, ItemState } from "../../api/types"; import { cn } from "../cn"; +import { Tooltip } from "./Tooltip"; /** Phosphor icon and colour for an item, as GitHub shows its state. */ -function look(kind: ItemKind | null | undefined, state: ItemState | null | undefined, draft: boolean | undefined): [PhosphorIcon, string, string] { +function look(kind: ItemKind | null | undefined, state: ItemState | null | undefined, draft: boolean | undefined): [PhosphorIcon, string, string, string] { if (kind === "pr") { - if (state === "merged") return [GitMergeIcon, "text-merged", "merged PR"]; - if (state === "closed") return [GitPullRequestIcon, "text-bad", "closed PR"]; - return draft ? [GitPullRequestIcon, "text-ink/60", "draft PR"] : [GitPullRequestIcon, "text-ok", "open PR"]; + if (state === "merged") return [GitMergeIcon, "text-merged", "Merged pull request", "Its changes are in the base branch."]; + if (state === "closed") return [GitPullRequestIcon, "text-bad", "Closed pull request", "Closed without merging."]; + return draft + ? [GitPullRequestIcon, "text-ink/60", "Draft pull request", "Open, but its author marked it as not ready for review."] + : [GitPullRequestIcon, "text-ok", "Open pull request", "Proposed changes, not merged yet."]; } - if (kind === "issue") return state === "closed" ? [CheckCircleIcon, "text-merged", "closed issue"] : [RadioButtonIcon, "text-ok", "open issue"]; - return [CircleIcon, "text-ink/45", "item"]; + if (kind === "issue") + return state === "closed" + ? [CheckCircleIcon, "text-merged", "Closed issue", "Fixed, answered or closed as not planned."] + : [RadioButtonIcon, "text-ok", "Open issue", "A bug report or a request that is still open."]; + return [CircleIcon, "text-ink/45", "Item", "An issue or a pull request."]; } -/** The item's kind and state as a plain icon, as tall as one text line (`1lh`) so it sits with the text, also on wrapped titles. */ -export function ItemIcon({ kind, state, draft, className }: { kind?: ItemKind | null; state?: ItemState | null; draft?: boolean; className?: string }) { - const [Icon, tone, what] = look(kind, state, draft); +/** The item's kind and state as a plain icon, named and explained in its tip, as tall as one text line (`1lh`) so it sits with the text, also on wrapped titles. */ +export function ItemIcon({ kind, state, draft, className, tip = true }: { kind?: ItemKind | null; state?: ItemState | null; draft?: boolean; className?: string; /** false leaves out the tip (inside another tip). */ tip?: boolean }) { + const [Icon, tone, what, explain] = look(kind, state, draft); return ( - - - + + + + + ); } diff --git a/web/src/ui/atoms/Tooltip.tsx b/web/src/ui/atoms/Tooltip.tsx index 25bdb894..3ea3f247 100644 --- a/web/src/ui/atoms/Tooltip.tsx +++ b/web/src/ui/atoms/Tooltip.tsx @@ -1,15 +1,51 @@ +// The app's tooltip, in place of the browser's `title`: it opens at once (the provider in main.tsx has no delay), takes any content, so +// a tip can carry a heading, a state and a few lines of detail, and stays on screen at the edges. Keyboard focus opens it too. +// A tip is extra information: whatever it says must also be reachable without it (screen readers get the trigger's own text). import type { ReactNode } from "react"; import { Tooltip as T } from "radix-ui"; +import { cn } from "../cn"; -export function Tooltip({ label, children, side = "top" }: { label: ReactNode; children: ReactNode; side?: "top" | "right" | "bottom" | "left" }) { +export function Tooltip({ content, title, children, side = "top", align = "center", className }: { + /** The body; plain text or any markup. Nothing to show leaves the trigger as it is. */ + content?: ReactNode; + /** A bold first line. */ + title?: ReactNode; + /** One element that takes a ref (a span, a button, a link). */ + children: ReactNode; + side?: "top" | "right" | "bottom" | "left"; + align?: "start" | "center" | "end"; + className?: string; +}) { + if ((content == null || content === "" || content === false) && title == null) return <>{children}; return ( {children} - - {label} + + {title != null &&
{title}
} + {content != null && content !== false &&
{content}
}
); } + +/** Lines of detail in a tip, one per non-empty entry. */ +export function TipLines({ lines }: { lines: (ReactNode | null | undefined | false)[] }) { + const shown = lines.filter((l) => l != null && l !== false && l !== ""); + return ( + <> + {shown.map((l, i) => ( +
+ {l} +
+ ))} + + ); +}