diff --git a/apps/web/src/base/ErrorState.tsx b/apps/web/src/base/ErrorState.tsx new file mode 100644 index 000000000..d6cdd08de --- /dev/null +++ b/apps/web/src/base/ErrorState.tsx @@ -0,0 +1,57 @@ +import { cn } from "@app/utils"; +import { CircleAlert } from "lucide-react"; +import type { ReactNode } from "react"; + +type ErrorStateColor = "blue" | "green" | "gray" | "orange" | "purple" | "red"; + +type ErrorStateProps = { + children?: ReactNode; + className?: string; + color?: ErrorStateColor; + icon?: ReactNode; + message?: string; +}; + +const iconColors: Record = { + blue: "text-blue-500", + green: "text-green-500", + gray: "text-gray-500", + orange: "text-orange-500", + purple: "text-purple-500", + red: "text-red-500", +}; + +/** + * A centered error state with an icon, message, and optional action. + * + * The shared primitive behind the route-level `RouteError` retryable branch and + * any view that needs a generic "something went wrong" fallback in place of its + * content. Pass the recovery affordance (e.g. a "Try again" button) as + * `children`, and override the default icon with `icon` when a different visual + * fits. + */ +export default function ErrorState({ + children, + className, + color = "red", + icon = ( +