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 EuiDataGrid (Part 1) #7998

Merged
merged 9 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Pinning this here with loose relation]

The scrollbar tests across browsers went as expected (showing custom scrollbars or default ones) except for Safari which always shows the same static/non-overlaying ones it seemed. But that is Safari 🤷‍♀️

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Safari: the new IE11!

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions packages/eui/changelogs/upcoming/7998.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
**CSS-in-JS conversions**

- Converted `EuiDataGrid` to Emotion
- Removed `$euiZDataGrid`
- Removed `$euiZHeaderBelowDataGrid`
Original file line number Diff line number Diff line change
Expand Up @@ -457,11 +457,11 @@ exports[`EuiDataGrid rendering renders additional toolbar controls 1`] = `
tabindex="-1"
/>
<div
class="euiDataGrid__focusWrap"
class="euiDataGrid__focusWrap emotion-euiDataGrid__focusWrap"
data-focus-lock-disabled="disabled"
>
<div
class="euiDataGrid euiDataGrid--bordersAll euiDataGrid--headerShade euiDataGrid--footerOverline euiDataGrid--rowHoverHighlight euiDataGrid--stickyFooter testClass1 testClass2 emotion-euiTestCss"
class="euiDataGrid euiDataGrid--bordersAll euiDataGrid--headerShade euiDataGrid--footerOverline euiDataGrid--rowHoverHighlight euiDataGrid--stickyFooter testClass1 testClass2 emotion-euiDataGrid-euiTestCss"
data-test-subj="test subject string"
>
<div
Expand Down Expand Up @@ -576,14 +576,14 @@ exports[`EuiDataGrid rendering renders additional toolbar controls 1`] = `
<div
aria-label="aria-label"
aria-rowcount="3"
class="euiDataGrid__content"
class="euiDataGrid__content emotion-euiDataGrid__content"
data-test-subj="euiDataGridBody"
id="generated-id"
role="grid"
tabindex="0"
>
<div
class="euiDataGrid__virtualized"
class="euiDataGrid__virtualized emotion-euiDataGridBody-virtualized"
style="position: relative; height: 9007199254740991px; width: 9007199254740991px; overflow: auto; will-change: transform; direction: ltr;"
>
<div
Expand Down Expand Up @@ -866,11 +866,11 @@ exports[`EuiDataGrid rendering renders control columns 1`] = `
tabindex="-1"
/>
<div
class="euiDataGrid__focusWrap"
class="euiDataGrid__focusWrap emotion-euiDataGrid__focusWrap"
data-focus-lock-disabled="disabled"
>
<div
class="euiDataGrid euiDataGrid--bordersAll euiDataGrid--headerShade euiDataGrid--footerOverline euiDataGrid--rowHoverHighlight euiDataGrid--stickyFooter testClass1 testClass2 emotion-euiTestCss"
class="euiDataGrid euiDataGrid--bordersAll euiDataGrid--headerShade euiDataGrid--footerOverline euiDataGrid--rowHoverHighlight euiDataGrid--stickyFooter testClass1 testClass2 emotion-euiDataGrid-euiTestCss"
data-test-subj="test subject string"
>
<div
Expand Down Expand Up @@ -985,14 +985,14 @@ exports[`EuiDataGrid rendering renders control columns 1`] = `
<div
aria-label="aria-label"
aria-rowcount="3"
class="euiDataGrid__content"
class="euiDataGrid__content emotion-euiDataGrid__content"
data-test-subj="euiDataGridBody"
id="generated-id"
role="grid"
tabindex="0"
>
<div
class="euiDataGrid__virtualized"
class="euiDataGrid__virtualized emotion-euiDataGridBody-virtualized"
style="position: relative; height: 9007199254740991px; width: 9007199254740991px; overflow: auto; will-change: transform; direction: ltr;"
>
<div
Expand Down Expand Up @@ -1469,11 +1469,11 @@ exports[`EuiDataGrid rendering renders custom column headers 1`] = `
tabindex="-1"
/>
<div
class="euiDataGrid__focusWrap"
class="euiDataGrid__focusWrap emotion-euiDataGrid__focusWrap"
data-focus-lock-disabled="disabled"
>
<div
class="euiDataGrid euiDataGrid--bordersAll euiDataGrid--headerShade euiDataGrid--footerOverline euiDataGrid--rowHoverHighlight euiDataGrid--stickyFooter testClass1 testClass2 emotion-euiTestCss"
class="euiDataGrid euiDataGrid--bordersAll euiDataGrid--headerShade euiDataGrid--footerOverline euiDataGrid--rowHoverHighlight euiDataGrid--stickyFooter testClass1 testClass2 emotion-euiDataGrid-euiTestCss"
data-test-subj="test subject string"
>
<div
Expand Down Expand Up @@ -1585,14 +1585,14 @@ exports[`EuiDataGrid rendering renders custom column headers 1`] = `
<div
aria-label="aria-label"
aria-rowcount="3"
class="euiDataGrid__content"
class="euiDataGrid__content emotion-euiDataGrid__content"
data-test-subj="euiDataGridBody"
id="generated-id"
role="grid"
tabindex="0"
>
<div
class="euiDataGrid__virtualized"
class="euiDataGrid__virtualized emotion-euiDataGridBody-virtualized"
style="position: relative; height: 9007199254740991px; width: 9007199254740991px; overflow: auto; will-change: transform; direction: ltr;"
>
<div
Expand Down Expand Up @@ -1877,11 +1877,11 @@ exports[`EuiDataGrid rendering renders with common and div attributes 1`] = `
tabindex="-1"
/>
<div
class="euiDataGrid__focusWrap"
class="euiDataGrid__focusWrap emotion-euiDataGrid__focusWrap"
data-focus-lock-disabled="disabled"
>
<div
class="euiDataGrid euiDataGrid--bordersAll euiDataGrid--headerShade euiDataGrid--footerOverline euiDataGrid--rowHoverHighlight euiDataGrid--stickyFooter testClass1 testClass2 emotion-euiTestCss"
class="euiDataGrid euiDataGrid--bordersAll euiDataGrid--headerShade euiDataGrid--footerOverline euiDataGrid--rowHoverHighlight euiDataGrid--stickyFooter testClass1 testClass2 emotion-euiDataGrid-euiTestCss"
data-test-subj="test subject string"
>
<div
Expand Down Expand Up @@ -1993,14 +1993,14 @@ exports[`EuiDataGrid rendering renders with common and div attributes 1`] = `
<div
aria-label="aria-label"
aria-rowcount="3"
class="euiDataGrid__content"
class="euiDataGrid__content emotion-euiDataGrid__content"
data-test-subj="euiDataGridBody"
id="generated-id"
role="grid"
tabindex="0"
>
<div
class="euiDataGrid__virtualized"
class="euiDataGrid__virtualized emotion-euiDataGridBody-virtualized"
style="position: relative; height: 9007199254740991px; width: 9007199254740991px; overflow: auto; will-change: transform; direction: ltr;"
>
<div
Expand Down
121 changes: 0 additions & 121 deletions packages/eui/src/components/datagrid/_data_grid.scss

This file was deleted.

1 change: 0 additions & 1 deletion packages/eui/src/components/datagrid/_index.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@import 'variables';
@import 'mixins';
@import 'data_grid';
@import 'body/header/data_grid_header_row';
@import 'body/footer/data_grid_footer_row';
@import 'body/header/data_grid_column_resizer';
Expand Down
2 changes: 0 additions & 2 deletions packages/eui/src/components/datagrid/_variables.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
$euiZDataGrid: $euiZHeader - 1;
$euiZHeaderBelowDataGrid: $euiZHeader - 2;
$euiZDataGridCellPopover: $euiZHeader; // Same z-index as EuiFlyout mask overlays - cell popovers should be under both modal and flyout overlays

$euiDataGridColumnResizerWidth: 3px; // Odd number because it straddles a border
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { css } from '@emotion/react';

import { UseEuiTheme } from '../../../services';
import { euiScrollBarStyles, logicalSizeCSS } from '../../../global_styling';

export const euiDataGridBodyStyles = (euiThemeContext: UseEuiTheme) => {
return {
euiDataGridBody: css`
${euiScrollBarStyles(euiThemeContext)}
`,
virtualized: css`
scroll-padding: 0;
`,
customRender: css`
${logicalSizeCSS('100%')}
overflow: auto;
`,
};
};
11 changes: 10 additions & 1 deletion packages/eui/src/components/datagrid/body/data_grid_body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@

import React, { FunctionComponent } from 'react';

import { useEuiMemoizedStyles } from '../../../services';
import { EuiDataGridBodyProps } from '../data_grid_types';
import { EuiDataGridBodyVirtualized } from './data_grid_body_virtualized';
import { EuiDataGridBodyCustomRender } from './data_grid_body_custom';
import { euiDataGridBodyStyles } from './data_grid_body.styles';

export const EuiDataGridBody: FunctionComponent<EuiDataGridBodyProps> = ({
renderCustomGridBody,
Expand All @@ -21,12 +23,19 @@ export const EuiDataGridBody: FunctionComponent<EuiDataGridBodyProps> = ({
* + virtualization library for rendering content, or if consumers have
* passed their own custom renderer
*/
const styles = useEuiMemoizedStyles(euiDataGridBodyStyles);
const cssStyles = [
styles.euiDataGridBody,
renderCustomGridBody ? styles.customRender : styles.virtualized,
];

return renderCustomGridBody ? (
<EuiDataGridBodyCustomRender
renderCustomGridBody={renderCustomGridBody}
css={cssStyles}
{...props}
/>
) : (
<EuiDataGridBodyVirtualized {...props} />
<EuiDataGridBodyVirtualized css={cssStyles} {...props} />
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const EuiDataGridBodyCustomRender: FunctionComponent<
rowHeightsOptions,
gridWidth,
gridStyles,
className,
}) => {
/**
* Columns & widths
Expand Down Expand Up @@ -187,6 +188,7 @@ export const EuiDataGridBodyCustomRender: FunctionComponent<
{...customGridBodyProps}
className={classNames(
'euiDataGrid__customRenderBody',
className,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL. Thanks for the note on the required className 👍

customGridBodyProps?.className
)}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export const EuiDataGridBodyVirtualized: FunctionComponent<EuiDataGridBodyProps>
gridRef,
gridItemsRendered,
wrapperRef,
className,
}) => {
/**
* Grid refs & observers
Expand Down Expand Up @@ -367,6 +368,7 @@ export const EuiDataGridBodyVirtualized: FunctionComponent<EuiDataGridBodyProps>
ref={gridRef}
className={classNames(
'euiDataGrid__virtualized',
className,
virtualizationOptions?.className
)}
onItemsRendered={onItemsRendered}
Expand Down
Loading
Loading