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

[8.x] [ML] Migrate ColorRangeLegend from SCSS to emotion. (#199156) #199274

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion x-pack/plugins/ml/public/application/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -144,7 +167,7 @@ export const ColorRangeLegend: FC<ColorRangeLegendProps> = ({
</EuiText>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<svg ref={d3Container} />
<svg ref={d3Container} css={cssOverride} />
</EuiFlexItem>
</EuiFlexGroup>
);
Expand Down