Skip to content

Commit

Permalink
fix(tables): rename isTableHeadHidden prop to withoutHead in DataTable
Browse files Browse the repository at this point in the history
  • Loading branch information
ivangabriele committed Oct 24, 2024
1 parent 939c501 commit 5bc2b76
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/tables/DataTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ export type DataTableProps<T extends AnyObject> = {
columns: Array<ColumnDef<T>>
data: T[] | undefined
initialSorting: SortingState
isTableHeadHidden?: boolean | undefined
tableOptions?: Partial<TableOptions<T>> | undefined
withoutHead?: boolean | undefined
}
export function DataTable<T extends AnyObject>({
columns,
data,
initialSorting,
isTableHeadHidden = false,
tableOptions
tableOptions,
withoutHead = false
}: DataTableProps<T>) {
const [sorting, setSorting] = useState<SortingState>(initialSorting)

Expand Down Expand Up @@ -57,7 +57,7 @@ export function DataTable<T extends AnyObject>({

{data.length > 0 && (
<SimpleTable.Table>
{!isTableHeadHidden && (
{!withoutHead && (
<SimpleTable.Head>
{table.getHeaderGroups().map(headerGroup => (
<tr key={headerGroup.id}>
Expand All @@ -69,7 +69,7 @@ export function DataTable<T extends AnyObject>({
</SimpleTable.Head>
)}

<TBody $withTopBorder={isTableHeadHidden!}>
<TBody $withTopBorder={withoutHead}>
{rows.map(row => (
// `data-id` is expected by `cy.getTableRowById()` custom command
<SimpleTable.BodyTr key={row.id} data-id={'id' in row.original ? row.original.id : row.id}>
Expand Down
8 changes: 4 additions & 4 deletions stories/tables/DataTable.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const args: DataTableProps<FakeBasicTableDataItem> = {
id: 'lastName'
}
],
isTableHeadHidden: false,
tableOptions: undefined
tableOptions: undefined,
withoutHead: false
}

/* eslint-disable sort-keys-fix/sort-keys-fix */
Expand All @@ -29,7 +29,6 @@ const meta: Meta<DataTableProps<FakeBasicTableDataItem>> = {
component: DataTable,

argTypes: {
isTableHeadHidden: ARG_TYPE.OPTIONAL_BOOLEAN,
tableOptions: {
...ARG_TYPE.NO_CONTROL_INPUT,
table: {
Expand All @@ -38,7 +37,8 @@ const meta: Meta<DataTableProps<FakeBasicTableDataItem>> = {
summary: `import('@tanstack/react-table').TableOptions | undefined`
}
}
}
},
withoutHead: ARG_TYPE.OPTIONAL_BOOLEAN
},

args,
Expand Down

0 comments on commit 5bc2b76

Please sign in to comment.