Skip to content

Commit

Permalink
Convert height-specific styles to CSS
Browse files Browse the repository at this point in the history
- Remove unnecessary `flex-grow: 1` - isn't doing anything

+ start the process of moving out the text truncation/breaking CSS to their className utils
  • Loading branch information
cee-chen committed Oct 4, 2023
1 parent 92a7d1e commit 953e6f7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
7 changes: 4 additions & 3 deletions src/components/datagrid/_data_grid_data_row.scss
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@
text-transform: capitalize;
}

.euiDataGridRowCell__definedHeight {
@include euiTextBreakWord;
flex-grow: 1;
.euiDataGridRowCell__lineCountHeight,
.euiDataGridRowCell__numericalHeight {
height: 100%;
overflow: hidden;
}

// We only truncate if the cell is not a control column.
Expand Down
25 changes: 15 additions & 10 deletions src/components/datagrid/body/data_grid_cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,26 @@ const EuiDataGridCellContent: FunctionComponent<
const CellElement =
renderCellValue as JSXElementConstructor<EuiDataGridCellValueElementProps>;

const rowHeightOption = rowHeightUtils?.getRowHeightOption(
rowIndex,
rowHeightsOptions
);
const cellHeightType = rowHeightUtils?.getHeightType(rowHeightOption);

const classes = classNames(
`euiDataGridRowCell__${cellHeightType}Height`,
{
'eui-textBreakWord': cellHeightType !== 'default',
'euiDataGridRowCell__truncate': cellHeightType === 'default', // TODO: Convert to .eui-textTruncate
}
);

return (
<>
<div
ref={setCellContentsRef}
data-datagrid-cellcontent
className={
isDefinedHeight
? 'euiDataGridRowCell__definedHeight'
: 'euiDataGridRowCell__truncate'
}
style={
isDefinedHeight
? rowHeightUtils?.getStylesForCell(rowHeightsOptions!, rowIndex)
: {}
}
className={classes}
>
<CellElement
isDetails={false}
Expand Down

0 comments on commit 953e6f7

Please sign in to comment.