// The confirmation that drops in at the top of the screen after a save. // // Two rules it exists to enforce: // 1. Success is never optimistic. The toast is driven by the server's answer // (`ok: true`), not by the click, so "Gespeichert" cannot appear over a // write that failed. // 2. An error says what went wrong. The message comes from the action's // i18n key, never from a raw provider string or an HTTP code (A.1). // // Pure/presentational: it renders the copy it is handed. Firing it is the // `useSaveToast` hook's job. import { FeatherAlertCircle, FeatherCheckCircle } from "@subframe/core"; export type SaveToastVariant = "success" | "error"; export type SaveToastProps = { variant: SaveToastVariant; /** Resolved headline, e.g. "Gespeichert". */ title: string; /** Resolved detail. On an error this is what went wrong and what to do. */ description?: string | null; }; const VARIANT = { success: { frame: "border-border-positive-subtle bg-surface-feedback-subtle-positive", icon: "text-icon-feedback-positive", title: "text-text-feedback-positive", }, error: { frame: "border-border-negative-subtle bg-surface-feedback-subtle-negative", icon: "text-icon-feedback-negative", title: "text-text-feedback-negative", }, } as const; export function SaveToast({ variant, title, description }: SaveToastProps) { const tone = VARIANT[variant]; return (
{variant === "success" ? ( ) : ( )}
{title} {description ? ( {description} ) : null}
); } export default SaveToast;