Skip to content

Commit 734ea85

Browse files
committed
added core alart component
1 parent 062eccd commit 734ea85

File tree

4 files changed

+79
-6
lines changed

4 files changed

+79
-6
lines changed

app/(sink)/demo/components/page.tsx

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import {
44
Accordion,
5+
Alert,
56
Avatar,
67
Badge,
78
Button,
@@ -12,6 +13,7 @@ import {
1213
TabsTriggerList,
1314
} from "@/packages/ui";
1415
import { Card } from "@/packages/ui/Cards/Card";
16+
import { Check, CheckCircle, CheckCircle2 } from "lucide-react";
1517
import React from "react";
1618

1719
export default function page() {
@@ -76,12 +78,28 @@ export default function page() {
7678
<Card.Description>Card Description</Card.Description>
7779
</Card.Header>
7880
</Card>
79-
<Accordion type="single" collapsible>
80-
<Accordion.Item value="item-1">
81-
<Accordion.Header>Head...</Accordion.Header>
82-
<Accordion.Content>Content...</Accordion.Content>
83-
</Accordion.Item>
84-
</Accordion>
81+
</div>
82+
83+
<div className="space-y-6">
84+
<Alert>
85+
<Alert.Title>Heads up!</Alert.Title>
86+
<Alert.Description>
87+
You can add components to your app using the cli.
88+
</Alert.Description>
89+
</Alert>
90+
91+
<Alert variant="secondary">
92+
<Alert.Title>Heads up!</Alert.Title>
93+
<Alert.Description>
94+
You can add components to your app using the cli.
95+
</Alert.Description>
96+
</Alert>
97+
<Alert variant="secondary" className="flex items-center">
98+
<CheckCircle className="h-4 w-4 mr-4" />
99+
<div>
100+
<Alert.Title>Heads up!</Alert.Title>
101+
</div>
102+
</Alert>
85103
</div>
86104
</div>
87105
);

packages/ui/Alerts/Alert.tsx

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { HtmlHTMLAttributes } from "react";
2+
import { cva, type VariantProps } from "class-variance-authority";
3+
4+
import { cn } from "@/lib/utils";
5+
import { Text } from "../Text";
6+
7+
const alertVariants = cva("relative w-full border-2 border-black p-4", {
8+
variants: {
9+
variant: {
10+
default: "bg-primary-300 text-foreground",
11+
secondary: "bg-black text-white",
12+
destructive:
13+
"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",
14+
},
15+
},
16+
defaultVariants: {
17+
variant: "default",
18+
},
19+
});
20+
21+
interface IAlertProps
22+
extends HtmlHTMLAttributes<HTMLDivElement>,
23+
VariantProps<typeof alertVariants> {}
24+
25+
const Alert = ({ className, variant, ...props }: IAlertProps) => (
26+
<div
27+
role="alert"
28+
className={cn(alertVariants({ variant }), className)}
29+
{...props}
30+
/>
31+
);
32+
Alert.displayName = "Alert";
33+
34+
interface IAlertTitleProps extends HtmlHTMLAttributes<HTMLHeadingElement> {}
35+
const AlertTitle = ({ className, ...props }: IAlertTitleProps) => (
36+
<Text as="h5" className={cn("mb-1", className)} {...props} />
37+
);
38+
AlertTitle.displayName = "AlertTitle";
39+
40+
interface IAlertDescriptionProps
41+
extends HtmlHTMLAttributes<HTMLParagraphElement> {}
42+
const AlertDescription = ({ className, ...props }: IAlertDescriptionProps) => (
43+
<div className={cn("text-muted", className)} {...props} />
44+
);
45+
46+
AlertDescription.displayName = "AlertDescription";
47+
48+
const AlertComponent = Object.assign(Alert, {
49+
Title: AlertTitle,
50+
Description: AlertDescription,
51+
});
52+
53+
export { AlertComponent as Alert };

packages/ui/Alerts/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./Alert";

packages/ui/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export * from "./Buttons";
22
export * from "./Form";
33
export * from "./Text";
44
export * from "./Accordions";
5+
export * from "./Alerts";
56
export * from "./Cards";
67
export * from "./Avatars";
78
export * from "./Badges";

0 commit comments

Comments
 (0)