mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[DataDiscovery] Remove color functions in favor of color tokens where possible (#208901)
## Summary Closes #205841 205841 All Data Discovery usage of color functions removed in favor of color tokens. ``` shade() tint() shadeOrTint() tintOrShade() transparentize() ``` As per [EUI guide](https://github.com/elastic/kibana/issues/199715) (`(Important) Replace color calculation functions with semantic tokens` section) some colors are not 1:1, but rather a token matching the function of the element. I was following this guide and tried to make it consistent, I'm open for suggestions though, in case some color should be different. ### 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/src/platform/packages/shared/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) ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ...
This commit is contained in:
parent
2bf8a24c5c
commit
b4a2009325
9 changed files with 36 additions and 20 deletions
|
@ -79,7 +79,7 @@
|
|||
}
|
||||
|
||||
.euiDataGrid--rowHoverHighlight .euiDataGridRow:hover {
|
||||
background-color: $euiColorBackgroundBaseInteractiveHover;
|
||||
background-color: $euiColorLightestShade; // we keep using a deprecated shade until a proper token is available
|
||||
}
|
||||
|
||||
.euiDataGrid__scrollOverlay .euiDataGrid__scrollBarOverlayRight {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
import { useContext, useEffect, useMemo } from 'react';
|
||||
import type { EuiDataGridCellValueElementProps } from '@elastic/eui';
|
||||
import { EuiDataGridCellValueElementProps, useEuiTheme } from '@elastic/eui';
|
||||
import type { DataTableRecord } from '@kbn/discover-utils';
|
||||
import { UnifiedDataTableContext } from '../table_context';
|
||||
|
||||
|
@ -21,11 +21,14 @@ export const useControlColumn = ({
|
|||
} => {
|
||||
const { expanded, getRowByIndex } = useContext(UnifiedDataTableContext);
|
||||
const record = useMemo(() => getRowByIndex(rowIndex), [getRowByIndex, rowIndex]);
|
||||
const { euiTheme } = useEuiTheme();
|
||||
const { backgroundBasePrimary: anchorColor } = euiTheme.colors;
|
||||
|
||||
useEffect(() => {
|
||||
if (record?.isAnchor) {
|
||||
setCellProps({
|
||||
className: 'unifiedDataTable__cell--highlight',
|
||||
css: { backgroundColor: anchorColor },
|
||||
});
|
||||
} else if (expanded && record && expanded.id === record.id) {
|
||||
setCellProps({
|
||||
|
@ -36,7 +39,7 @@ export const useControlColumn = ({
|
|||
className: '',
|
||||
});
|
||||
}
|
||||
}, [expanded, record, setCellProps]);
|
||||
}, [expanded, record, setCellProps, anchorColor]);
|
||||
|
||||
return useMemo(() => ({ record, rowIndex }), [record, rowIndex]);
|
||||
};
|
||||
|
|
|
@ -15,6 +15,7 @@ import {
|
|||
EuiFlexGroup,
|
||||
EuiFlexItem,
|
||||
EuiDataGridCellValueElementProps,
|
||||
useEuiTheme,
|
||||
} from '@elastic/eui';
|
||||
import type { FieldFormatsStart } from '@kbn/field-formats-plugin/public';
|
||||
import type { DataTableRecord, ShouldShowFieldInTableHandler } from '@kbn/discover-utils/types';
|
||||
|
@ -62,11 +63,14 @@ export const getRenderCellValueFn = ({
|
|||
const row = rows ? rows[rowIndex] : undefined;
|
||||
const field = dataView.fields.getByName(columnId);
|
||||
const ctx = useContext(UnifiedDataTableContext);
|
||||
const { euiTheme } = useEuiTheme();
|
||||
const { backgroundBasePrimary: anchorColor } = euiTheme.colors;
|
||||
|
||||
useEffect(() => {
|
||||
if (row?.isAnchor) {
|
||||
setCellProps({
|
||||
className: 'unifiedDataTable__cell--highlight',
|
||||
css: { backgroundColor: anchorColor },
|
||||
});
|
||||
} else if (ctx.expanded && row && ctx.expanded.id === row.id) {
|
||||
setCellProps({
|
||||
|
@ -75,7 +79,7 @@ export const getRenderCellValueFn = ({
|
|||
} else {
|
||||
setCellProps({ style: undefined });
|
||||
}
|
||||
}, [ctx, row, setCellProps]);
|
||||
}, [ctx, row, setCellProps, anchorColor]);
|
||||
|
||||
if (typeof row === 'undefined') {
|
||||
return <span className={CELL_CLASS}>-</span>;
|
||||
|
|
|
@ -74,7 +74,6 @@
|
|||
}
|
||||
|
||||
.unifiedFieldListItemButton--missing {
|
||||
background: lightOrDarkTheme(transparentize($euiColorMediumShade, .9), $euiColorEmptyShade);
|
||||
color: $euiColorDarkShade;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,12 +20,6 @@ $previewShowMoreHeight: 40px; /* [2] */
|
|||
align-items: center;
|
||||
overflow: hidden;
|
||||
|
||||
&--highlighted {
|
||||
$backgroundColor: tintOrShade($euiColorPrimary, 90%, 70%);
|
||||
background: $backgroundColor;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
&__key, &__value {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,9 @@ import {
|
|||
EuiButtonEmpty,
|
||||
EuiBadge,
|
||||
EuiTextColor,
|
||||
useEuiTheme,
|
||||
} from '@elastic/eui';
|
||||
import { css } from '@emotion/react';
|
||||
|
||||
import { useFieldPreviewContext } from '../field_preview_context';
|
||||
import { IsUpdatingIndicator } from '../is_updating_indicator';
|
||||
|
@ -43,6 +45,7 @@ export const PreviewListItem: React.FC<PreviewListItemProps> = ({
|
|||
hasScriptError,
|
||||
isFromScript = false,
|
||||
}) => {
|
||||
const { euiTheme } = useEuiTheme();
|
||||
const { controller } = useFieldPreviewContext();
|
||||
const isLoadingPreview = useStateSelector(controller.state$, isLoadingPreviewSelector);
|
||||
|
||||
|
@ -143,7 +146,20 @@ export const PreviewListItem: React.FC<PreviewListItemProps> = ({
|
|||
|
||||
return (
|
||||
<>
|
||||
<EuiFlexGroup className={classes} gutterSize="none" data-test-subj="listItem">
|
||||
<EuiFlexGroup
|
||||
className={classes}
|
||||
// highlights the field using token, TODO: migrate whole SCSS file to emotions
|
||||
css={
|
||||
isFromScript
|
||||
? css`
|
||||
background-color: ${euiTheme.colors.backgroundBasePrimary};
|
||||
font-weight: ${euiTheme.font.weight.bold};
|
||||
`
|
||||
: undefined
|
||||
}
|
||||
gutterSize="none"
|
||||
data-test-subj="listItem"
|
||||
>
|
||||
<EuiFlexItem className="indexPatternFieldEditor__previewFieldList__item__key">
|
||||
<div
|
||||
className="indexPatternFieldEditor__previewFieldList__item__key__wrapper"
|
||||
|
|
|
@ -13,8 +13,4 @@
|
|||
.dscDocsGrid {
|
||||
flex: 1 1 100%;
|
||||
overflow: auto;
|
||||
|
||||
.unifiedDataTable__cell--highlight {
|
||||
background-color: tintOrShade($euiColorPrimary, 90%, 70%);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,10 +23,6 @@
|
|||
border-bottom: $euiBorderThin;
|
||||
}
|
||||
|
||||
&.euiDataGrid--rowHoverHighlight .euiDataGridRow:hover {
|
||||
background-color: tintOrShade($euiColorLightShade, 50%, 0);
|
||||
}
|
||||
|
||||
& [data-gridcell-column-id='name'] .euiDataGridRowCell__content {
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
|
|
|
@ -25,6 +25,7 @@ import {
|
|||
useResizeObserver,
|
||||
EuiSwitch,
|
||||
EuiSwitchEvent,
|
||||
useEuiTheme,
|
||||
} from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { css } from '@emotion/react';
|
||||
|
@ -129,6 +130,7 @@ export const DocViewerTable = ({
|
|||
onAddColumn,
|
||||
onRemoveColumn,
|
||||
}: DocViewRenderProps) => {
|
||||
const { euiTheme } = useEuiTheme();
|
||||
const isEsqlMode = Array.isArray(textBasedHits);
|
||||
const [containerRef, setContainerRef] = useState<HTMLDivElement | null>(null);
|
||||
const { fieldFormats, storage, uiSettings } = getUnifiedDocViewerServices();
|
||||
|
@ -511,6 +513,12 @@ export const DocViewerTable = ({
|
|||
css={css`
|
||||
min-block-size: 0;
|
||||
display: block;
|
||||
.euiDataGridRow {
|
||||
&:hover {
|
||||
// we keep using a deprecated shade until proper token is available
|
||||
background-color: ${euiTheme.colors.lightestShade};
|
||||
}
|
||||
}
|
||||
`}
|
||||
>
|
||||
<EuiDataGrid
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue