Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Emotion] Convert final EuiDataGrid cell styles (Part 5) #8013

Merged
merged 28 commits into from
Sep 12, 2024
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
175b2f8
Convert remaining `.euiDataGridRowCell` styles
cee-chen Sep 10, 2024
046bfef
Convert remaining `.euiDataGridRowCell__content` styles
cee-chen Sep 10, 2024
ba408b6
Update downstream snapshots
cee-chen Sep 9, 2024
91a349c
Convert remaining `.euiDataGridHeaderCell` styles
cee-chen Sep 10, 2024
89ad354
[refactor] Remove unnecessary `CellContent` FC
cee-chen Sep 10, 2024
45aeb31
Convert `.euiDataGridHeaderCell__content` styles
cee-chen Sep 10, 2024
95548bb
[refactor] Clean up column actions button/icon DOM+CSS
cee-chen Sep 10, 2024
ccde288
Convert `.euiDataGridHeaderCell__button` styles
cee-chen Sep 10, 2024
c9327ca
Add VRT/E2E tests for header styles
cee-chen Sep 10, 2024
8320712
[refactor] clean up header control column DOM
cee-chen Sep 10, 2024
25d92ff
Update downstream tests/snapshots
cee-chen Sep 10, 2024
480f098
[Enhancement] Replace unused header cell actions CSS
cee-chen Sep 1, 2024
22f27c8
Convert column resizer styles
cee-chen Sep 1, 2024
18ce982
Convert remaining `.euiDataGridFooterCell` styles
cee-chen Sep 9, 2024
2a80790
changelog
cee-chen Sep 10, 2024
64d3ce5
Delete all data grid Sass files
cee-chen Sep 1, 2024
9e68f6f
Final component Sass deletions 🥲
cee-chen Sep 10, 2024
d70c124
[tech debt] Address various Emotion component post-conversion TODOs
cee-chen Sep 10, 2024
5d47175
Final EuiDataGrid VRT updates
cee-chen Sep 10, 2024
d7d70c2
Fix Storybook control docgen for `gridStyle`/`rowHeightsOptions`/`too…
cee-chen Sep 10, 2024
456f5ef
Fix Cypress axe test
cee-chen Sep 10, 2024
64f1748
[PR feedback] Fix column actions button sizing
cee-chen Sep 11, 2024
fb0178c
[PR feedback] Remove `export` on internal consts
cee-chen Sep 11, 2024
3e6c32b
[refactor] avoid render prop + unmemoized array by creating a new fun…
cee-chen Sep 11, 2024
7594ac8
[a11y] Fix VO not correctly reading out SR text due to newlines in JSX
cee-chen Sep 11, 2024
bf7853e
[refactor] remove non-content children out of EuiDataGridCellContent
cee-chen Sep 11, 2024
f53c710
[cleanup] Replace `hidden` attribute with conditional JSX
cee-chen Sep 12, 2024
0b29898
[refactor] clean up focus trap aria-describedby text
cee-chen Sep 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 60 additions & 68 deletions packages/eui/src/components/datagrid/body/cell/data_grid_cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,8 @@ const EuiDataGridCellContent: FunctionComponent<
EuiDataGridCellValueProps & {
setCellProps: EuiDataGridCellValueElementProps['setCellProps'];
setCellContentsRef: (ref: HTMLDivElement | null) => void;
showCellActions: boolean;
isExpanded: boolean;
onExpandClick: () => void;
popoverAnchorRef: MutableRefObject<HTMLDivElement | null>;
isControlColumn: boolean;
isFocused: boolean;
ariaRowIndex: number;
rowHeight?: EuiDataGridRowHeightOption;
}
> = memo(
Expand All @@ -70,14 +65,9 @@ const EuiDataGridCellContent: FunctionComponent<
setCellContentsRef,
rowIndex,
colIndex,
ariaRowIndex,
rowHeight,
rowHeightUtils,
isControlColumn,
isFocused,
showCellActions,
onExpandClick,
popoverAnchorRef,
...rest
}) => {
// React is more permissive than the TS types indicate
Expand Down Expand Up @@ -123,64 +113,30 @@ const EuiDataGridCellContent: FunctionComponent<
]),
];

const cellPosition = useEuiI18n(
'euiDataGridCell.position',
'{columnId}, column {col}, row {row}',
{
columnId: column?.displayAsText || rest.columnId,
col: colIndex + 1,
row: ariaRowIndex,
}
);
const enterKeyPrompt = useEuiI18n(
'euiDataGridCell.expansionEnterPrompt',
'Press the Enter key to expand this cell.'
);

return (
<>
<RenderTruncatedCellContent
hasLineCountTruncation={
cellHeightType === 'lineCount' && !isControlColumn
}
rowHeight={rowHeight}
<RenderTruncatedCellContent
hasLineCountTruncation={
cellHeightType === 'lineCount' && !isControlColumn
}
rowHeight={rowHeight}
>
<div
ref={setCellContentsRef}
data-datagrid-cellcontent
className={classes}
css={cssStyles}
>
<div
ref={setCellContentsRef}
data-datagrid-cellcontent
className={classes}
css={cssStyles}
>
<CellElement
isDetails={false}
data-test-subj="cell-content"
rowIndex={rowIndex}
colIndex={colIndex}
schema={column?.schema || rest.columnType}
{...cellContext}
{...rest}
/>
</div>
</RenderTruncatedCellContent>

<EuiScreenReaderOnly>
<p hidden={!isFocused}>
{` - ${cellPosition}${
showCellActions ? `. ${enterKeyPrompt}` : ''
}`}
</p>
</EuiScreenReaderOnly>

{showCellActions && (
<EuiDataGridCellActions
<CellElement
isDetails={false}
data-test-subj="cell-content"
rowIndex={rowIndex}
colIndex={colIndex}
column={column}
onExpandClick={onExpandClick}
popoverAnchorRef={popoverAnchorRef}
schema={column?.schema || rest.columnType}
{...cellContext}
{...rest}
/>
)}
</>
</div>
</RenderTruncatedCellContent>
);
}
);
Expand Down Expand Up @@ -657,21 +613,33 @@ export class EuiDataGridCell extends Component<
columnType={columnType}
isExpandable={isExpandable}
isExpanded={popoverIsOpen}
onExpandClick={this.handleCellExpansionClick}
popoverAnchorRef={this.popoverAnchorRef}
showCellActions={showCellActions}
isFocused={this.state.isFocused}
setCellContentsRef={this.setCellContentsRef}
rowHeight={rowHeight}
rowHeightUtils={rowHeightUtils}
isControlColumn={cellClasses.includes(
'euiDataGridRowCell--controlColumn'
)}
ariaRowIndex={ariaRowIndex}
rowIndex={rowIndex}
colIndex={colIndex}
/>
</HandleInteractiveChildren>

<CellScreenReaderDescription
mgadewoll marked this conversation as resolved.
Show resolved Hide resolved
columnName={column?.displayAsText || this.props.columnId}
columnIndex={colIndex + 1}
rowIndex={ariaRowIndex}
canExpandCell={showCellActions}
/>

{showCellActions && (
<EuiDataGridCellActions
rowIndex={rowIndex}
colIndex={colIndex}
column={column}
onExpandClick={this.handleCellExpansionClick}
popoverAnchorRef={this.popoverAnchorRef}
/>
)}
</GridCellDiv>
</RenderCellInRow>
);
Expand Down Expand Up @@ -742,3 +710,27 @@ const GridCellDiv = memo(
})
);
GridCellDiv.displayName = 'GridCellDiv';

const CellScreenReaderDescription: FunctionComponent<{
columnName: string;
columnIndex: number;
rowIndex: number;
canExpandCell: boolean;
}> = memo(({ columnName, columnIndex, rowIndex, canExpandCell }) => {
const cellPosition = useEuiI18n(
'euiDataGridCell.position',
'{columnName}, column {columnIndex}, row {rowIndex}',
{ columnName, columnIndex, rowIndex }
);
const enterKeyPrompt = useEuiI18n(
'euiDataGridCell.expansionEnterPrompt',
'Press the Enter key to expand this cell.'
);

return (
<EuiScreenReaderOnly>
<p>{` - ${cellPosition}${canExpandCell ? `. ${enterKeyPrompt}` : ''}`}</p>
mgadewoll marked this conversation as resolved.
Show resolved Hide resolved
</EuiScreenReaderOnly>
);
});
CellScreenReaderDescription.displayName = 'CellScreenReaderDescription';