Skip to content

Commit

Permalink
body cell wrapper inner
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-kot committed Nov 26, 2024
1 parent e04b439 commit 4de7d75
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/table/__tests__/table.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ test('should render table with react content', () => {
];
const { wrapper } = renderTable(<Table columnDefinitions={columns} items={defaultItems} />);
const findCellContent = (row: number, col: number) =>
wrapper.findBodyCell(row, col)!.findByClassName(bodyCellStyles['body-cell-content'])!;
wrapper.findBodyCell(row, col)!.findByClassName(bodyCellStyles['body-cell-content-inner'])!;
expect(wrapper.findColumnHeaders().map(getHeaderHtmlContent)).toEqual(['id', 'name', 'Advanced <span>header</span>']);
expect(wrapper.findRows()).toHaveLength(3);
expect(findCellContent(1, 3)!.getElement().innerHTML).toEqual('<input readonly="" value="Apples">');
Expand Down
13 changes: 10 additions & 3 deletions src/table/body-cell/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,16 @@ $cell-negative-space-vertical: 2px;

&-content {
box-sizing: border-box;
block-size: 100%;
display: flex;
align-items: center;

&.body-cell-align-top {
align-items: baseline;
}
}
&-content-inner {
box-sizing: border-box;

&:not(.body-cell-wrap) {
white-space: nowrap;
Expand Down Expand Up @@ -189,9 +199,6 @@ $cell-negative-space-vertical: 2px;
&:first-child:not(.is-visual-refresh) {
@include cell-padding-inline-start($cell-edge-horizontal-padding);
}
&-align-top {
vertical-align: top;
}
&-first-row {
border-block-start: $border-placeholder;
}
Expand Down
7 changes: 5 additions & 2 deletions src/table/body-cell/td-element.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ export const TableTdElement = React.forwardRef<HTMLTableCellElement, TableTdElem
hasSuccessIcon && styles['body-cell-has-success'],
level !== undefined && styles['body-cell-expandable'],
level !== undefined && styles[`expandable-level-${getLevelClassSuffix(level)}`],
verticalAlign === 'top' && styles['body-cell-align-top'],
stickyStyles.className
)}
onClick={onClick}
Expand All @@ -161,7 +160,11 @@ export const TableTdElement = React.forwardRef<HTMLTableCellElement, TableTdElem
</div>
)}

<div className={clsx(styles['body-cell-content'], wrapLines && styles['body-cell-wrap'])}>{children}</div>
<div className={clsx(styles['body-cell-content'], verticalAlign === 'top' && styles['body-cell-align-top'])}>
<div className={clsx(styles['body-cell-content-inner'], wrapLines && styles['body-cell-wrap'])}>
{children}
</div>
</div>
</Element>
);
}
Expand Down
1 change: 1 addition & 0 deletions src/table/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

.table {
inline-size: 100%;
block-size: 100%;
border-spacing: 0;
position: relative;
box-sizing: border-box;
Expand Down

0 comments on commit 4de7d75

Please sign in to comment.