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

[ML] EUI Visual Refresh (tokens) #203518

Merged
merged 55 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
53841ed
theme fixes
walterra Dec 9, 2024
2ed192b
wip: ner output fixes
walterra Dec 9, 2024
8344d67
ner_output color fixes
walterra Dec 10, 2024
a1ec963
qa_output color fixes
walterra Dec 10, 2024
ae7f54d
update time series explorer styles
walterra Dec 11, 2024
ea7175b
euiColorVis*
walterra Dec 11, 2024
5f1d0f7
tabColor
walterra Dec 11, 2024
a7e5ed2
euiColorVis*
walterra Dec 11, 2024
0ff287d
remove useCurrentEuiTheme()
walterra Dec 11, 2024
6f414b4
remove useCurrentEuiThemeVars()
walterra Dec 11, 2024
14c4402
linting
walterra Dec 11, 2024
a664eee
simplify border
walterra Dec 12, 2024
296b30e
Merge branch 'main' into ml-borealis-fixes-color-palettes
walterra Dec 13, 2024
904b773
border color tweaks
walterra Dec 13, 2024
ec09453
fix NER badge colors
walterra Dec 13, 2024
d395b77
fix QA colors
walterra Dec 13, 2024
c31516b
disable scatterplot assertions
walterra Dec 13, 2024
3e84642
disable canvas element color assertions
walterra Dec 13, 2024
cc2f35e
Merge branch 'main' into ml-borealis-fixes-color-palettes
walterra Dec 13, 2024
6926c28
fix assertions
walterra Dec 16, 2024
47ab04c
Merge branch 'main' into ml-borealis-fixes-color-palettes
walterra Dec 16, 2024
d5f049c
migrate data_grid/hooks/use_column_chart
walterra Dec 16, 2024
3a8ee32
migrate option_list_popover_footer.tsx
walterra Dec 16, 2024
ac704bf
migrate file_data_visualizer/components/about_panel/about_panel.tsx
walterra Dec 16, 2024
f4d4f51
migrate file_data_visualizer/components/about_panel/welcome_content.tsx
walterra Dec 16, 2024
da30f7a
migrate data_visualizer/public/application/file_data_visualizer/compo…
walterra Dec 16, 2024
6ba3995
migrate field_stats_initializer.tsx
walterra Dec 16, 2024
53fec1e
migrate log_rate_analysis_embeddable_initializer.tsx
walterra Dec 16, 2024
89317f4
embeddables/pattern_analysis/pattern_analysis_initializer.tsx
walterra Dec 16, 2024
0b31d30
migrate /ml_inference/components/test_pipeline.tsx
walterra Dec 16, 2024
84ea0e6
linting
walterra Dec 16, 2024
347619d
migrate decision_path_chart.tsx
walterra Dec 16, 2024
ebeafc9
migrate /feature_importance_summary.tsx
walterra Dec 16, 2024
f9f0a06
linting
walterra Dec 16, 2024
cbb6e5f
Merge branch 'main' into ml-borealis-fixes-color-palettes
walterra Dec 17, 2024
368ebd0
formMaxWidth
walterra Dec 17, 2024
91120b6
euiColorVis use_color_range.ts
walterra Dec 17, 2024
f115be5
euiColorVis use_data_viz_chart_theme.ts
walterra Dec 17, 2024
d7eaf30
euiColorVis use_data_drift_colors.ts
walterra Dec 17, 2024
e0b73f6
euiColorVis event_rate_chart.tsx
walterra Dec 17, 2024
f30a476
euiColorVis group_color_utils.ts
walterra Dec 17, 2024
f0a5893
euiColorVis use_color_range.ts
walterra Dec 17, 2024
db1f8a3
euiColorVis cytoscape_options.tsx
walterra Dec 17, 2024
de6695a
euiColorVis /job_map/components/legend.tsx
walterra Dec 17, 2024
86a0d8e
euiColorVis jobs_list/components/datafeed_chart_flyout/datafeed_chart…
walterra Dec 17, 2024
f3d368f
euiColorVis ner_output.tsx
walterra Dec 17, 2024
9d0ce59
euiColorVis question_answering_output.tsx
walterra Dec 17, 2024
199f989
euiColorVis forecastColor
walterra Dec 17, 2024
4814bd8
refactor _top_values.scss to emotion
walterra Dec 17, 2024
3de1397
fix barColor in field stats expanded row
walterra Dec 17, 2024
4372840
remove obsolete scss
walterra Dec 17, 2024
d4346ac
fix chart colors
walterra Dec 17, 2024
8250674
fix analytics map colors
walterra Dec 17, 2024
532f718
fix NER badge colors (again)
walterra Dec 18, 2024
dc5b902
revert change to euiBorderThin
walterra Dec 18, 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
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
getSnappedTimestamps,
getSnappedWindowParameters,
getWindowParametersForTrigger,
useLogRateAnalysisBarColors,
type DocumentCountStatsChangePoint,
type LogRateHistogramItem,
type WindowParameters,
Expand Down Expand Up @@ -198,6 +199,7 @@ export const DocumentCountChart: FC<DocumentCountChartProps> = (props) => {
const { data, uiSettings, fieldFormats, charts } = dependencies;

const chartBaseTheme = charts.theme.useChartsBaseTheme();
const barColors = useLogRateAnalysisBarColors();

const xAxisFormatter = fieldFormats.deserialize({ id: 'date' });
const useLegacyTimeAxis = uiSettings.get('visualization:useLegacyTimeAxis', false);
Expand Down Expand Up @@ -422,8 +424,10 @@ export const DocumentCountChart: FC<DocumentCountChartProps> = (props) => {
const baselineBadgeMarginLeft =
(mlBrushMarginLeft ?? 0) + (windowParametersAsPixels?.baselineMin ?? 0);

const barColor = barColorOverride ? [barColorOverride] : undefined;
const barHighlightColor = barHighlightColorOverride ? [barHighlightColorOverride] : ['orange'];
const barColor = barColorOverride ? [barColorOverride] : barColors.barColor;
const barHighlightColor = barHighlightColorOverride
? [barHighlightColorOverride]
: [barColors.barHighlightColor];

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { render, renderHook } from '@testing-library/react';

import { KBN_FIELD_TYPES } from '@kbn/field-types';

import type { EuiThemeComputed } from '@elastic/eui';

import type {
NumericChartData,
OrdinalChartData,
Expand All @@ -23,6 +25,10 @@ import {

import { getFieldType, getLegendText, getXScaleType, useColumnChart } from './use_column_chart';

const euiThemeMock = {
size: { base: '16px' },
} as EuiThemeComputed;

describe('getFieldType()', () => {
it('should return the Kibana field type for a given EUI data grid schema', () => {
expect(getFieldType('text')).toBe('string');
Expand Down Expand Up @@ -103,63 +109,81 @@ describe('isUnsupportedChartData()', () => {

describe('getLegendText()', () => {
it('should return the chart legend text for unsupported chart types', () => {
expect(getLegendText(validUnsupportedChartData)).toBe('Chart not supported.');
expect(getLegendText(validUnsupportedChartData, euiThemeMock)).toBe('Chart not supported.');
});
it('should return the chart legend text for empty datasets', () => {
expect(getLegendText(validNumericChartData)).toBe('0 documents contain field.');
expect(getLegendText(validNumericChartData, euiThemeMock)).toBe('0 documents contain field.');
});
it('should return the chart legend text for boolean chart types', () => {
const { getByText } = render(
<>
{getLegendText({
{getLegendText(
{
cardinality: 2,
data: [
{ key: 'true', key_as_string: 'true', doc_count: 10 },
{ key: 'false', key_as_string: 'false', doc_count: 20 },
],
id: 'the-id',
type: 'boolean',
})}
},
euiThemeMock
)}
</>
);
expect(getByText('true')).toBeInTheDocument();
expect(getByText('false')).toBeInTheDocument();
});
it('should return the chart legend text for ordinal chart data with less than max categories', () => {
expect(getLegendText({ ...validOrdinalChartData, data: [{ key: 'cat', doc_count: 10 }] })).toBe(
'10 categories'
);
expect(
getLegendText(
{ ...validOrdinalChartData, data: [{ key: 'cat', doc_count: 10 }] },
euiThemeMock
)
).toBe('10 categories');
});
it('should return the chart legend text for ordinal chart data with more than max categories', () => {
expect(
getLegendText({
getLegendText(
{
...validOrdinalChartData,
cardinality: 30,
data: [{ key: 'cat', doc_count: 10 }],
})
},
euiThemeMock
)
).toBe('top 20 of 30 categories');
});
it('should return the chart legend text for numeric datasets', () => {
expect(
getLegendText({
getLegendText(
{
...validNumericChartData,
data: [{ key: 1, doc_count: 10 }],
stats: [1, 100],
})
},
euiThemeMock
)
).toBe('1 - 100');
expect(
getLegendText({
getLegendText(
{
...validNumericChartData,
data: [{ key: 1, doc_count: 10 }],
stats: [100, 100],
})
},
euiThemeMock
)
).toBe('100');
expect(
getLegendText({
getLegendText(
{
...validNumericChartData,
data: [{ key: 1, doc_count: 10 }],
stats: [1.2345, 6.3456],
})
},
euiThemeMock
)
).toBe('1.23 - 6.35');
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ import { css } from '@emotion/react';

import useObservable from 'react-use/lib/useObservable';

import { euiPaletteColorBlind, type EuiDataGridColumn } from '@elastic/eui';
import {
useEuiTheme,
euiPaletteColorBlind,
type EuiDataGridColumn,
type EuiThemeComputed,
} from '@elastic/eui';

import { euiThemeVars } from '@kbn/ui-theme';
import { i18n } from '@kbn/i18n';
import { KBN_FIELD_TYPES } from '@kbn/field-types';

Expand All @@ -29,14 +33,6 @@ import { isNumericChartData, isOrdinalChartData } from '../lib/field_histograms'
import { NON_AGGREGATABLE } from '../lib/common';
import type { DataGridItem } from '../lib/types';

const cssHistogramLegendBoolean = css({
width: '100%',
// This was originally $euiButtonMinWidth, but that
// is no longer exported from the EUI package,
// so we're replicating it here inline.
minWidth: `calc(${euiThemeVars.euiSize} * 7)`,
});

const cssTextAlignCenter = css({
textAlign: 'center',
});
Expand Down Expand Up @@ -97,6 +93,7 @@ export const getFieldType = (schema: EuiDataGridColumn['schema']): KBN_FIELD_TYP
type LegendText = string | JSX.Element;
export const getLegendText = (
chartData: ChartData,
euiTheme: EuiThemeComputed,
maxChartColumns = MAX_CHART_COLUMNS
): LegendText => {
if (chartData.type === 'unsupported') {
Expand All @@ -112,6 +109,14 @@ export const getLegendText = (
}

if (chartData.type === 'boolean') {
const cssHistogramLegendBoolean = css({
width: '100%',
// This was originally $euiButtonMinWidth, but that
// is no longer exported from the EUI package,
// so we're replicating it here inline.
minWidth: `calc(${euiTheme.size.base} * 7)`,
});

return (
<table css={cssHistogramLegendBoolean}>
<tbody>
Expand Down Expand Up @@ -171,6 +176,8 @@ export const useColumnChart = (
columnType: EuiDataGridColumn,
maxChartColumns?: number
): ColumnChart => {
const { euiTheme } = useEuiTheme();

const fieldType = getFieldType(columnType.schema);

const hoveredRow = useObservable(hoveredRow$);
Expand Down Expand Up @@ -231,7 +238,7 @@ export const useColumnChart = (

return {
data,
legendText: getLegendText(chartData, maxChartColumns),
legendText: getLegendText(chartData, euiTheme, maxChartColumns),
xScaleType,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"@kbn/ml-agg-utils",
"@kbn/ml-error-utils",
"@kbn/ml-data-frame-analytics-utils",
"@kbn/ui-theme",
"@kbn/i18n-react",
"@kbn/ml-is-populated-object",
"@kbn/ml-date-picker",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import type { PropsWithChildren, FC } from 'react';
import React, { useCallback, useState } from 'react';
import type { ThemeServiceStart } from '@kbn/core-theme-browser';
import type { DataView } from '@kbn/data-plugin/common';
import type { FieldStatsServices } from '@kbn/unified-field-list/src/components/field_stats';
import type { TimeRange as TimeRangeMs } from '@kbn/ml-date-picker';
Expand Down Expand Up @@ -36,7 +35,6 @@ import { PopulatedFieldsCacheManager } from './populated_fields/populated_fields
export type FieldStatsFlyoutProviderProps = PropsWithChildren<{
dataView: DataView;
fieldStatsServices: FieldStatsServices;
theme: ThemeServiceStart;
timeRangeMs?: TimeRangeMs;
dslQuery?: FieldStatsProps['dslQuery'];
disablePopulatedFields?: boolean;
Expand Down Expand Up @@ -65,7 +63,6 @@ export const FieldStatsFlyoutProvider: FC<FieldStatsFlyoutProviderProps> = (prop
const {
dataView,
fieldStatsServices,
theme,
timeRangeMs,
dslQuery,
disablePopulatedFields = false,
Expand Down Expand Up @@ -174,7 +171,6 @@ export const FieldStatsFlyoutProvider: FC<FieldStatsFlyoutProviderProps> = (prop
fieldValue,
timeRangeMs,
populatedFields,
theme,
}}
>
<FieldStatsFlyout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@
* 2.0.
*/

import { EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiToolTip, EuiText } from '@elastic/eui';
import {
useEuiTheme,
EuiButtonIcon,
EuiFlexGroup,
EuiFlexItem,
EuiToolTip,
EuiText,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React, { type FC } from 'react';
import { FieldIcon } from '@kbn/react-field';
import { type Field } from '@kbn/ml-anomaly-utils';
import { useCurrentEuiThemeVars } from '@kbn/ml-kibana-theme';
import { useFieldStatsFlyoutThemeVars } from './use_field_stats_flyout_context';

import { getKbnFieldIconType } from './get_kbn_field_icon_types';

Expand Down Expand Up @@ -71,8 +76,7 @@ export interface FieldStatsInfoButtonProps {
*/
export const FieldStatsInfoButton: FC<FieldStatsInfoButtonProps> = (props) => {
const { field, label, onButtonClick, disabled, isEmpty, hideTrigger } = props;
const theme = useFieldStatsFlyoutThemeVars();
const themeVars = useCurrentEuiThemeVars(theme);
const { euiTheme } = useEuiTheme();

const emptyFieldMessage = isEmpty
? ' ' +
Expand Down Expand Up @@ -100,7 +104,7 @@ export const FieldStatsInfoButton: FC<FieldStatsInfoButtonProps> = (props) => {
disabled={disabled === true}
size="xs"
iconType="fieldStatistics"
css={{ color: isEmpty ? themeVars.euiTheme.euiColorDisabled : undefined }}
css={{ color: isEmpty ? euiTheme.colors.textDisabled : undefined }}
onClick={(ev: React.MouseEvent<HTMLButtonElement>) => {
if (ev.type === 'click') {
ev.currentTarget.focus();
Expand All @@ -127,12 +131,12 @@ export const FieldStatsInfoButton: FC<FieldStatsInfoButtonProps> = (props) => {
<EuiFlexItem
grow={false}
css={{
paddingRight: themeVars.euiTheme.euiSizeXS,
paddingRight: euiTheme.size.xs,
}}
>
{!hideTrigger ? (
<FieldIcon
color={isEmpty ? themeVars.euiTheme.euiColorDisabled : undefined}
color={isEmpty ? euiTheme.colors.textDisabled : undefined}
type={getKbnFieldIconType(field.type)}
fill="none"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,26 @@
*/
import React from 'react';
import type { FC } from 'react';
import { EuiPopoverFooter, EuiSwitch, EuiProgress, useEuiBackgroundColor } from '@elastic/eui';
import { EuiPopoverFooter, EuiSwitch, EuiProgress, useEuiTheme } from '@elastic/eui';
import { css } from '@emotion/react';
import { i18n } from '@kbn/i18n';
import { euiThemeVars } from '@kbn/ui-theme';

export const OptionsListPopoverFooter: FC<{
showEmptyFields: boolean;
setShowEmptyFields: (showEmptyFields: boolean) => void;
isLoading?: boolean;
}> = ({ showEmptyFields, setShowEmptyFields, isLoading }) => {
const { euiTheme } = useEuiTheme();

return (
<EuiPopoverFooter
paddingSize="none"
css={css({
height: euiThemeVars.euiButtonHeight,
backgroundColor: useEuiBackgroundColor('subdued'),
height: euiTheme.size.xxl,
backgroundColor: euiTheme.colors.backgroundBaseSubdued,
alignItems: 'center',
display: 'flex',
paddingLeft: euiThemeVars.euiSizeS,
paddingLeft: euiTheme.size.s,
})}
>
{isLoading ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@
"@kbn/i18n",
"@kbn/react-field",
"@kbn/ml-anomaly-utils",
"@kbn/ml-kibana-theme",
"@kbn/ml-data-grid",
"@kbn/ml-string-hash",
"@kbn/ml-is-populated-object",
"@kbn/ml-query-utils",
"@kbn/ml-is-defined",
"@kbn/field-types",
"@kbn/ui-theme",
"@kbn/core-theme-browser",
]
}
Loading
Loading