Skip to content

Commit

Permalink
feat(Alert): warning sentiment
Browse files Browse the repository at this point in the history
  • Loading branch information
kripod committed Dec 15, 2023
1 parent 08da35e commit bb68cab
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/Alert.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import {
ExclamationTriangleIcon,
InformationCircleIcon,
XCircleIcon,
} from "@heroicons/react/24/solid";
import { clsx } from "clsx";

export interface AlertProps {
sentiment?: "neutral" | "danger";
sentiment?: "neutral" | "warning" | "danger";
children?: React.ReactNode;
}

const iconBySentiment = {
neutral: InformationCircleIcon,
danger: ExclamationTriangleIcon,
warning: ExclamationTriangleIcon,
danger: XCircleIcon,
} satisfies Record<NonNullable<AlertProps["sentiment"]>, React.ComponentType>;

export function Alert({ sentiment = "neutral", children }: AlertProps) {
Expand All @@ -23,6 +25,8 @@ export function Alert({ sentiment = "neutral", children }: AlertProps) {
className={clsx("flex gap-x-2 rounded-2xl border p-4 text-base", {
"border-ui-neutral-2 bg-ui-neutral-1 text-ui-neutral-5":
sentiment === "neutral",
"border-ui-warning-2 bg-ui-warning-1 text-ui-warning-5":
sentiment === "warning",
"border-ui-danger-2 bg-ui-danger-1 text-ui-danger-5":
sentiment === "danger",
})}
Expand Down

0 comments on commit bb68cab

Please sign in to comment.