-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathTable.tsx
42 lines (35 loc) · 1.36 KB
/
Table.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import type {BaseTableProps} from '@gravity-ui/table';
import {BaseTable} from '@gravity-ui/table';
import {cn} from '../../utils/cn';
import './Table.scss';
const block = cn('ydb-table');
interface TableProps<TData> extends BaseTableProps<TData> {
width?: 'max' | 'auto';
wrapperClassName?: string;
}
interface ColumnHeaderProps {
children: React.ReactNode;
className?: string;
}
export function ColumnHeader({children, className}: ColumnHeaderProps) {
return <div className={block('table-header-content', className)}>{children}</div>;
}
export function Table<TData>({className, width, wrapperClassName, ...props}: TableProps<TData>) {
return (
<div className={block(null, wrapperClassName)}>
<BaseTable
headerCellClassName={({column}) => {
const align = column.columnDef.meta?.align;
return block('table-header-cell', {align});
}}
cellClassName={(cell) => {
const align = cell?.column.columnDef.meta?.align;
const verticalAlign = cell?.column.columnDef.meta?.verticalAlign;
return block('table-cell', {align, 'vertical-align': verticalAlign});
}}
className={block('table', {width}, className)}
{...props}
/>
</div>
);
}