Files
flvx/vite-frontend/src/shadcn-bridge/heroui/alert.tsx
T
sagit 66de566a00 fix(frontend): stabilize multiselect behavior and UI spacing (#154)
* fix(frontend): left-align announcement logo in homepage banner

* fix(frontend): keep multiselect panels floating and preserve summaries

* fix(frontend): rebalance config card header spacing

* fix(frontend): normalize formatting and fix multiselect modal behavior

* fix(frontend): restore config divider spacing on desktop
2026-02-19 20:50:12 +08:00

54 lines
1.2 KiB
TypeScript

import * as React from "react";
import {
Alert as BaseAlert,
AlertDescription,
AlertTitle,
} from "@/components/ui/alert";
type AlertColor = "default" | "success" | "warning" | "danger" | "primary";
type AlertVariant = "solid" | "flat" | "faded" | "bordered";
interface AlertProps
extends Omit<React.ComponentProps<"div">, "color" | "title"> {
color?: AlertColor;
description?: React.ReactNode;
title?: React.ReactNode;
variant?: AlertVariant;
}
function mapVariant(color: AlertColor) {
if (color === "danger") {
return "destructive" as const;
}
if (color === "success") {
return "success" as const;
}
if (color === "warning") {
return "warning" as const;
}
return "default" as const;
}
export function Alert({
children,
color = "default",
description,
title,
variant,
...props
}: AlertProps) {
return (
<BaseAlert
className={variant === "flat" ? "bg-opacity-15" : undefined}
variant={mapVariant(color)}
{...props}
>
{title ? <AlertTitle>{title}</AlertTitle> : null}
{description ? <AlertDescription>{description}</AlertDescription> : null}
{!description && !title ? children : null}
</BaseAlert>
);
}