Skip to content

Commit

Permalink
style: fix data table style
Browse files Browse the repository at this point in the history
  • Loading branch information
ogous committed Aug 16, 2024
1 parent 098f0da commit 7a2c0cf
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
8 changes: 7 additions & 1 deletion web/src/app/_DataTable/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ export function DataTable<TData, TValue>({
{table.getHeaderGroups().map((headerGroup) => (
<TableRow key={headerGroup.id} className="border-b-0">
{headerGroup.headers.map((header) => {
if (!header.column.columnDef.header) return null;
console.log("ASDSAD", (header.column.columnDef as any).colSpan);
return (
<TableHead key={header.id} className="text-sm text-black">
<TableHead
key={header.id}
className="text-sm text-black"
colSpan={(header.column.columnDef as any).colSpan}
>
{header.isPlaceholder
? null
: flexRender(
Expand Down
25 changes: 22 additions & 3 deletions web/src/app/_DataTable/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,39 @@ const AmountHeader = () => {
);
};

export const columns: ColumnDef<Transaction>[] = [
export const columns: (ColumnDef<Transaction> & { colSpan?: number })[] = [
{
accessorKey: "value",
header: "Value",
cell: ({ row }) => usdFormat(row.original.value),
},
{
id: "amount",
id: "amountFrom",
header: () => <AmountHeader />,
colSpan: 3,
cell: ({ row }) => {
return (
<div className="flex flex-row items-center gap-2">
<Token />
{row.original.amountFrom} {"->"} <Token size="small" />
{row.original.amountFrom}
</div>
);
},
},
{
id: "amountIcon",
header: undefined,
cell: () => {
return <span>{"->"}</span>;
},
},
{
id: "amountTo",
header: undefined,
cell: ({ row }) => {
return (
<div className="flex flex-row items-center gap-2">
<Token size="small" />
{row.original.amountTo}
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/ui/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const TableHead = React.forwardRef<
<th
ref={ref}
className={cn(
"h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",
"h-12 pr-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",
className,
)}
{...props}
Expand Down

0 comments on commit 7a2c0cf

Please sign in to comment.