mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-10-08 18:56:37 +08:00
66de566a00
* 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
54 lines
1.2 KiB
TypeScript
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>
|
|
);
|
|
}
|