Skip to content

Commit

Permalink
fix(DataTable): fixes overflowing sort button and select column spaci…
Browse files Browse the repository at this point in the history
…ng (#9956)

* fix: add width to checkbox column

* feat: add select/sort story

* feat: add fix to styles package

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
jnm2377 and kodiakhq[bot] authored Oct 29, 2021
1 parent 9f3da13 commit 6ce1b54
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@

.#{$prefix}--data-table thead th.#{$prefix}--table-column-checkbox,
.#{$prefix}--data-table tbody td.#{$prefix}--table-column-checkbox {
width: 2.5rem;
// spacing between checkbox / chevron and next cell should be 8px / 0.5rem
padding-right: rem(4px);
padding-left: 1rem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,45 @@ export const WithRadioSelection = () => (
)}
</DataTable>
);

export const WithSelectionAndSorting = () => (
<DataTable rows={rows} headers={headers} isSortable>
{({
rows,
headers,
getHeaderProps,
getRowProps,
getSelectionProps,
getTableProps,
getTableContainerProps,
}) => (
<TableContainer
title="DataTable"
description="With selection"
{...getTableContainerProps()}>
<Table {...getTableProps()}>
<TableHead>
<TableRow>
<TableSelectAll {...getSelectionProps()} />
{headers.map((header, i) => (
<TableHeader key={i} {...getHeaderProps({ header })}>
{header.header}
</TableHeader>
))}
</TableRow>
</TableHead>
<TableBody>
{rows.map((row, i) => (
<TableRow key={i} {...getRowProps({ row })}>
<TableSelectRow {...getSelectionProps({ row })} />
{row.cells.map((cell) => (
<TableCell key={cell.id}>{cell.value}</TableCell>
))}
</TableRow>
))}
</TableBody>
</Table>
</TableContainer>
)}
</DataTable>
);
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@

.#{$prefix}--data-table thead th.#{$prefix}--table-column-checkbox,
.#{$prefix}--data-table tbody td.#{$prefix}--table-column-checkbox {
width: 2.5rem;
// spacing between checkbox / chevron and next cell should be 8px / 0.5rem
padding-right: rem(4px);
padding-left: 1rem;
Expand Down

0 comments on commit 6ce1b54

Please sign in to comment.