|
5 | 5 | InfoIcon, |
6 | 6 | OctagonXIcon, |
7 | 7 | TriangleAlertIcon, |
8 | | - XIcon, |
9 | 8 | } from "lucide-react"; |
10 | | -import { type ReactNode, useEffect, useRef, useState } from "react"; |
| 9 | +import { useEffect, useRef, useState } from "react"; |
11 | 10 | import { toast } from "sonner"; |
12 | 11 |
|
13 | 12 | import { Alert, AlertDescription, AlertTitle } from "@/registry/alert/alert"; |
@@ -106,65 +105,37 @@ export function AlertExamples() { |
106 | 105 | ); |
107 | 106 | } |
108 | 107 |
|
109 | | -function DismissibleAlert({ |
110 | | - children, |
111 | | - status, |
112 | | - visual = "outline", |
113 | | -}: { |
114 | | - children: ReactNode; |
115 | | - status: "default" | "warning" | "error"; |
116 | | - visual?: "outline" | "tinted"; |
117 | | -}) { |
118 | | - const [visible, setVisible] = useState(true); |
119 | | - if (!visible) return null; |
120 | | - return ( |
121 | | - <div className="relative"> |
122 | | - <Alert status={status} visual={visual}> |
123 | | - {children} |
124 | | - </Alert> |
125 | | - <button |
126 | | - type="button" |
127 | | - onClick={() => setVisible(false)} |
128 | | - className="absolute top-3 right-3 rounded-sm opacity-70 hover:opacity-100 transition-opacity" |
129 | | - aria-label="Dismiss" |
130 | | - > |
131 | | - <XIcon className="h-4 w-4" /> |
132 | | - </button> |
133 | | - </div> |
134 | | - ); |
135 | | -} |
136 | | - |
137 | 108 | export function AlertOutlineExamples() { |
138 | 109 | const [resetKey, setResetKey] = useState(0); |
139 | 110 |
|
140 | 111 | return ( |
141 | 112 | <div className="space-y-3" key={resetKey}> |
142 | | - <DismissibleAlert status="default"> |
| 113 | + <Alert status="default" visual="outline" dismissible> |
143 | 114 | <InfoIcon className="h-4 w-4" /> |
144 | 115 | <AlertTitle>New version available</AlertTitle> |
145 | 116 | <AlertDescription> |
146 | 117 | A new version of the platform is ready. Review the changelog for |
147 | 118 | details. |
148 | 119 | </AlertDescription> |
149 | | - </DismissibleAlert> |
| 120 | + </Alert> |
150 | 121 |
|
151 | | - <DismissibleAlert status="warning"> |
| 122 | + <Alert status="warning" visual="outline" dismissible> |
152 | 123 | <TriangleAlertIcon className="h-4 w-4" /> |
153 | 124 | <AlertTitle>API rate limit approaching</AlertTitle> |
154 | 125 | <AlertDescription> |
155 | 126 | You have used 90% of your monthly API quota. Consider upgrading your |
156 | 127 | plan. |
157 | 128 | </AlertDescription> |
158 | | - </DismissibleAlert> |
| 129 | + </Alert> |
159 | 130 |
|
160 | | - <DismissibleAlert status="error"> |
| 131 | + <Alert status="error" visual="outline" dismissible> |
161 | 132 | <OctagonXIcon className="h-4 w-4" /> |
162 | 133 | <AlertTitle>Connection failed</AlertTitle> |
163 | 134 | <AlertDescription> |
164 | 135 | Unable to reach the server. Check your network connection and try |
165 | 136 | again. |
166 | 137 | </AlertDescription> |
167 | | - </DismissibleAlert> |
| 138 | + </Alert> |
168 | 139 |
|
169 | 140 | <button |
170 | 141 | type="button" |
|
0 commit comments