mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[ML] Migrate ColorRangeLegend from SCSS to emotion. (#199156)
## Summary Part of https://github.com/elastic/kibana/issues/140695 Migrates SCSS to emotion for ColorRangeLegend. <img src="https://github.com/user-attachments/assets/3444fa49-2ef2-4706-b15e-c3e8415c6293" /> <img src="https://github.com/user-attachments/assets/a79648a5-1230-41b6-b8f5-c1ff2dc9f996" width="75%" /> ### Checklist - [ ] [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 - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)
This commit is contained in:
parent
4c61876a3a
commit
12dc8c1bb8
4 changed files with 25 additions and 22 deletions
|
@ -11,7 +11,6 @@
|
|||
// Components
|
||||
@import 'components/annotations/annotation_description_list/index'; // SASSTODO: This file overwrites EUI directly
|
||||
@import 'components/anomalies_table/index'; // SASSTODO: This file overwrites EUI directly
|
||||
@import 'components/color_range_legend/index';
|
||||
@import 'components/entity_cell/index';
|
||||
@import 'components/influencers_list/index';
|
||||
@import 'components/job_selector/index';
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
/* Overrides for d3/svg default styles */
|
||||
.mlColorRangeLegend {
|
||||
text {
|
||||
@include fontSize($euiFontSizeXS - 2px);
|
||||
fill: $euiColorDarkShade;
|
||||
}
|
||||
|
||||
.axis path {
|
||||
fill: none;
|
||||
stroke: none;
|
||||
}
|
||||
|
||||
.axis line {
|
||||
fill: none;
|
||||
stroke: $euiColorMediumShade;
|
||||
shape-rendering: crispEdges;
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
@import 'color_range_legend';
|
|
@ -7,12 +7,36 @@
|
|||
|
||||
import type { FC } from 'react';
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import { css } from '@emotion/react';
|
||||
import d3 from 'd3';
|
||||
|
||||
import { EuiFlexGroup, EuiFlexItem, EuiText } from '@elastic/eui';
|
||||
|
||||
import { euiThemeVars } from '@kbn/ui-theme';
|
||||
|
||||
const COLOR_RANGE_RESOLUTION = 10;
|
||||
|
||||
// Overrides for d3/svg default styles
|
||||
const cssOverride = css({
|
||||
// Override default font size and color for axis
|
||||
text: {
|
||||
fontSize: `calc(${euiThemeVars.euiFontSizeXS} - 2px)`,
|
||||
fill: euiThemeVars.euiColorDarkShade,
|
||||
},
|
||||
// Override default styles for axis lines
|
||||
'.axis': {
|
||||
path: {
|
||||
fill: 'none',
|
||||
stroke: 'none',
|
||||
},
|
||||
line: {
|
||||
fill: 'none',
|
||||
stroke: euiThemeVars.euiColorMediumShade,
|
||||
shapeRendering: 'crispEdges',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
interface ColorRangeLegendProps {
|
||||
colorRange: (d: number) => string;
|
||||
justifyTicks?: boolean;
|
||||
|
@ -65,7 +89,6 @@ export const ColorRangeLegend: FC<ColorRangeLegendProps> = ({
|
|||
|
||||
const wrapper = d3
|
||||
.select(d3Container.current)
|
||||
.classed('mlColorRangeLegend', true)
|
||||
.attr('width', wrapperWidth)
|
||||
.attr('height', wrapperHeight)
|
||||
.append('g')
|
||||
|
@ -144,7 +167,7 @@ export const ColorRangeLegend: FC<ColorRangeLegendProps> = ({
|
|||
</EuiText>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
<svg ref={d3Container} />
|
||||
<svg ref={d3Container} css={cssOverride} />
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue