| ... | ... | @@ -42,9 +42,13 @@ function alertChildSlot(child: React.ReactElement): string | undefined { |
| 42 | 42 | function Alert({ |
| 43 | 43 | className, |
| 44 | 44 | variant, |
| 45 | controlAlignment = "center", |
| 45 | 46 | children, |
| 46 | 47 | ...props |
| 47 | | }: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>) { |
| 48 | }: React.ComponentProps<"div"> & |
| 49 | VariantProps<typeof alertVariants> & { |
| 50 | controlAlignment?: "center" | "first-line"; |
| 51 | }) { |
| 48 | 52 | const icon: React.ReactNode[] = []; |
| 49 | 53 | const content: React.ReactNode[] = []; |
| 50 | 54 | const action: React.ReactNode[] = []; |
| ... | ... | @@ -71,9 +75,24 @@ function Alert({ |
| 71 | 75 | role="alert" |
| 72 | 76 | {...props} |
| 73 | 77 | > |
| 74 | | <div className="flex items-center gap-2"> |
| 78 | <div |
| 79 | className={cn( |
| 80 | "flex gap-2", |
| 81 | controlAlignment === "first-line" ? "items-start" : "items-center", |
| 82 | controlAlignment === "first-line" && |
| 83 | action.length > 0 && |
| 84 | "min-h-7 pt-1 sm:min-h-6 sm:pt-0.5", |
| 85 | )} |
| 86 | > |
| 75 | 87 | {icon.length > 0 && ( |
| 76 | | <div className="flex size-4 shrink-0 items-center justify-center [&>svg]:size-full"> |
| 88 | <div |
| 89 | className={cn( |
| 90 | "flex shrink-0 items-center justify-center", |
| 91 | controlAlignment === "first-line" |
| 92 | ? "h-lh w-4 [&>svg]:size-4" |
| 93 | : "size-4 [&>svg]:size-full", |
| 94 | )} |
| 95 | > |
| 77 | 96 | {icon} |
| 78 | 97 | </div> |
| 79 | 98 | )} |
| ... | ... | @@ -81,7 +100,14 @@ function Alert({ |
| 81 | 100 | <div className="flex min-w-0 flex-1 flex-col gap-0.5">{content}</div> |
| 82 | 101 | )} |
| 83 | 102 | {action.length > 0 && ( |
| 84 | | <div className="flex shrink-0 items-center self-center">{action}</div> |
| 103 | <div |
| 104 | className={cn( |
| 105 | "flex shrink-0 items-center", |
| 106 | controlAlignment === "first-line" ? "h-lh self-start" : "self-center", |
| 107 | )} |
| 108 | > |
| 109 | {action} |
| 110 | </div> |
| 85 | 111 | )} |
| 86 | 112 | </div> |
| 87 | 113 | </div> |