Skip to content

Commit

Permalink
feat(Table): table size supported
Browse files Browse the repository at this point in the history
  • Loading branch information
DanisAvko committed Sep 17, 2024
1 parent ffd60ca commit 343025e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/components/Table/Table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,20 @@ $block: '.#{variables.$ns}styled-table';
@include mixins.text-subheader-1();
}

&_size {
&_s {
--_--cell-padding: 7px var(--g-spacing-2) 6px;
}

&_m {
--_--cell-padding: 11px var(--g-spacing-2) 10px;
}
}

&__cell,
&__header-cell,
&__footer-cell {
padding: 11px var(--g-spacing-2) 10px;
padding: var(--_--cell-padding);
border-block-end: 1px solid var(--g-color-line-generic);
}
}
9 changes: 7 additions & 2 deletions src/components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ import {BaseTable} from '../BaseTable';
import type {BaseTableProps} from '../BaseTable';

import {b} from './Table.classname';
import type {TableSize} from './types';

import './Table.scss';

export interface TableProps<TData, TScrollElement extends Element | Window = HTMLDivElement>
extends BaseTableProps<TData, TScrollElement> {}
extends BaseTableProps<TData, TScrollElement> {
/** Table size */
size?: TableSize;
}

export const Table = React.forwardRef(
<TData, TScrollElement extends Element | Window = HTMLDivElement>(
Expand All @@ -18,6 +22,7 @@ export const Table = React.forwardRef(
footerCellClassName: footerCellClassNameProp,
headerCellClassName: headerCellClassNameProp,
headerClassName,
size = 'm',
...props
}: TableProps<TData, TScrollElement>,
ref: React.Ref<HTMLTableElement>,
Expand Down Expand Up @@ -49,7 +54,7 @@ export const Table = React.forwardRef(
return (
<BaseTable
ref={ref}
className={b(null, className)}
className={b({size}, className)}
cellClassName={cellClassName}
footerCellClassName={footerCellClassName}
headerCellClassName={headerCellClassName}
Expand Down
1 change: 1 addition & 0 deletions src/components/Table/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './Table';
export * from './types';
1 change: 1 addition & 0 deletions src/components/Table/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type TableSize = 's' | 'm';

0 comments on commit 343025e

Please sign in to comment.