From 1d780ba4d6954b3b3a3f782ab79741892c713afb Mon Sep 17 00:00:00 2001 From: SerinaNya <34389622+SerinaNya@users.noreply.github.com> Date: Mon, 28 Sep 2026 14:27:32 +0800 Subject: [PATCH] refactor(transactions): extract responsive data list --- app/transactions/transactions-view.tsx | 89 +++++++++-------- components/data-list.tsx | 127 +++++++++++++++++++++++++ 2 files changed, 177 insertions(+), 39 deletions(-) create mode 100644 components/data-list.tsx diff --git a/app/transactions/transactions-view.tsx b/app/transactions/transactions-view.tsx index 14e777b..925c6ae 100644 --- a/app/transactions/transactions-view.tsx +++ b/app/transactions/transactions-view.tsx @@ -46,6 +46,7 @@ import { DropdownMenuTrigger, } from "@/components/ui/dropdown-menu" import { Input } from "@/components/ui/input" +import { DataList } from "@/components/data-list" import { Select, SelectContent, @@ -294,6 +295,7 @@ export function TransactionsView({ ) : ( - diff --git a/components/data-list.tsx b/components/data-list.tsx new file mode 100644 index 0000000..82c281d --- /dev/null +++ b/components/data-list.tsx @@ -0,0 +1,127 @@ +import * as React from "react" +import { cn } from "cn" + +// Intended consumers: transactions, channels, and accounts. + +export type DataListRootProps = React.ComponentProps<"div"> & { + columns: string +} + +function DataListRoot({ + className, + columns, + style, + ...props +}: DataListRootProps) { + return ( +
+ ) +} + +function DataListHeader({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +export type DataListHeadProps = React.ComponentProps<"span"> & { + align?: "left" | "center" | "right" +} + +function DataListHead({ + align = "left", + className, + ...props +}: DataListHeadProps) { + return ( + + ) +} + +function DataListBody({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function DataListRow({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +export type DataListCellProps = React.ComponentProps<"div"> & { + label?: React.ReactNode + labelClassName?: string + align?: "left" | "center" | "right" +} + +function DataListCell({ + align = "left", + children, + className, + labelClassName, + label, + ...props +}: DataListCellProps) { + return ( +
+ {label != null && ( + + {label} + + )} + {children} +
+ ) +} + +export const DataList = Object.assign(DataListRoot, { + Header: DataListHeader, + Head: DataListHead, + Body: DataListBody, + Row: DataListRow, + Cell: DataListCell, +})