From e0df28d45d0b0cbbcf2b1153c64894de1cd5b7c7 Mon Sep 17 00:00:00 2001 From: Cee Chen Date: Fri, 30 Aug 2024 12:06:43 -0700 Subject: [PATCH] Convert datagrid wrapper styles --- .../__snapshots__/data_grid.test.tsx.snap | 24 +++++------ .../src/components/datagrid/_data_grid.scss | 24 ----------- .../components/datagrid/data_grid.styles.ts | 41 +++++++++++++++++++ .../eui/src/components/datagrid/data_grid.tsx | 8 +++- 4 files changed, 60 insertions(+), 37 deletions(-) create mode 100644 packages/eui/src/components/datagrid/data_grid.styles.ts diff --git a/packages/eui/src/components/datagrid/__snapshots__/data_grid.test.tsx.snap b/packages/eui/src/components/datagrid/__snapshots__/data_grid.test.tsx.snap index f197ca1bf0b..cc6c8c465c9 100644 --- a/packages/eui/src/components/datagrid/__snapshots__/data_grid.test.tsx.snap +++ b/packages/eui/src/components/datagrid/__snapshots__/data_grid.test.tsx.snap @@ -457,11 +457,11 @@ exports[`EuiDataGrid rendering renders additional toolbar controls 1`] = ` tabindex="-1" />
{ + const { euiTheme } = euiThemeContext; + + return { + euiDataGrid: css` + display: flex; + flex-direction: column; + align-items: stretch; + ${logicalCSS('height', '100%')} + overflow: hidden; + `, + // Sits below the controls above it and pagination below it + euiDataGrid__content: css` + z-index: 1; + position: relative; + flex-grow: 1; + ${logicalSizeCSS('100%')} + ${logicalCSS('max-width', '100%')} + overflow: hidden; + background-color: ${euiTheme.colors.body}; + font-feature-settings: 'tnum' 1; /* Tabular numbers */ + `, + // Wrapper around EuiDataGrid + euiDataGrid__focusWrap: css` + ${logicalCSS('height', '100%')} + `, + }; +}; diff --git a/packages/eui/src/components/datagrid/data_grid.tsx b/packages/eui/src/components/datagrid/data_grid.tsx index f3c7341df39..89bd611a559 100644 --- a/packages/eui/src/components/datagrid/data_grid.tsx +++ b/packages/eui/src/components/datagrid/data_grid.tsx @@ -19,7 +19,7 @@ import { VariableSizeGrid as Grid, GridOnItemsRenderedProps, } from 'react-window'; -import { useGeneratedHtmlId } from '../../services'; +import { useGeneratedHtmlId, useEuiMemoizedStyles } from '../../services'; import { useEuiTablePaginationDefaults } from '../table/table_pagination'; import { EuiFocusTrap } from '../focus_trap'; import { EuiI18n, useEuiI18n } from '../i18n'; @@ -67,6 +67,7 @@ import { EuiDataGridStyleHeader, EuiDataGridStyleRowHover, } from './data_grid_types'; +import { euiDataGridStyles } from './data_grid.styles'; // Each gridStyle object above sets a specific CSS select to .euiGrid const fontSizesToClassMap: { [size in EuiDataGridStyleFontSizes]: string } = { @@ -427,6 +428,8 @@ export const EuiDataGrid = memo( ] ); + const styles = useEuiMemoizedStyles(euiDataGridStyles); + return ( @@ -434,8 +437,10 @@ export const EuiDataGrid = memo(