Skip to content

Commit 9d8e032

Browse files
committed
added status variants
1 parent c630afd commit 9d8e032

File tree

4 files changed

+47
-3
lines changed

4 files changed

+47
-3
lines changed

config/components.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ export const componentConfig = {
5050
filePath: "preview/components/alert-style-with-icon.tsx",
5151
preview: lazy(() => import("@/preview/components/alert-style-with-icon")),
5252
},
53+
"alert-style-all-status": {
54+
name: "alert-style-all-status",
55+
filePath: "preview/components/alert-style-all-status.tsx",
56+
preview: lazy(
57+
() => import("@/preview/components/alert-style-all-status")
58+
),
59+
},
5360
"avatar-style-circle": {
5461
name: "avatar-style-circle",
5562
filePath: "preview/components/avatar-style-circle.tsx",

content/docs/components/alert.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,9 @@ npm install class-variance-authority
4242
### With Icon
4343

4444
<ComponentShowcase name="alert-style-with-icon" />
45+
<br />
46+
<br />
47+
48+
### Status
49+
50+
<ComponentShowcase name="alert-style-all-status" />

packages/ui/Alerts/Alert.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ const alertVariants = cva("relative w-full border-2 border-black p-4", {
1212
destructive:
1313
"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",
1414
},
15+
status: {
16+
error: "bg-red-300 text-red-800 border-red-800",
17+
success: "bg-green-300 text-green-800 border-green-800",
18+
warning: "bg-yellow-300 text-yellow-800 border-yellow-800",
19+
info: "bg-blue-300 text-blue-800 border-blue-800",
20+
},
1521
},
1622
defaultVariants: {
1723
variant: "default",
@@ -22,18 +28,18 @@ interface IAlertProps
2228
extends HtmlHTMLAttributes<HTMLDivElement>,
2329
VariantProps<typeof alertVariants> {}
2430

25-
const Alert = ({ className, variant, ...props }: IAlertProps) => (
31+
const Alert = ({ className, variant, status, ...props }: IAlertProps) => (
2632
<div
2733
role="alert"
28-
className={cn(alertVariants({ variant }), className)}
34+
className={cn(alertVariants({ variant, status }), className)}
2935
{...props}
3036
/>
3137
);
3238
Alert.displayName = "Alert";
3339

3440
interface IAlertTitleProps extends HtmlHTMLAttributes<HTMLHeadingElement> {}
3541
const AlertTitle = ({ className, ...props }: IAlertTitleProps) => (
36-
<Text as="h5" className={cn("mb-1", className)} {...props} />
42+
<Text as="h5" className={cn(className)} {...props} />
3743
);
3844
AlertTitle.displayName = "AlertTitle";
3945

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { Alert } from "@/packages/ui";
2+
import { CheckCircle, InfoIcon, XIcon } from "lucide-react";
3+
4+
export default function AlertAllStatus() {
5+
return (
6+
<div className="space-y-4">
7+
<Alert status="success" className="flex items-center">
8+
<CheckCircle className="h-4 w-4 mr-4" />
9+
<Alert.Title>This is a success alert!</Alert.Title>
10+
</Alert>
11+
<Alert status="info" className="flex items-center">
12+
<InfoIcon className="h-4 w-4 mr-4" />
13+
<Alert.Title>This is an info alert!</Alert.Title>
14+
</Alert>
15+
<Alert status="error" className="flex items-center">
16+
<XIcon className="h-4 w-4 mr-4" />
17+
<Alert.Title>This is an error alert!</Alert.Title>
18+
</Alert>
19+
<Alert status="warning" className="flex items-center">
20+
<InfoIcon className="h-4 w-4 mr-4" />
21+
<Alert.Title>This is an error alert!</Alert.Title>
22+
</Alert>
23+
</div>
24+
);
25+
}

0 commit comments

Comments
 (0)