Skip to content

Commit 0eb4986

Browse files
committed
feat: add column header buttons
1 parent 1ae0c57 commit 0eb4986

File tree

2 files changed

+49
-15
lines changed

2 files changed

+49
-15
lines changed

packages/ui-react/src/components/button/button.tsx

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,23 @@ const buttonVariants = cva(
1414
{
1515
variants: {
1616
color: {
17+
gray: `
18+
[--btn-text:var(--color-gray-800)]
19+
[--btn-border:var(--color-gray-400)]
20+
[--btn-bg:var(--color-gray-200)]
21+
[--btn-bg-hover:var(--color-gray-4300)]
22+
[--btn-bg-active:var(--color-gray-400)]
23+
24+
[--btn-bg-text-hover:var(--color-gray-200)]
25+
[--btn-bg-text-active:var(--color-gray-300)]
26+
`,
1727
blue: `
1828
[--btn-text:var(--color-white)]
1929
[--btn-border:var(--color-blue)]
2030
[--btn-bg:var(--color-blue)]
2131
[--btn-bg-hover:var(--color-blue-hover)]
2232
[--btn-bg-active:var(--color-blue-active)]
2333
24-
[--btn-text-border:var(--color-blue-600)]
2534
[--btn-bg-text-hover:var(--color-bluegray-100)]
2635
[--btn-bg-text-active:var(--color-bluegray-200)]
2736
`,
@@ -32,7 +41,6 @@ const buttonVariants = cva(
3241
[--btn-bg-hover:var(--color-orange-hover)]
3342
[--btn-bg-active:var(--color-orange-active)]
3443
35-
[--btn-text-border:var(--color-orange)]
3644
[--btn-bg-text-hover:var(--color-orange-100)]
3745
[--btn-bg-text-active:var(--color-orange-200)]
3846
`,
@@ -43,7 +51,6 @@ const buttonVariants = cva(
4351
[--btn-bg-hover:var(--color-red-hover)]
4452
[--btn-bg-active:var(--color-red-active)]
4553
46-
[--btn-text-border:var(--color-red)]
4754
[--btn-bg-text-hover:var(--color-red-100)]
4855
[--btn-bg-text-active:var(--color-red-200)]
4956
`,
@@ -54,7 +61,6 @@ const buttonVariants = cva(
5461
[--btn-bg-hover:var(--color-trackergreen-hover)]
5562
[--btn-bg-active:var(--color-trackergreen-active)]
5663
57-
[--btn-text-border:var(--color-trackergreen)]
5864
[--btn-bg-text-hover:var(--color-trackergreen-100)]
5965
[--btn-bg-text-active:var(--color-trackergreen-200)]
6066
`,
@@ -65,7 +71,6 @@ const buttonVariants = cva(
6571
[--btn-bg-hover:var(--color-discovererblue-hover)]
6672
[--btn-bg-active:var(--color-discovererblue-active)]
6773
68-
[--btn-text-border:var(--color-discovererblue)]
6974
[--btn-bg-text-hover:var(--color-discovererblue-100)]
7075
[--btn-bg-text-active:var(--color-discovererblue-200)]
7176
`,
@@ -76,7 +81,6 @@ const buttonVariants = cva(
7681
[--btn-bg-hover:var(--color-adventurerorange-hover)]
7782
[--btn-bg-active:var(--color-adventurerorange-active)]
7883
79-
[--btn-text-border:var(--color-adventurerorange)]
8084
[--btn-bg-text-hover:var(--color-adventurerorange-100)]
8185
[--btn-bg-text-active:var(--color-adventurerorange-200)]
8286
`,
@@ -87,7 +91,6 @@ const buttonVariants = cva(
8791
[--btn-bg-hover:var(--color-challengerpink-hover)]
8892
[--btn-bg-active:var(--color-challengerpink-active)]
8993
90-
[--btn-text-border:var(--color-challengerpink)]
9194
[--btn-bg-text-hover:var(--color-challengerpink-100)]
9295
[--btn-bg-text-active:var(--color-challengerpink-200)]
9396
`,
@@ -98,7 +101,6 @@ const buttonVariants = cva(
98101
[--btn-bg-hover:var(--color-roveryellow-hover)]
99102
[--btn-bg-active:var(--color-roveryellow-active)]
100103
101-
[--btn-text-border:var(--color-roveryellow)]
102104
[--btn-bg-text-hover:var(--color-roveryellow-100)]
103105
[--btn-bg-text-active:var(--color-roveryellow-200)]
104106
`,
@@ -129,13 +131,30 @@ const buttonVariants = cva(
129131
size: {
130132
medium: "text-base px-4 h-10 rounded-lg",
131133
small: "text-sm px-3 h-8 rounded-md",
134+
"tiny-icon": "text-sm p-1 size-6 rounded-md",
132135
},
133136
},
134137
defaultVariants: {
135138
color: "blue",
136139
variant: "contained",
137140
size: "medium",
138141
},
142+
compoundVariants: [
143+
{
144+
color: "gray",
145+
variant: "text",
146+
class: `
147+
text-(--btn-text)
148+
`,
149+
},
150+
{
151+
color: "gray",
152+
variant: "outlined",
153+
class: `
154+
text-(--btn-text)
155+
`,
156+
},
157+
],
139158
},
140159
);
141160

packages/ui-react/src/components/table/table.tsx

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ import {
22
createColumnHelper,
33
flexRender,
44
getCoreRowModel,
5+
getFilteredRowModel,
56
type Table as TanstackTable,
67
useReactTable,
78
} from "@tanstack/react-table";
9+
import { EllipsisVerticalIcon, ListFilterIcon } from "lucide-react";
810
import { type ComponentProps, memo, useMemo, useState } from "react";
911
import { cn } from "../../lib/utils.js";
12+
import { Button } from "../button/button.js";
1013
import { Card } from "../card/card.js";
1114

1215
type Attendee = {
@@ -47,6 +50,7 @@ function TableTest() {
4750
columns,
4851
columnResizeMode: "onChange",
4952
getCoreRowModel: getCoreRowModel(),
53+
getFilteredRowModel: getFilteredRowModel(),
5054
});
5155

5256
return <Table table={table} className="w-full" />;
@@ -110,12 +114,23 @@ function Table<TData>(props: Props<TData>) {
110114
width: `calc(var(--header-${header?.id}-size) * 1px)`,
111115
}}
112116
>
113-
{header.isPlaceholder
114-
? null
115-
: flexRender(
116-
header.column.columnDef.header,
117-
header.getContext(),
118-
)}
117+
<div className="flex justify-between pr-1">
118+
{header.isPlaceholder
119+
? null
120+
: flexRender(
121+
header.column.columnDef.header,
122+
header.getContext(),
123+
)}
124+
125+
<div className="flex gap-0.5">
126+
<Button size="tiny-icon" variant="text" color="gray">
127+
<ListFilterIcon />
128+
</Button>
129+
<Button size="tiny-icon" variant="text" color="gray">
130+
<EllipsisVerticalIcon />
131+
</Button>
132+
</div>
133+
</div>
119134

120135
{header.column.getCanResize() && (
121136
<div
@@ -196,4 +211,4 @@ export const MemoizedTableBody = memo(
196211
(prev, next) => prev.table.options.data === next.table.options.data,
197212
) as typeof TableBody;
198213

199-
export { TableTest, Table };
214+
export { Table, TableTest };

0 commit comments

Comments
 (0)