diff --git a/x-pack/platform/plugins/shared/maps/public/classes/styles/vector/components/color/other_category_color_picker.tsx b/x-pack/platform/plugins/shared/maps/public/classes/styles/vector/components/color/other_category_color_picker.tsx index f4c538ef72f4b..c602e458df98c 100644 --- a/x-pack/platform/plugins/shared/maps/public/classes/styles/vector/components/color/other_category_color_picker.tsx +++ b/x-pack/platform/plugins/shared/maps/public/classes/styles/vector/components/color/other_category_color_picker.tsx @@ -6,19 +6,10 @@ */ import React from 'react'; -import { euiThemeVars } from '@kbn/ui-theme'; -import { EuiFormRow, EuiToolTip } from '@elastic/eui'; +import { EuiFormRow, EuiToolTip, useEuiTheme } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { MbValidatedColorPicker } from './mb_validated_color_picker'; -import { OTHER_CATEGORY_LABEL, OTHER_CATEGORY_DEFAULT_COLOR } from '../../style_util'; - -const OTHER_CATEGORY_SWATCHES = [ - euiThemeVars.euiColorLightestShade, - euiThemeVars.euiColorLightShade, - euiThemeVars.euiColorMediumShade, - euiThemeVars.euiColorDarkShade, - euiThemeVars.euiColorDarkestShade, -]; +import { OTHER_CATEGORY_DEFAULT_COLOR, OTHER_CATEGORY_LABEL } from '../../style_util'; interface Props { onChange: (color: string) => void; @@ -26,6 +17,16 @@ interface Props { } export function OtherCategoryColorPicker(props: Props) { + const { euiTheme } = useEuiTheme(); + + const OTHER_CATEGORY_SWATCHES = [ + euiTheme.colors.textInverse, + euiTheme.colors.textDisabled, + euiTheme.colors.textSubdued, + euiTheme.colors.textParagraph, + euiTheme.colors.textHeading, + ]; + return ( - - - - - - - - - - - - - - - + + + `; @@ -197,201 +128,86 @@ exports[`Should render legend 1`] = ` height={71} xmlns="http://www.w3.org/2000/svg" > - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + `; @@ -434,84 +250,38 @@ exports[`Should render legend with 2 markers when size difference does not provi height={37} xmlns="http://www.w3.org/2000/svg" > - - - - - - - - - - + + `; @@ -554,123 +324,54 @@ exports[`Should render legend with 3 markers when size difference does not provi height={55} xmlns="http://www.w3.org/2000/svg" > - - - - - - - - - - - - - - - + + + `; @@ -713,45 +414,22 @@ exports[`Should render legend with only max marker when size difference does not height={29} xmlns="http://www.w3.org/2000/svg" > - - - - - + `; @@ -794,84 +472,38 @@ exports[`Should render legend without label cutoff when min size is 1 1`] = ` height={21} xmlns="http://www.w3.org/2000/svg" > - - - - - - - - - - + + `; @@ -914,45 +546,22 @@ exports[`Should render max label with std clamp notification 1`] = ` height={29} xmlns="http://www.w3.org/2000/svg" > - - - - - + `; diff --git a/x-pack/platform/plugins/shared/maps/public/classes/styles/vector/components/legend/size/map_marker.tsx b/x-pack/platform/plugins/shared/maps/public/classes/styles/vector/components/legend/size/map_marker.tsx new file mode 100644 index 0000000000000..b91cc78575499 --- /dev/null +++ b/x-pack/platform/plugins/shared/maps/public/classes/styles/vector/components/legend/size/map_marker.tsx @@ -0,0 +1,67 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { FC, CSSProperties } from 'react'; +import { useEuiTheme } from '@elastic/eui'; +import { RightAlignedText } from '../right_aligned_text'; + +const FONT_SIZE = 10; + +interface Props { + radius: number; + circleCenterX: number; + circleTopY: number; + textOffset: number; + textY: number; + formattedValue: string | number; + circleCenterY: number; + circleStyle: CSSProperties; + onWidthChange: (width: number) => void; +} + +export const MapMarker: FC = ({ + circleCenterX, + circleCenterY, + circleTopY, + formattedValue, + radius, + textOffset, + textY, + onWidthChange, +}) => { + const { euiTheme } = useEuiTheme(); + const circleStyle = { + fillOpacity: 0, + stroke: euiTheme.colors.textParagraph, + strokeWidth: 1, + }; + + return ( + + + + + + ); +}; diff --git a/x-pack/platform/plugins/shared/maps/public/classes/styles/vector/components/legend/size/marker_size_legend.tsx b/x-pack/platform/plugins/shared/maps/public/classes/styles/vector/components/legend/size/marker_size_legend.tsx index c00557a2d1382..59d191e889a53 100644 --- a/x-pack/platform/plugins/shared/maps/public/classes/styles/vector/components/legend/size/marker_size_legend.tsx +++ b/x-pack/platform/plugins/shared/maps/public/classes/styles/vector/components/legend/size/marker_size_legend.tsx @@ -7,13 +7,12 @@ import React, { Component } from 'react'; import _ from 'lodash'; -import { euiThemeVars } from '@kbn/ui-theme'; import { EuiFlexGroup, EuiFlexItem, EuiText, EuiToolTip } from '@elastic/eui'; import { RangeFieldMeta } from '../../../../../../../common/descriptor_types'; import { DynamicSizeProperty } from '../../../properties/dynamic_size_property'; -import { RightAlignedText } from '../right_aligned_text'; import { getMaxLabel, getMinLabel } from './get_ordinal_label'; import { type Marker, MarkerList } from './marker_list'; +import { MapMarker } from './map_marker'; const FONT_SIZE = 10; const HALF_FONT_SIZE = FONT_SIZE / 2; @@ -96,7 +95,6 @@ export class MarkerSizeLegend extends Component { const circleStyle = { fillOpacity: 0, - stroke: euiThemeVars.euiTextColor, strokeWidth: 1, }; @@ -110,25 +108,20 @@ export class MarkerSizeLegend extends Component { const textOffset = this.state.maxLabelWidth + HALF_FONT_SIZE; const rawTextY = circleTopY + HALF_FONT_SIZE; const textY = rawTextY > svgHeight ? svgHeight : rawTextY; + return { svg: ( - - - - - + ), textY, }; diff --git a/x-pack/platform/plugins/shared/maps/public/classes/styles/vector/components/legend/vector_style_legend.tsx b/x-pack/platform/plugins/shared/maps/public/classes/styles/vector/components/legend/vector_style_legend.tsx index afe1bbe194636..8f8735459a4a3 100644 --- a/x-pack/platform/plugins/shared/maps/public/classes/styles/vector/components/legend/vector_style_legend.tsx +++ b/x-pack/platform/plugins/shared/maps/public/classes/styles/vector/components/legend/vector_style_legend.tsx @@ -6,8 +6,7 @@ */ import React from 'react'; -import { EuiText } from '@elastic/eui'; -import { euiThemeVars } from '@kbn/ui-theme'; +import { EuiText, useEuiTheme } from '@elastic/eui'; import { StyleError } from './style_error'; import { DynamicStyleProperty, @@ -36,6 +35,7 @@ export function VectorStyleLegend({ svg, }: Props) { const legendRows = []; + const { euiTheme } = useEuiTheme(); for (let i = 0; i < styles.length; i++) { const styleMetaDataRequest = styles[i].isDynamic() @@ -89,10 +89,7 @@ export function VectorStyleLegend({
    {masksByFieldOrigin.map((mask) => ( -
  • +
  • { return new DynamicColorProperty( @@ -575,7 +576,7 @@ describe('get mapbox color expression (via internal _getMbColor)', () => { fieldMetaOptions, }; const colorProperty = makeProperty(dynamicStyleOptions); - expect(colorProperty._getMbColor()).toBe('#d3dae6'); + expect(colorProperty._getMbColor()).toBe(OTHER_CATEGORY_DEFAULT_COLOR); }); test('should return "other category" color when field name is not provided', async () => { @@ -586,7 +587,7 @@ describe('get mapbox color expression (via internal _getMbColor)', () => { }; // @ts-expect-error - test is verifing behavior when field is invalid. const colorProperty = makeProperty(dynamicStyleOptions); - expect(colorProperty._getMbColor()).toBe('#d3dae6'); + expect(colorProperty._getMbColor()).toBe(OTHER_CATEGORY_DEFAULT_COLOR); }); describe('pre-defined color palette', () => { @@ -596,7 +597,7 @@ describe('get mapbox color expression (via internal _getMbColor)', () => { fieldMetaOptions, }; const colorProperty = makeProperty(dynamicStyleOptions); - expect(colorProperty._getMbColor()).toBe('#d3dae6'); + expect(colorProperty._getMbColor()).toBe(OTHER_CATEGORY_DEFAULT_COLOR); }); test('should return mapbox expression for color palette', async () => { @@ -627,7 +628,7 @@ describe('get mapbox color expression (via internal _getMbColor)', () => { fieldMetaOptions, }; const colorProperty = makeProperty(dynamicStyleOptions); - expect(colorProperty._getMbColor()).toBe('#d3dae6'); + expect(colorProperty._getMbColor()).toBe(OTHER_CATEGORY_DEFAULT_COLOR); }); test('should return "other category" color when customColorPalette is empty', async () => { @@ -638,7 +639,7 @@ describe('get mapbox color expression (via internal _getMbColor)', () => { fieldMetaOptions, }; const colorProperty = makeProperty(dynamicStyleOptions); - expect(colorProperty._getMbColor()).toBe('#d3dae6'); + expect(colorProperty._getMbColor()).toBe(OTHER_CATEGORY_DEFAULT_COLOR); }); test('should return mapbox expression for custom color palette', async () => { diff --git a/x-pack/platform/plugins/shared/maps/public/classes/styles/vector/properties/dynamic_color_property.tsx b/x-pack/platform/plugins/shared/maps/public/classes/styles/vector/properties/dynamic_color_property.tsx index f1a55b571e27d..9095492074490 100644 --- a/x-pack/platform/plugins/shared/maps/public/classes/styles/vector/properties/dynamic_color_property.tsx +++ b/x-pack/platform/plugins/shared/maps/public/classes/styles/vector/properties/dynamic_color_property.tsx @@ -10,7 +10,12 @@ import React from 'react'; import { EuiTextColor } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { DynamicStyleProperty, OTHER_CATEGORY_KEY } from './dynamic_style_property'; -import { makeMbClampedNumberExpression, dynamicRound } from '../style_util'; +import { + makeMbClampedNumberExpression, + dynamicRound, + OTHER_CATEGORY_DEFAULT_COLOR, + OTHER_CATEGORY_LABEL, +} from '../style_util'; import { getOrdinalMbColorRampStops, getPercentilesMbColorRampStops, @@ -23,7 +28,6 @@ import { VECTOR_STYLES, } from '../../../../../common/constants'; import { isCategoricalStopsInvalid } from '../components/color/color_stops_utils'; -import { OTHER_CATEGORY_LABEL, OTHER_CATEGORY_DEFAULT_COLOR } from '../style_util'; import { Break, BreakedLegend } from '../components/legend/breaked_legend'; import { ColorDynamicOptions, OrdinalColorStop } from '../../../../../common/descriptor_types'; import { LegendProps } from './style_property'; diff --git a/x-pack/platform/plugins/shared/maps/public/classes/styles/vector/style_util.ts b/x-pack/platform/plugins/shared/maps/public/classes/styles/vector/style_util.ts index 82f1015bfe167..f4ba318cd27d6 100644 --- a/x-pack/platform/plugins/shared/maps/public/classes/styles/vector/style_util.ts +++ b/x-pack/platform/plugins/shared/maps/public/classes/styles/vector/style_util.ts @@ -5,7 +5,6 @@ * 2.0. */ -import { euiThemeVars } from '@kbn/ui-theme'; import { i18n } from '@kbn/i18n'; import { ICON_SOURCE, MB_LOOKUP_FUNCTION, VECTOR_STYLES } from '../../../../common/constants'; import { Category } from '../../../../common/descriptor_types'; @@ -19,7 +18,7 @@ export const OTHER_CATEGORY_LABEL = i18n.translate( } ); -export const OTHER_CATEGORY_DEFAULT_COLOR = euiThemeVars.euiColorLightShade; +export const OTHER_CATEGORY_DEFAULT_COLOR = '#cad3e2'; // Defaulting to a light grey color that works in both dark and light mode export function getComputedFieldName(styleName: VECTOR_STYLES, fieldName: string) { return `${getComputedFieldNamePrefix(fieldName)}__${styleName as string}`; diff --git a/x-pack/platform/plugins/shared/maps/public/reducers/map/default_map_settings.ts b/x-pack/platform/plugins/shared/maps/public/reducers/map/default_map_settings.ts index 544410c8e383b..4b0c5fb9675a8 100644 --- a/x-pack/platform/plugins/shared/maps/public/reducers/map/default_map_settings.ts +++ b/x-pack/platform/plugins/shared/maps/public/reducers/map/default_map_settings.ts @@ -5,14 +5,13 @@ * 2.0. */ -import { euiThemeVars } from '@kbn/ui-theme'; import { INITIAL_LOCATION, MAX_ZOOM, MIN_ZOOM } from '../../../common/constants'; import { MapSettings } from '../../../common/descriptor_types'; export function getDefaultMapSettings(): MapSettings { return { autoFitToDataBounds: false, - backgroundColor: euiThemeVars.euiColorEmptyShade, + backgroundColor: 'transparent', customIcons: [], disableInteractive: false, disableTooltipControl: false, diff --git a/x-pack/platform/plugins/shared/maps/tsconfig.json b/x-pack/platform/plugins/shared/maps/tsconfig.json index 23f39932990bb..ee6f254b918ed 100644 --- a/x-pack/platform/plugins/shared/maps/tsconfig.json +++ b/x-pack/platform/plugins/shared/maps/tsconfig.json @@ -54,7 +54,6 @@ "@kbn/mapbox-gl", "@kbn/core-execution-context-common", "@kbn/chart-icons", - "@kbn/ui-theme", "@kbn/monaco", "@kbn/safer-lodash-set", "@kbn/custom-integrations-plugin",