| 1 | const variantStyles = { |
| 2 | error: { |
| 3 | backgroundColor: "var(--error-bg)", |
| 4 | border: "1px solid var(--error-border)", |
| 5 | color: "var(--error-text)", |
| 6 | }, |
| 7 | warning: { |
| 8 | backgroundColor: "var(--status-closed-bg)", |
| 9 | border: "1px solid var(--status-closed-border)", |
| 10 | color: "var(--status-closed-text)", |
| 11 | }, |
| 12 | info: { |
| 13 | backgroundColor: "var(--accent-subtle)", |
| 14 | border: "1px solid var(--accent)", |
| 15 | color: "var(--accent)", |
| 16 | }, |
| 17 | success: { |
| 18 | backgroundColor: "var(--status-open-bg)", |
| 19 | border: "1px solid var(--status-open-border)", |
| 20 | color: "var(--status-open-text)", |
| 21 | }, |
| 22 | } as const; |
| 23 | |
| 24 | export interface AlertProps extends React.HTMLAttributes<HTMLDivElement> { |
| 25 | variant?: keyof typeof variantStyles; |
| 26 | } |
| 27 | |
| 28 | export function Alert({ |
| 29 | variant = "error", |
| 30 | className = "", |
| 31 | style, |
| 32 | children, |
| 33 | ...props |
| 34 | }: AlertProps) { |
| 35 | return ( |
| 36 | <div |
| 37 | className={`text-sm px-3 py-2 ${className}`} |
| 38 | style={{ ...variantStyles[variant], ...style }} |
| 39 | {...props} |
| 40 | > |
| 41 | {children} |
| 42 | </div> |
| 43 | ); |
| 44 | } |
| 45 | |