Skip to content

Commit 1ef638a

Browse files
authored
[DataDiscovery] Replace euiThemeVars with euiTheme (#204457)
## Summary Closes #204357 This PR replaces euiThemeVars occurrences with euiTheme. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] ~~Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)~~ - [ ] ~~[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials~~ - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] ~~If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)~~ - [ ] ~~This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations.~~ - [ ] ~~[Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed~~ - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
1 parent 06cf554 commit 1ef638a

File tree

23 files changed

+107
-84
lines changed

23 files changed

+107
-84
lines changed

src/platform/packages/shared/kbn-discover-contextual-components/src/data_types/logs/components/log_level_badge_cell/log_level_badge_cell.test.tsx

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import { fieldFormatsMock } from '@kbn/field-formats-plugin/common/mocks';
1111
import { render, screen } from '@testing-library/react';
12+
import { EuiProvider } from '@elastic/eui';
1213
import React from 'react';
1314
import { getLogLevelBadgeCell } from './log_level_badge_cell';
1415
import { dataViewMock } from '@kbn/discover-utils/src/__mocks__/data_view';
@@ -17,19 +18,21 @@ import { DataTableRecord, buildDataTableRecord } from '@kbn/discover-utils';
1718
const renderCell = (logLevelField: string, record: DataTableRecord) => {
1819
const LogLevelBadgeCell = getLogLevelBadgeCell(logLevelField);
1920
render(
20-
<LogLevelBadgeCell
21-
rowIndex={0}
22-
colIndex={0}
23-
columnId="log.level"
24-
isExpandable={false}
25-
isExpanded={false}
26-
isDetails={false}
27-
row={record}
28-
dataView={dataViewMock}
29-
fieldFormats={fieldFormatsMock}
30-
setCellProps={() => {}}
31-
closePopover={() => {}}
32-
/>
21+
<EuiProvider>
22+
<LogLevelBadgeCell
23+
rowIndex={0}
24+
colIndex={0}
25+
columnId="log.level"
26+
isExpandable={false}
27+
isExpanded={false}
28+
isDetails={false}
29+
row={record}
30+
dataView={dataViewMock}
31+
fieldFormats={fieldFormatsMock}
32+
setCellProps={() => {}}
33+
closePopover={() => {}}
34+
/>
35+
</EuiProvider>
3336
);
3437
};
3538

src/platform/packages/shared/kbn-discover-utils/src/components/custom_control_columns/degraded_docs_control.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99

1010
import React from 'react';
1111
import { i18n } from '@kbn/i18n';
12-
import { EuiCode } from '@elastic/eui';
12+
import { EuiCode, useEuiTheme } from '@elastic/eui';
1313
import { FormattedMessage } from '@kbn/i18n-react';
14-
import { euiThemeVars } from '@kbn/ui-theme';
1514
import {
1615
RowControlColumn,
1716
RowControlComponent,
@@ -83,6 +82,8 @@ const DegradedDocs = ({
8382
Control: RowControlComponent;
8483
rowProps: RowControlRowProps;
8584
} & DegradedDocsControlProps) => {
85+
const { euiTheme } = useEuiTheme();
86+
8687
const isDegradedDocumentExists = DEGRADED_DOCS_FIELDS.some(
8788
(field) => field in record.raw && record.raw[field] !== null && record.raw[field] !== undefined
8889
);
@@ -91,7 +92,7 @@ const DegradedDocs = ({
9192
if (addIgnoredMetadataToQuery) {
9293
return (
9394
<Control
94-
css={{ color: euiThemeVars.euiColorDisabledText }} // Give same color as disabled
95+
css={{ color: euiTheme.colors.textDisabled }} // Give same color as disabled
9596
data-test-subj="docTableDegradedDocDisabled"
9697
iconType="indexClose"
9798
label={actionsHeaderAriaLabelDegradedAction}

src/platform/packages/shared/kbn-discover-utils/src/data_types/logs/components/log_level_badge.test.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,17 @@
99

1010
import { render, screen } from '@testing-library/react';
1111
import React from 'react';
12+
import { EuiProvider } from '@elastic/eui';
1213
import { LogLevelBadge } from './log_level_badge';
1314

1415
const renderBadge = (logLevel: string) => {
1516
render(
16-
<LogLevelBadge
17-
logLevel={logLevel}
18-
fallback={<span data-test-subj="logLevelBadge-unknown">{logLevel}</span>}
19-
/>
17+
<EuiProvider>
18+
<LogLevelBadge
19+
logLevel={logLevel}
20+
fallback={<span data-test-subj="logLevelBadge-unknown">{logLevel}</span>}
21+
/>
22+
</EuiProvider>
2023
);
2124
};
2225

src/platform/packages/shared/kbn-discover-utils/src/data_types/logs/components/log_level_badge.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88
*/
99

1010
import React, { ReactElement } from 'react';
11-
import { EuiBadge, EuiBadgeProps, mathWithUnits, useEuiTheme } from '@elastic/eui';
12-
import { CSSObject } from '@emotion/react';
13-
import { euiThemeVars } from '@kbn/ui-theme';
11+
import { EuiBadge, EuiBadgeProps, useEuiTheme, UseEuiTheme } from '@elastic/eui';
12+
import { css } from '@emotion/react';
1413
import { getLogLevelCoalescedValue, getLogLevelColor } from '../utils';
1514

16-
const badgeCss: CSSObject = {
17-
maxWidth: mathWithUnits(euiThemeVars.euiSize, (size) => size * 7.5),
18-
};
15+
const badgeCss = ({ euiTheme }: UseEuiTheme) => css`
16+
max-width: calc(${euiTheme.size.base} * 7.5);
17+
`;
1918

2019
export const LogLevelBadge = ({
2120
logLevel,

src/platform/packages/shared/kbn-discover-utils/tsconfig.json

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,12 @@
66
"jest",
77
"node",
88
"react",
9-
"@testing-library/jest-dom"
9+
"@testing-library/jest-dom",
10+
"../../../../../typings/emotion.d.ts"
1011
]
1112
},
12-
"include": [
13-
"**/*.ts",
14-
"**/*.tsx"
15-
],
16-
"exclude": [
17-
"target/**/*"
18-
],
13+
"include": ["**/*.ts", "**/*.tsx"],
14+
"exclude": ["target/**/*"],
1915
"kbn_references": [
2016
"@kbn/data-service",
2117
"@kbn/data-views-plugin",
@@ -27,7 +23,6 @@
2723
"@kbn/expressions-plugin",
2824
"@kbn/logs-data-access-plugin",
2925
"@kbn/i18n-react",
30-
"@kbn/navigation-plugin",
31-
"@kbn/ui-theme"
26+
"@kbn/navigation-plugin"
3227
]
3328
}

src/platform/packages/shared/kbn-unified-data-table/src/components/column_header_truncate_container.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
*/
99

1010
import React from 'react';
11-
import { EuiTextBlockTruncate } from '@elastic/eui';
11+
import { EuiTextBlockTruncate, useEuiTheme } from '@elastic/eui';
1212
import { css } from '@emotion/react';
13-
import { euiThemeVars } from '@kbn/ui-theme';
1413

1514
const ColumnHeaderTruncateContainer = ({
1615
headerRowHeight,
@@ -19,11 +18,13 @@ const ColumnHeaderTruncateContainer = ({
1918
headerRowHeight?: number;
2019
children: React.ReactNode;
2120
}) => {
21+
const { euiTheme } = useEuiTheme();
22+
2223
const headerCss = css`
2324
overflow-wrap: anywhere;
2425
white-space: normal;
2526
word-break: break-all;
26-
line-height: ${euiThemeVars.euiSize};
27+
line-height: ${euiTheme.size.base};
2728
text-align: left;
2829
.euiDataGridHeaderCell--numeric & {
2930
float: right;

src/platform/packages/shared/kbn-unified-data-table/src/components/data_table_column_header.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99

1010
import React, { useMemo } from 'react';
1111
import { css, CSSObject } from '@emotion/react';
12-
import { EuiIconTip } from '@elastic/eui';
12+
import { EuiIconTip, useEuiTheme } from '@elastic/eui';
1313
import type { DataView, DataViewField } from '@kbn/data-views-plugin/common';
1414
import { FieldIcon, getFieldIconProps, getTextBasedColumnIconType } from '@kbn/field-utils';
1515
import { isNestedFieldParent } from '@kbn/discover-utils';
1616
import { i18n } from '@kbn/i18n';
17-
import { euiThemeVars } from '@kbn/ui-theme';
1817
import type { DataTableColumnsMeta } from '../types';
1918
import ColumnHeaderTruncateContainer from './column_header_truncate_container';
2019

@@ -52,15 +51,14 @@ export const DataTableColumnHeader: React.FC<DataTableColumnHeaderProps> = ({
5251
const DataTableColumnToken: React.FC<
5352
Pick<DataTableColumnHeaderProps, 'columnName' | 'columnsMeta' | 'dataView'>
5453
> = (props) => {
54+
const { euiTheme } = useEuiTheme();
5555
const { columnName, columnsMeta, dataView } = props;
5656
const columnToken = useMemo(
5757
() => getRenderedToken({ columnName, columnsMeta, dataView }),
5858
[columnName, columnsMeta, dataView]
5959
);
6060

61-
return columnToken ? (
62-
<span css={{ paddingRight: euiThemeVars.euiSizeXS }}>{columnToken}</span>
63-
) : null;
61+
return columnToken ? <span css={{ paddingRight: euiTheme.size.xs }}>{columnToken}</span> : null;
6462
};
6563

6664
const DataTableColumnTitle: React.FC<Pick<DataTableColumnHeaderProps, 'columnDisplayName'>> = ({

src/platform/packages/shared/kbn-unified-data-table/src/components/row_height_settings.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99

1010
import React from 'react';
1111
import { i18n } from '@kbn/i18n';
12-
import { EuiButtonGroup, EuiFormRow, EuiRange, htmlIdGenerator } from '@elastic/eui';
13-
import { euiThemeVars } from '@kbn/ui-theme';
12+
import { EuiButtonGroup, EuiFormRow, EuiRange, htmlIdGenerator, useEuiTheme } from '@elastic/eui';
1413

1514
export enum RowHeightMode {
1615
auto = 'auto',
@@ -40,6 +39,8 @@ export function RowHeightSettings({
4039
maxRowHeight,
4140
['data-test-subj']: dataTestSubj,
4241
}: RowHeightSettingsProps) {
42+
const { euiTheme } = useEuiTheme();
43+
4344
const rowHeightModeOptions = [
4445
{
4546
id: `${idPrefix}${RowHeightMode.single}`,
@@ -95,7 +96,7 @@ export function RowHeightSettings({
9596
}}
9697
data-test-subj={`${dataTestSubj}_lineCountNumber`}
9798
css={{
98-
marginTop: compressed ? euiThemeVars.euiSizeXS : euiThemeVars.euiSizeM,
99+
marginTop: compressed ? euiTheme.size.xs : euiTheme.size.m,
99100
}}
100101
/>
101102
) : null}

src/platform/packages/shared/kbn-unified-data-table/tsconfig.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
"compilerOptions": {
44
"outDir": "target/types"
55
},
6-
"include": ["*.ts", "**/*.tsx", "src/**/*", "__mocks__/**/*.ts"],
7-
"exclude": [
8-
"target/**/*"
6+
"include": [
7+
"*.ts",
8+
"**/*.tsx",
9+
"src/**/*",
10+
"__mocks__/**/*.ts",
11+
"../../../../../typings/emotion.d.ts"
912
],
13+
"exclude": ["target/**/*"],
1014
"kbn_references": [
1115
"@kbn/i18n",
1216
"@kbn/data-views-plugin",
@@ -16,7 +20,6 @@
1620
"@kbn/expressions-plugin",
1721
"@kbn/test-jest-helpers",
1822
"@kbn/i18n-react",
19-
"@kbn/ui-theme",
2023
"@kbn/field-types",
2124
"@kbn/kibana-utils-plugin",
2225
"@kbn/cell-actions",
@@ -39,6 +42,6 @@
3942
"@kbn/unified-field-list",
4043
"@kbn/core-notifications-browser",
4144
"@kbn/core-capabilities-browser-mocks",
42-
"@kbn/sort-predicates",
45+
"@kbn/sort-predicates"
4346
]
4447
}

src/platform/packages/shared/kbn-unified-field-list/src/components/field_popover/field_popover.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ import {
1515
EuiPopoverProps,
1616
EuiPopoverTitle,
1717
} from '@elastic/eui';
18+
import { css } from '@emotion/react';
19+
1820
import './field_popover.scss';
19-
import { euiThemeVars } from '@kbn/ui-theme';
2021

2122
export interface FieldPopoverProps extends EuiPopoverProps {
2223
renderHeader?: () => React.ReactNode;
@@ -80,10 +81,10 @@ export const FieldPopover: React.FC<FieldPopoverProps> = ({
8081
{content ? (
8182
<EuiFlexItem
8283
className="eui-yScrollWithShadows"
83-
css={{
84-
padding: euiThemeVars.euiSize,
85-
margin: `-${euiThemeVars.euiSize}`,
86-
}}
84+
css={({ euiTheme }) => css`
85+
padding: ${euiTheme.size.base};
86+
margin: -${euiTheme.size.base};
87+
`}
8788
>
8889
{content}
8990
</EuiFlexItem>

0 commit comments

Comments
 (0)