diff --git a/apps/desktop/src/index.css b/apps/desktop/src/index.css index b1199a860..28811386e 100644 --- a/apps/desktop/src/index.css +++ b/apps/desktop/src/index.css @@ -1398,21 +1398,6 @@ transform-origin: bottom center; transition: transform 220ms var(--ease-snappy); } -/* An auto-dismissing card's clock, along its foot: a 1px accent hairline that drains. */ -@keyframes rc-toast-timer { - from { - transform: scaleX(1); - } - to { - transform: scaleX(0); - } -} -.rc-toast-timer { - animation-name: rc-toast-timer; - animation-timing-function: linear; - animation-fill-mode: forwards; - transform-origin: left center; -} /* * Skeletons: a quiet block where content will appear, swept by a soft diff --git a/apps/desktop/src/ui/Toaster.tsx b/apps/desktop/src/ui/Toaster.tsx index 05ae08289..667798f47 100644 --- a/apps/desktop/src/ui/Toaster.tsx +++ b/apps/desktop/src/ui/Toaster.tsx @@ -1,6 +1,8 @@ // Up to three toasts, newest in front (state/toasts.ts keeps the queue), frosted // like the composer, in the window's bottom-right corner, away from the -// transcript being read. Info and success leave after 2.5 s, errors after 5 s. +// transcript being read. At rest the cards behind the front one take its +// height and hide their text, so only their edges peek above it. Info and +// success leave after 2.5 s, errors after 5 s. // The pointer or focus on the stack, a drag, or the window in the background // stops the clock. A click anywhere on the card, ×, Escape, or a drag past 48px // sideways or 24px down dismisses; a drag never selects text anywhere. @@ -17,16 +19,26 @@ import { TOAST_DRAG_MS, } from "../lib/toastDrag"; import { dismissToast, expireToasts, setToastsPaused, type Toast, useApp } from "../state/store"; -import { nextExpiry, toastTtl } from "../state/toasts"; -import { CircleAlert, CircleCheck, Info, X } from "./icons"; -import { cx, Pill, Spinner } from "./primitives"; +import { nextExpiry } from "../state/toasts"; +import { + ArrowUpRight, + CircleAlert, + CircleCheck, + ExternalLink, + FolderOpen, + Info, + RotateCcw, + Undo2, + X, +} from "./icons"; +import { cx, Spinner } from "./primitives"; /** How far the cards behind the front one peek over its top edge, and how much smaller each is. */ const TOAST_PEEK = 6; const TOAST_SHRINK = 0.04; -/** The 8px between fanned-out cards. */ /** The stack's distance from the window's bottom and right edges. */ const TOAST_INSET = 16; +/** The 8px between fanned-out cards. */ const TOAST_GAP = 8; /** A quiet settle on the check after a spinner finishes. */ const TOAST_SETTLE_MS = 320; @@ -50,11 +62,12 @@ interface DragSession { function ToastCard({ toast, - paused, + compactHeight, onDrag, }: { toast: Toast; - paused: boolean; + /** A card behind the front one at rest: drawn at the front card's height with its text hidden. */ + compactHeight?: number; onDrag: (dragging: boolean) => void; }) { const ref = useRef(null); @@ -167,6 +180,7 @@ function ToastCard({ const timer = setTimeout(() => setSettled(false), TOAST_SETTLE_MS); return () => clearTimeout(timer); }, [spinning, toast.tone]); + const compact = compactHeight !== undefined; return (
- - {spinning ? ( - - ) : ( - +
-

{toast.text}

- {toast.action && ( - { - toast.action?.run(); - dismissToast(toast.id); - }} - > - {toast.action.label} - - )} - - {toast.persist && toast.progress !== undefined ? ( +
+ + {spinning ? ( + + ) : ( + + )} + +

{toast.text}

+
+
+ {toast.action && } + +
+
+ {toast.persist && toast.progress !== undefined && ( - ) : toast.persist ? null : ( - // An auto-dismissing card drains a 1px accent hairline along its foot; it stops with - // the clock while the stack is held by the pointer, focus or a drag. - - - )}
); } +const ACTION_ICONS: Record ReactNode> = { + Undo: Undo2, + Open: ArrowUpRight, + "Release page": ExternalLink, + Restart: RotateCcw, + "Move…": FolderOpen, +}; + +function ToastActionButton({ toast, compact }: { toast: Toast; compact: boolean }) { + const action = toast.action; + if (!action) return null; + const ActionIcon = ACTION_ICONS[action.label]; + return ( + + ); +} + export function Toaster() { const toasts = useApp((s) => s.toasts); const section = useRef(null); @@ -354,7 +388,11 @@ export function Toaster() { : `translateY(${-index * TOAST_PEEK}px) scale(${Math.max(0.9, 1 - index * TOAST_SHRINK)})`, }} > - + 0 ? heights[toasts[0]?.id ?? ""] : undefined} + onDrag={setDragging} + /> ))} @@ -380,9 +418,10 @@ function ToastSlot({ useEffect(() => { const el = ref.current; if (!el) return; - const report = () => onHeight(id, el.offsetHeight); + const body = el.querySelector("[data-toast-body]") ?? el; + const report = () => onHeight(id, body.offsetHeight); report(); - return observeSize(el, report); + return observeSize(body, report); }, [id, onHeight]); return (
diff --git a/docs/design.md b/docs/design.md index cab4c2c2b..dd28acd0a 100644 --- a/docs/design.md +++ b/docs/design.md @@ -674,14 +674,16 @@ a raw element. `?catalog` in a dev build shows them all on one page. - **Toast:** `.rc-toast rounded-2xl` (strong glass and a slight shadow), 380px wide, `py-1.5 pl-3 pr-1.5 text-callout`: an icon (info `text-fg-muted`, success `text-success`, error `text-danger`, a spinner while it has progress), the text in `text-fg` (up to 3 lines), at - most one action as a secondary pill (`h-6 bg-fill`), and a close button. + most one action as a tinted button on the close button's row (`h-6 + bg-accent/12 text-accent`, the action's icon before its label: Undo ↶, + Open ↗), and a quiet close button. The card is as tall as its text. Progress is a 2px accent bar along its foot. `Toaster` shows at most three (`state/toasts.ts` enforces the queue), newest on top: at rest only the - front card is fully shown, the others peeking 6px above it, and hovering or + front card is fully shown, the others taking its height with their text + hidden and peeking 6px above it, and hovering or focusing the stack fans them out 8px apart, upward. In the window's - bottom-right corner, 16px in, away from the transcript being read. An - auto-dismissing card drains a 1px accent hairline along its foot, which - stops with its clock; a card replaced in place from spinner to check settles + bottom-right corner, 16px in, away from the transcript being read. No timer + line: a card's clock is not drawn. A card replaced in place from spinner to check settles onto the check. The same message again refreshes its card and restarts its time instead of stacking; past three, the oldest is dropped. Info and success leave after 2.5s, errors after 5s. The pointer or focus on