Skip to content

Commit

Permalink
feat(Table): remove bottom border from last row (#88)
Browse files Browse the repository at this point in the history
Co-authored-by: alx-chernigin <[email protected]>
  • Loading branch information
kvestus and alx-chernigin authored Nov 15, 2024
1 parent 27091eb commit 30e73b5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/Table/Table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,10 @@ $block: '.#{variables.$ns}styled-table';
padding: var(--_--cell-padding);
border-block-end: 1px solid var(--g-color-line-generic);
}

&__row:last-of-type {
#{$block}__cell {
border-block-end: none;
}
}
}
10 changes: 10 additions & 0 deletions src/components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const Table = React.forwardRef(
cellClassName: cellClassNameProp,
footerCellClassName: footerCellClassNameProp,
headerCellClassName: headerCellClassNameProp,
rowClassName: rowClassNameProp,
headerClassName,
size = 'm',
...props
Expand Down Expand Up @@ -51,6 +52,14 @@ export const Table = React.forwardRef(
return b('footer-cell', footerCellClassNameProp);
}, [footerCellClassNameProp]);

const rowClassName: TableProps<TData>['rowClassName'] = React.useMemo(() => {
if (typeof rowClassNameProp === 'function') {
return (...args) => b('row', rowClassNameProp(...args));
}

return b('row', rowClassNameProp);
}, [rowClassNameProp]);

return (
<BaseTable
ref={ref}
Expand All @@ -59,6 +68,7 @@ export const Table = React.forwardRef(
footerCellClassName={footerCellClassName}
headerCellClassName={headerCellClassName}
headerClassName={b('header', headerClassName)}
rowClassName={rowClassName}
{...props}
/>
);
Expand Down

0 comments on commit 30e73b5

Please sign in to comment.