Skip to content

Commit

Permalink
fix(DataTable): fix cell size and border in FF
Browse files Browse the repository at this point in the history
- add classes for (header) cell containers
- fix cell height size
- tune up tests, stories, and snapshots
  • Loading branch information
booc0mtaco committed Oct 15, 2024
1 parent 4942679 commit 31cd23a
Show file tree
Hide file tree
Showing 4 changed files with 1,282 additions and 431 deletions.
27 changes: 13 additions & 14 deletions src/components/DataTable/DataTable.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,27 @@
}

.data-table__table {
height: fit-content;
table-layout: fixed;
width: 100%;

/* add class instead of tag for styles? */
th,
td {
padding: 0;
vertical-align: top;
/**
* inherit height from 1px size of table rows. This allows height: 100% on cells containers
* to affect full height of cell
*/
height: inherit;
}

.data-table__caption + &,
.data-table__subcaption + & {
margin-top: calc(var(--eds-size-4) / 16 * 1rem);
}
}

.data-table__cell-container, .data-table__header-cell-container {
padding: 0;
vertical-align: top;

&:last-child {
.data-table__cell, .data-table__header-cell {
border-width: 0;
}
}
}

.data-table__search {
width: calc(var(--eds-size-34) / 16 * 1rem);
}
Expand Down Expand Up @@ -193,8 +193,7 @@
*/

.data-table__row {
/* setting the height to 1px so that later, table cell containers can take up 100% of height */
height: 1px;
height: 100%;

&.data-table__row--is-selected {
background-color: var(--eds-theme-color-background-table-row-selected);
Expand Down
2 changes: 1 addition & 1 deletion src/components/DataTable/DataTable.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ export const DefaultWithCustomTable: StoryObj<Args> = {
<table>
<tbody className="border-2 border-utility-default-lowEmphasis-hover">
<tr>
<td>TODO: Custom table rows/cells here</td>
<td>Custom or standard table rows/cells here</td>
</tr>
</tbody>
</table>
Expand Down
11 changes: 9 additions & 2 deletions src/components/DataTable/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export function DataTable<T>({
<DataTableRow key={headerGroup.id}>
{headerGroup.headers.map((header) => (
<th
className={styles['data-table__header-cell-container']}
colSpan={header.colSpan}
key={header.id}
style={{
Expand Down Expand Up @@ -243,7 +244,10 @@ export function DataTable<T>({
{row.getLeafRows().map((row) => (
<DataTableRow key={row.id}>
{row.getVisibleCells().map((cell) => (
<td key={cell.id}>
<td
className={styles['data-table__cell-container']}
key={cell.id}
>
{flexRender(
cell.column.columnDef.cell,
cell.getContext(),
Expand All @@ -259,7 +263,10 @@ export function DataTable<T>({
isSelected={row.getIsSelected()}
>
{row.getVisibleCells().map((cell) => (
<td key={cell.id}>
<td
className={styles['data-table__cell-container']}
key={cell.id}
>
{flexRender(
cell.column.columnDef.cell,
cell.getContext(),
Expand Down
Loading

0 comments on commit 31cd23a

Please sign in to comment.