Skip to content

Commit e2455c2

Browse files
feat(c): update some, add badge
1 parent 4bc93cb commit e2455c2

File tree

6 files changed

+112
-18
lines changed

6 files changed

+112
-18
lines changed

src/components/badge/Badge.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ const badgeVariants = cva(
77
{
88
variants: {
99
variant: {
10-
default: "bg-gray-100 text-gray-900 dark:bg-gray-800 dark:text-gray-100",
11-
secondary: "bg-gray-200 text-gray-900 dark:bg-gray-700 dark:text-gray-100",
12-
success: "bg-green-100 text-green-700 dark:bg-green-500/20 dark:text-green-300",
13-
warning: "bg-yellow-100 text-yellow-700 dark:bg-yellow-500/20 dark:text-yellow-300",
14-
destructive: "bg-red-100 text-red-700 dark:bg-red-500/20 dark:text-red-300",
15-
outline: "border border-gray-200 dark:border-gray-700",
10+
default: "bg-gray-200 text-gray-700 dark:bg-gray-800 dark:text-gray-100",
11+
secondary: "bg-gray-300 text-gray-700 dark:bg-gray-700 dark:text-gray-100",
12+
success: "bg-green-200 text-green-700 dark:bg-green-500/20 dark:text-green-300",
13+
warning: "bg-yellow-200 text-yellow-700 dark:bg-yellow-500/20 dark:text-yellow-300",
14+
destructive: "bg-red-200 text-red-700 dark:bg-red-500/20 dark:text-red-300",
15+
outline: "border-2 border-gray-400 text-gray-700 dark:border-gray-600 dark:text-gray-200",
1616
},
1717
},
1818
defaultVariants: {

src/components/table/Table.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const TableRow = React.forwardRef<
4242
<tr
4343
ref={ref}
4444
className={cn(
45-
"border-b border-gray-700 transition-colors hover:bg-gray-800/50",
45+
"border-b transition-colors hover:bg-gray-100 dark:border-gray-700 dark:hover:bg-gray-800",
4646
className
4747
)}
4848
{...props}
@@ -57,7 +57,7 @@ const TableHead = React.forwardRef<
5757
<th
5858
ref={ref}
5959
className={cn(
60-
"h-12 px-4 text-left align-middle font-medium text-gray-400 [&:has([role=checkbox])]:pr-0",
60+
"h-12 px-4 text-left align-middle font-medium text-gray-500 dark:text-gray-400 [&:has([role=checkbox])]:pr-0",
6161
className
6262
)}
6363
{...props}

src/docs/App.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { CodeEditorPage } from "./pages/components/CodeEditorPage";
3232
import { FeaturesPage } from "./pages/FeaturesPage";
3333
import { Toaster } from 'react-hot-toast';
3434
import { SchemaEditorPage } from "./pages/features/SchemaEditorPage";
35+
import { BadgePage } from "./pages/components/BadgePage";
3536

3637
export const App = () => {
3738
const [currentPage, setCurrentPage] = React.useState(() => {
@@ -118,6 +119,8 @@ export const App = () => {
118119
return <CodeEditorPage />;
119120
case "schema-editor":
120121
return <SchemaEditorPage />;
122+
case "badge":
123+
return <BadgePage />;
121124
default:
122125
return <GettingStartedPage />;
123126
}

src/docs/components/Navigation.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ export const Navigation: React.FC<NavigationProps> = ({ currentPage, onNavigate
5151
{ id: "table", label: "Table" },
5252
{ id: "tooltip", label: "Tooltip" },
5353
{ id: "accordion", label: "Accordion" },
54-
{ id: "code-editor", label: "Code Editor" }
54+
{ id: "code-editor", label: "Code Editor" },
55+
{ id: "badge", label: "Badge" },
5556
],
5657
},
5758
{
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import * as React from "react";
2+
import { ComponentDemo } from "../../components/ComponentDemo";
3+
import { PropsTable } from "../../components/PropsTable";
4+
import { Badge } from "../../../components/badge/Badge";
5+
import { Title } from "../../../components/typography/Title";
6+
7+
export const BadgePage = () => {
8+
const badgeProps = [
9+
{
10+
name: "variant",
11+
type: "'default' | 'secondary' | 'success' | 'warning' | 'destructive' | 'outline'",
12+
defaultValue: "default",
13+
description: "Controls the visual style of the badge",
14+
},
15+
{
16+
name: "className",
17+
type: "string",
18+
description: "Additional CSS classes",
19+
},
20+
];
21+
22+
return (
23+
<div className="space-y-12">
24+
<ComponentDemo
25+
title="Badge"
26+
description="A small visual indicator component for status, labels, and counts."
27+
code={`import { Badge } from "av1-c";
28+
29+
const MyComponent = () => (
30+
<Badge variant="success">
31+
Completed
32+
</Badge>
33+
);`}
34+
>
35+
<div className="flex gap-4">
36+
<Badge>Default</Badge>
37+
<Badge variant="secondary">Secondary</Badge>
38+
<Badge variant="success">Success</Badge>
39+
</div>
40+
</ComponentDemo>
41+
42+
<section>
43+
<Title level={3}>Properties</Title>
44+
<div className="mt-4">
45+
<PropsTable props={badgeProps} />
46+
</div>
47+
</section>
48+
49+
<section className="space-y-4">
50+
<Title level={3}>Examples</Title>
51+
<div className="grid grid-cols-2 gap-4">
52+
<ComponentDemo
53+
title="All Variants"
54+
description="Available badge variants"
55+
code={`<div className="space-x-2">
56+
<Badge variant="default">Default</Badge>
57+
<Badge variant="secondary">Secondary</Badge>
58+
<Badge variant="success">Success</Badge>
59+
<Badge variant="warning">Warning</Badge>
60+
<Badge variant="destructive">Destructive</Badge>
61+
<Badge variant="outline">Outline</Badge>
62+
</div>`}
63+
>
64+
<div className="space-x-2">
65+
<Badge variant="default">Default</Badge>
66+
<Badge variant="secondary">Secondary</Badge>
67+
<Badge variant="success">Success</Badge>
68+
<Badge variant="warning">Warning</Badge>
69+
<Badge variant="destructive">Destructive</Badge>
70+
<Badge variant="outline">Outline</Badge>
71+
</div>
72+
</ComponentDemo>
73+
74+
<ComponentDemo
75+
title="With Custom Styles"
76+
description="Badge with custom styling"
77+
code={`<Badge className="bg-purple-200 text-purple-800 dark:bg-purple-500/20 dark:text-purple-300">
78+
Custom
79+
</Badge>`}
80+
>
81+
<Badge className="bg-purple-200 text-purple-800 dark:bg-purple-500/20 dark:text-purple-300">
82+
Custom
83+
</Badge>
84+
</ComponentDemo>
85+
</div>
86+
</section>
87+
</div>
88+
);
89+
};

src/docs/pages/components/TablePage.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { ComponentDemo } from "../../components/ComponentDemo";
33
import { PropsTable } from "../../components/PropsTable";
44
import { Table } from "../../../components/table/Table";
55
import { Title } from "../../../components/typography/Title";
6+
import { Badge } from "../../../components/badge/Badge";
67

78
export const TablePage = () => {
89
const tableProps = [
@@ -88,12 +89,16 @@ const MyComponent = () => (
8889
<Table.Body>
8990
<Table.Row>
9091
<Table.Cell>
91-
<span className="bg-green-500/20 text-green-300 px-2 py-1 rounded-full text-xs">
92-
Active
93-
</span>
92+
<Badge variant="success">Active</Badge>
9493
</Table.Cell>
9594
<Table.Cell className="font-mono">$1,234.56</Table.Cell>
9695
</Table.Row>
96+
<Table.Row>
97+
<Table.Cell>
98+
<Badge variant="warning">Pending</Badge>
99+
</Table.Cell>
100+
<Table.Cell className="font-mono">$567.89</Table.Cell>
101+
</Table.Row>
97102
</Table.Body>
98103
</Table>`}
99104
>
@@ -107,17 +112,13 @@ const MyComponent = () => (
107112
<Table.Body>
108113
<Table.Row>
109114
<Table.Cell>
110-
<span className="bg-green-500/20 text-green-300 px-2 py-1 rounded-full text-xs">
111-
Active
112-
</span>
115+
<Badge variant="success">Active</Badge>
113116
</Table.Cell>
114117
<Table.Cell className="font-mono">$1,234.56</Table.Cell>
115118
</Table.Row>
116119
<Table.Row>
117120
<Table.Cell>
118-
<span className="bg-amber-500/20 text-amber-300 px-2 py-1 rounded-full text-xs">
119-
Pending
120-
</span>
121+
<Badge variant="warning">Pending</Badge>
121122
</Table.Cell>
122123
<Table.Cell className="font-mono">$567.89</Table.Cell>
123124
</Table.Row>

0 commit comments

Comments
 (0)