mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-03 00:05:01 -05:00
* Initial * CSS lint * Test CI * Add 1v1, 2v2, and 3v3 Tags (#1771) * Initial * CSS lint * Test CI * Rename step --------- Co-authored-by: xi <104683822+ximk@users.noreply.github.com>
52 lines
1.1 KiB
TypeScript
52 lines
1.1 KiB
TypeScript
import clsx from "clsx";
|
|
import type * as React from "react";
|
|
import { assertUnreachable } from "~/utils/types";
|
|
import { AlertIcon } from "./icons/Alert";
|
|
import { CheckmarkIcon } from "./icons/Checkmark";
|
|
import { ErrorIcon } from "./icons/Error";
|
|
|
|
export type AlertVariation = "INFO" | "WARNING" | "ERROR" | "SUCCESS";
|
|
|
|
export function Alert({
|
|
children,
|
|
textClassName,
|
|
alertClassName,
|
|
variation = "INFO",
|
|
tiny = false,
|
|
}: {
|
|
children: React.ReactNode;
|
|
textClassName?: string;
|
|
alertClassName?: string;
|
|
variation?: AlertVariation;
|
|
tiny?: boolean;
|
|
}) {
|
|
return (
|
|
<div
|
|
className={clsx("alert", alertClassName, {
|
|
tiny,
|
|
warning: variation === "WARNING",
|
|
error: variation === "ERROR",
|
|
success: variation === "SUCCESS",
|
|
})}
|
|
>
|
|
<Icon variation={variation} />{" "}
|
|
<div className={textClassName}>{children}</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function Icon({ variation }: { variation: AlertVariation }) {
|
|
switch (variation) {
|
|
case "INFO":
|
|
return <AlertIcon />;
|
|
case "WARNING":
|
|
return <AlertIcon />;
|
|
case "ERROR":
|
|
return <ErrorIcon />;
|
|
case "SUCCESS":
|
|
return <CheckmarkIcon />;
|
|
default:
|
|
assertUnreachable(variation);
|
|
}
|
|
}
|