Skip to content

Commit 96ba0fa

Browse files
committed
Badge ✅
1 parent 55c2060 commit 96ba0fa

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

app/page.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
Avatar,
1616
} from "@/components";
1717
import { Login } from "@/components/Login";
18+
import { Badge } from "@/components/Badges";
1819

1920
export default function page() {
2021
return (
@@ -43,6 +44,16 @@ export default function page() {
4344
<Button>Primary Button</Button>
4445
</div>
4546

47+
<div>
48+
<H3>Badges</H3>
49+
<div className="space-x-2 mt-2">
50+
<Badge>Default Badge</Badge>
51+
<Badge variant="error">Error Badge</Badge>
52+
<Badge variant="success">Success Badge</Badge>
53+
<Badge className="rounded-full">Rounded Badge</Badge>
54+
</div>
55+
</div>
56+
4657
<div>
4758
<H3>Forms</H3>
4859
<Input />

components/Badges/Badge.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React, { HTMLAttributes } from "react";
2+
3+
const variants = {
4+
default: "border-black text-black",
5+
error: "border-red-600 text-red-600",
6+
success: "border-green-600 text-green-600",
7+
};
8+
9+
interface ButtonProps extends HTMLAttributes<HTMLSpanElement> {
10+
size?: "sm" | "md" | "lg";
11+
variant?: keyof typeof variants;
12+
className?: string;
13+
}
14+
15+
export function Badge({
16+
children,
17+
size = "md",
18+
variant = "default",
19+
className = "",
20+
...props
21+
}: ButtonProps) {
22+
const sizeClasses = {
23+
sm: "px-4 py-1 text-sm",
24+
md: "px-2 py-1 text-sm",
25+
lg: "px-8 py-3 text-lg",
26+
};
27+
28+
return (
29+
<span
30+
className={`text-primary-foreground border-2 ${variants[variant]} ${sizeClasses[size]} ${className}`}
31+
{...props}
32+
>
33+
{children}
34+
</span>
35+
);
36+
}

components/Badges/index.ts

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

0 commit comments

Comments
 (0)