Skip to content

Commit f14344a

Browse files
committed
fix(table): resolve lint and syntax errors, enforce prop order and forwardRef usage
1 parent 500fcc9 commit f14344a

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

apps/web/vibes/soul/examples/primitives/table/index.tsx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ const orders = [
4141
},
4242
];
4343

44+
function getBadgeVariant(status: string) {
45+
switch (status) {
46+
case 'Delivered':
47+
return 'success';
48+
case 'Shipped':
49+
return 'info';
50+
case 'Processing':
51+
return 'warning';
52+
default:
53+
return 'primary';
54+
}
55+
}
56+
4457
export default function Preview() {
4558
return (
4659
<div className="bg-background mx-auto max-w-4xl px-6 py-8">
@@ -70,19 +83,7 @@ export default function Preview() {
7083
<TableCell className="font-medium">{order.id}</TableCell>
7184
<TableCell>{order.date}</TableCell>
7285
<TableCell>
73-
<Badge
74-
variant={
75-
order.status === 'Delivered'
76-
? 'success'
77-
: order.status === 'Shipped'
78-
? 'info'
79-
: order.status === 'Processing'
80-
? 'warning'
81-
: 'primary'
82-
}
83-
>
84-
{order.status}
85-
</Badge>
86+
<Badge variant={getBadgeVariant(order.status)}>{order.status}</Badge>
8687
</TableCell>
8788
<TableCell className="text-right">{order.items}</TableCell>
8889
<TableCell className="text-right font-medium">{order.total}</TableCell>

apps/web/vibes/soul/primitives/table/index.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ export const Table = forwardRef<HTMLTableElement, TableProps>(({ className, ...p
2727
return (
2828
<div className="relative overflow-auto">
2929
<table
30-
ref={ref}
3130
className={clsx(
3231
'w-full caption-bottom border-collapse border-spacing-0 font-(family-name:--table-font-family,var(--font-family-body)) text-sm',
3332
className,
3433
)}
3534
{...props}
35+
ref={ref}
3636
/>
3737
</div>
3838
);
@@ -47,12 +47,12 @@ export const TableHeader = forwardRef<HTMLTableSectionElement, TableHeaderProps>
4747
({ className, ...props }, ref) => {
4848
return (
4949
<thead
50-
ref={ref}
5150
className={clsx(
5251
'bg-(--table-header-background,var(--contrast-50)) [&_tr]:border-b [&_tr]:border-(--table-border,var(--contrast-200))',
5352
className,
5453
)}
5554
{...props}
55+
ref={ref}
5656
/>
5757
);
5858
},
@@ -65,7 +65,7 @@ export type TableBodyProps = ComponentPropsWithRef<'tbody'> & {
6565

6666
export const TableBody = forwardRef<HTMLTableSectionElement, TableBodyProps>(
6767
({ className, ...props }, ref) => {
68-
return <tbody ref={ref} className={clsx('[&_tr:last-child]:border-0', className)} {...props} />;
68+
return <tbody className={clsx('[&_tr:last-child]:border-0', className)} {...props} ref={ref} />;
6969
},
7070
);
7171
TableBody.displayName = 'TableBody';
@@ -78,12 +78,12 @@ export const TableFooter = forwardRef<HTMLTableSectionElement, TableFooterProps>
7878
({ className, ...props }, ref) => {
7979
return (
8080
<tfoot
81-
ref={ref}
8281
className={clsx(
8382
'border-t border-(--table-border,var(--contrast-200)) bg-(--table-header-background,var(--contrast-50)) font-medium [&>tr]:last:border-b-0',
8483
className,
8584
)}
8685
{...props}
86+
ref={ref}
8787
/>
8888
);
8989
},
@@ -98,12 +98,12 @@ export const TableRow = forwardRef<HTMLTableRowElement, TableRowProps>(
9898
({ className, ...props }, ref) => {
9999
return (
100100
<tr
101-
ref={ref}
102101
className={clsx(
103102
'border-b border-(--table-border,var(--contrast-200)) bg-(--table-row-background,var(--background)) text-(--table-row-text,var(--foreground)) transition-colors hover:bg-(--table-row-background-hover,var(--contrast-50)) data-[state=selected]:bg-(--table-row-background-hover,var(--contrast-50))',
104103
className,
105104
)}
106105
{...props}
106+
ref={ref}
107107
/>
108108
);
109109
},
@@ -118,12 +118,12 @@ export const TableHead = forwardRef<HTMLTableCellElement, TableHeadProps>(
118118
({ className, ...props }, ref) => {
119119
return (
120120
<th
121-
ref={ref}
122121
className={clsx(
123122
'h-12 px-(--table-cell-padding,0.75rem) text-left align-middle font-medium text-(--table-header-text,var(--foreground)) [&:has([role=checkbox])]:pr-0',
124123
className,
125124
)}
126125
{...props}
126+
ref={ref}
127127
/>
128128
);
129129
},
@@ -138,12 +138,12 @@ export const TableCell = forwardRef<HTMLTableCellElement, TableCellProps>(
138138
({ className, ...props }, ref) => {
139139
return (
140140
<td
141-
ref={ref}
142141
className={clsx(
143142
'p-(--table-cell-padding,0.75rem) align-middle text-(--table-row-text,var(--foreground)) [&:has([role=checkbox])]:pr-0',
144143
className,
145144
)}
146145
{...props}
146+
ref={ref}
147147
/>
148148
);
149149
},
@@ -158,9 +158,9 @@ export const TableCaption = forwardRef<HTMLTableCaptionElement, TableCaptionProp
158158
({ className, ...props }, ref) => {
159159
return (
160160
<caption
161-
ref={ref}
162161
className={clsx('mt-4 text-sm text-(--table-row-text,var(--foreground))', className)}
163162
{...props}
163+
ref={ref}
164164
/>
165165
);
166166
},

0 commit comments

Comments
 (0)