From 68aedb8f5b1be8a524c45842424c826f43d7c668 Mon Sep 17 00:00:00 2001 From: Nick Winters Date: Thu, 19 Sep 2024 16:44:32 -0700 Subject: [PATCH] Add custom styles to table component --- .../_site+/c_+/_components/GridView.tsx | 26 ++++++++++++++++--- .../_site+/c_+/_components/ListFilters.tsx | 3 ++- .../_site+/c_+/_components/ListTable.tsx | 14 +++++++--- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/app/routes/_site+/c_+/_components/GridView.tsx b/app/routes/_site+/c_+/_components/GridView.tsx index e8f0edddc..817529ba6 100644 --- a/app/routes/_site+/c_+/_components/GridView.tsx +++ b/app/routes/_site+/c_+/_components/GridView.tsx @@ -1,13 +1,31 @@ import { type Table as TableType, flexRender } from "@tanstack/react-table"; +import clsx from "clsx"; -export function GridView({ table }: { table: TableType }) { +export function GridView({ + table, + gridCellClassNames, + gridContainerClassNames, +}: { + table: TableType; + gridCellClassNames?: string; + gridContainerClassNames?: string; +}) { return ( -
+
{table.getRowModel().rows.map((row) => { return (
{flexRender( diff --git a/app/routes/_site+/c_+/_components/ListFilters.tsx b/app/routes/_site+/c_+/_components/ListFilters.tsx index c71764c29..e78fe7024 100644 --- a/app/routes/_site+/c_+/_components/ListFilters.tsx +++ b/app/routes/_site+/c_+/_components/ListFilters.tsx @@ -257,8 +257,9 @@ export function ListFilters({
{option?.icon && ( )} diff --git a/app/routes/_site+/c_+/_components/ListTable.tsx b/app/routes/_site+/c_+/_components/ListTable.tsx index b331898b1..0a50d2cab 100644 --- a/app/routes/_site+/c_+/_components/ListTable.tsx +++ b/app/routes/_site+/c_+/_components/ListTable.tsx @@ -33,16 +33,20 @@ export function ListTable({ gridView, defaultSort, searchPlaceholder, + gridCellClassNames, + gridContainerClassNames, }: { data: any; - columns: AccessorKeyColumnDefBase[]; + columns: AccessorKeyColumnDefBase[] | any; collection?: Collection; columnViewability?: VisibilityState; defaultViewType?: "list" | "grid"; - filters?: TableFilters; + filters?: TableFilters | any; gridView?: AccessorKeyColumnDef; defaultSort?: SortingState; searchPlaceholder?: string; + gridCellClassNames?: string; + gridContainerClassNames?: string; }) { // Table state definitions const [tableData] = useState(() => [...data?.listData?.docs]); @@ -104,7 +108,11 @@ export function ListTable({ {viewMode === "list" ? ( ) : ( - + )}