({ children, title, variant, className = "" }: AlertProps)
| 11 | } |
| 12 | |
| 13 | export const Alert = ({ children, title, variant, className = "" }: AlertProps) => { |
| 14 | const { t } = useTranslation() |
| 15 | const getVariantStyles = () => { |
| 16 | switch (variant) { |
| 17 | case "info": |
| 18 | return { |
| 19 | container: "bg-[var(--color-info-bg)] border-[var(--color-info-border)] border-l-4", |
| 20 | title: "text-[var(--color-info-text)]", |
| 21 | content: "text-[var(--color-info-text)]", |
| 22 | icon: "text-[var(--color-info-icon)]", |
| 23 | } |
| 24 | case "warning": |
| 25 | return { |
| 26 | container: "bg-[var(--color-warning-bg)] border-[var(--color-warning-border)] border-l-4", |
| 27 | title: "text-[var(--color-warning-text)]", |
| 28 | content: "text-[var(--color-warning-text)]", |
| 29 | icon: "text-[var(--color-warning-icon)]", |
| 30 | } |
| 31 | default: |
| 32 | return { |
| 33 | container: "", |
| 34 | title: "", |
| 35 | content: "", |
| 36 | icon: "", |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | const getIcon = () => { |
| 42 | switch (variant) { |
| 43 | case "info": |
| 44 | return <Icon name="Info" className="size-6" /> |
| 45 | case "warning": |
| 46 | return <Icon name="TriangleAlert" className="size-6" /> |
| 47 | default: |
| 48 | return null |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | const styles = getVariantStyles() |
| 53 | const defaultTitle = variant === "info" ? t("titles.good_to_know") : t("titles.warning") |
| 54 | |
| 55 | return ( |
| 56 | <div className={cn("my-6 flex flex-col gap-2 rounded-xl border p-4 md:p-6", styles.container, className)}> |
| 57 | <div className="inline-flex items-center gap-2"> |
| 58 | <div className={cn("inline-flex", styles.icon)}>{getIcon()}</div> |
| 59 | <p className={cn("mt-0 mb-0 font-semibold text-sm leading-6 sm:text-base md:text-lg", styles.title)}>{title || defaultTitle}</p> |
| 60 | </div> |
| 61 | |
| 62 | <div |
| 63 | className={cn( |
| 64 | "prose prose-xs sm:prose-sm md:prose-base max-w-none text-sm sm:text-base md:text-lg leading-6 md:leading-7 xl:leading-8", |
| 65 | styles.content |
| 66 | )} |
| 67 | > |
| 68 | {children} |
| 69 | </div> |
| 70 | </div> |
nothing calls this directly
no test coverage detected
searching dependent graphs…