Skip to content

Commit

Permalink
feat(Table): use <colgroup/> to set cells width
Browse files Browse the repository at this point in the history
  • Loading branch information
ogonkov committed Jul 19, 2023
1 parent c01ad33 commit f4b190c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,23 @@ export class Table<I extends TableDataItem = Record<string, string>> extends Rea
);
}

private renderColgroup() {
const {columns} = this.props;
const {columnsStyles} = this.state;

if (!columnsStyles.length) {
return null;
}

return (
<colgroup>
{columnsStyles.map(({width}, index) => (
<col style={{width}} key={columns[index].id} />
))}
</colgroup>
);
}

private renderHead() {
const {columns, edgePadding} = this.props;
const {columnsStyles} = this.state;
Expand Down Expand Up @@ -381,6 +398,7 @@ export class Table<I extends TableDataItem = Record<string, string>> extends Rea
private renderTable() {
return (
<table ref={this.tableRef} className={b('table')}>
{this.renderColgroup()}
{this.renderHead()}
{this.renderBody()}
</table>
Expand Down

0 comments on commit f4b190c

Please sign in to comment.