Skip to content

Commit 71e72c6

Browse files
committed
added badge variants
1 parent d3ec030 commit 71e72c6

File tree

10 files changed

+89
-53
lines changed

10 files changed

+89
-53
lines changed

config/components.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ export const componentConfig = {
1414
name: "avatar",
1515
filePath: "packages/ui/Avatars/Avatar.tsx",
1616
},
17+
badge: {
18+
name: "badge",
19+
filePath: "packages/ui/Badges/Badge.tsx",
20+
},
1721
button: {
1822
name: "button",
1923
filePath: "packages/ui/Buttons/Button.tsx",
@@ -85,20 +89,20 @@ export const componentConfig = {
8589
filePath: "preview/components/badge-style-default.tsx",
8690
preview: lazy(() => import("@/preview/components/badge-style-default")),
8791
},
88-
"badge-style-success": {
89-
name: "badge-style-default",
90-
filePath: "preview/components/badge-style-success.tsx",
91-
preview: lazy(() => import("@/preview/components/badge-style-success")),
92+
"badge-style-variants": {
93+
name: "badge-style-variants",
94+
filePath: "preview/components/badge-style-variants.tsx",
95+
preview: lazy(() => import("@/preview/components/badge-style-variants")),
9296
},
93-
"badge-style-error": {
97+
"badge-style-rounded": {
9498
name: "badge-style-default",
95-
filePath: "preview/components/badge-style-error.tsx",
96-
preview: lazy(() => import("@/preview/components/badge-style-error")),
99+
filePath: "preview/components/badge-style-rounded.tsx",
100+
preview: lazy(() => import("@/preview/components/badge-style-rounded")),
97101
},
98-
"badge-style-filled": {
99-
name: "badge-style-default",
100-
filePath: "preview/components/badge-style-filled.tsx",
101-
preview: lazy(() => import("@/preview/components/badge-style-filled")),
102+
"badge-style-sizes": {
103+
name: "badge-style-sizes",
104+
filePath: "preview/components/badge-style-sizes.tsx",
105+
preview: lazy(() => import("@/preview/components/badge-style-sizes")),
102106
},
103107
"button-style-default": {
104108
name: "button-style-default",

content/docs/components/badge.mdx

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,51 @@
11
---
22
title: Badge
33
description: The component that looks like a button but isn't clickable!
4-
lastUpdated: 08 Oct, 2024
4+
lastUpdated: 30 Oct, 2024
55
---
66

7-
### Default
7+
<ComponentShowcase name="badge-style-default" />
8+
<br />
9+
<br />
10+
11+
## Installation
12+
13+
#### 1. Install dependencies:
14+
15+
```sh
16+
npm install class-variance-authority
17+
```
818

9-
<hr />
1019
<br />
11-
<ComponentShowcase name="badge-style-default" />
20+
21+
#### 2. Copy the code 👇 into your project:
22+
23+
<ComponentSource name="badge" />
1224
<br />
1325
<br />
1426

15-
### Success
27+
### Default
1628

1729
<hr />
1830
<br />
19-
<ComponentShowcase name="badge-style-success" />
31+
<ComponentShowcase name="badge-style-default" />
2032
<br />
2133
<br />
2234

23-
### Error
35+
### Variants
2436

2537
<hr />
2638
<br />
27-
<ComponentShowcase name="badge-style-error" />
39+
<ComponentShowcase name="badge-style-variants" />
2840
<br />
2941
<br />
3042

31-
### Filled
43+
### Rounded
3244

33-
<hr />
45+
<ComponentShowcase name="badge-style-rounded" />
46+
<br />
3447
<br />
35-
<ComponentShowcase name="badge-style-filled" />
48+
49+
### Sizes
50+
51+
<ComponentShowcase name="badge-style-sizes" />

packages/ui/Badges/Badge.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import React, { HTMLAttributes } from "react";
55
const badgeVariants = cva("font-semibold ", {
66
variants: {
77
variant: {
8-
default: "border-2 border-black text-black",
9-
error: "border-2 border-red-600 text-red-600",
10-
success: "border-2 border-green-600 text-green-600",
11-
filled: "bg-purple-200 text-purple-600 rounded",
8+
default: "bg-gray-300 text-gray-700",
9+
outline: "outline outline-2 outline-black text-black",
10+
solid: "bg-black text-white",
11+
surface: "outline outline-2 bg-primary-300 text-black",
1212
},
1313
size: {
14-
sm: "px-2 py-.5 text-xs",
15-
md: "px-2.5 py-1 text-sm",
16-
lg: "px-3 py-1.5 text-base",
14+
sm: "px-2 py-1 text-xs",
15+
md: "px-2.5 py-1.5 text-sm",
16+
lg: "px-3 py-2 text-base",
1717
},
1818
},
1919
defaultVariants: {
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1+
import { Badge } from "@/packages/ui";
2+
13
export default function BadgeStyleDefault() {
2-
return (
3-
<span className="px-2.5 py-1 text-sm font-semibold border-2 border-black text-black">
4-
Default Badge
5-
</span>
6-
);
4+
return <Badge>Default Badge</Badge>;
75
}

preview/components/badge-style-error.tsx

Lines changed: 0 additions & 7 deletions
This file was deleted.

preview/components/badge-style-filled.tsx

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Badge } from "@/packages/ui";
2+
3+
export default function BadgeStyleRounded() {
4+
return (
5+
<div className="space-x-4">
6+
<Badge variant="solid" className="rounded">
7+
Rounded
8+
</Badge>
9+
<Badge variant="solid" className="rounded-full">
10+
Full
11+
</Badge>
12+
</div>
13+
);
14+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Badge } from "@/packages/ui";
2+
3+
export default function BadgeStyleVariants() {
4+
return (
5+
<div className="space-x-4">
6+
<Badge size="sm">small</Badge>
7+
<Badge>medium</Badge>
8+
<Badge size="lg">large</Badge>
9+
</div>
10+
);
11+
}

preview/components/badge-style-success.tsx

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Badge } from "@/packages/ui";
2+
3+
export default function BadgeStyleVariants() {
4+
return (
5+
<div className="space-x-4">
6+
<Badge>Default</Badge>
7+
<Badge variant="outline">Outlined</Badge>
8+
<Badge variant="solid">Solid</Badge>
9+
<Badge variant="surface">Surface</Badge>
10+
</div>
11+
);
12+
}

0 commit comments

Comments
 (0)