Skip to content

Commit

Permalink
[ML] Remove legacy scss overwrites Single Metric Viewer (elastic#195259)
Browse files Browse the repository at this point in the history
## Summary

Removes SCSS files for the Single Metric Viewer and adds BEM classes for
`annotations`.
Affects the Single Metric Viewer in ML and the embeddable.
Part of [elastic#140695](elastic#140695)
  • Loading branch information
rbrtj authored Oct 14, 2024
1 parent f90dc39 commit 87c91f4
Show file tree
Hide file tree
Showing 14 changed files with 403 additions and 417 deletions.
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 @@ -7,7 +7,6 @@
// Sub applications
@import 'data_frame_analytics/index';
@import 'explorer/index'; // SASSTODO: This file needs to be rewritten
@import 'timeseriesexplorer/index';

// Components
@import 'components/annotations/annotation_description_list/index'; // SASSTODO: This file overwrites EUI directly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export const AnnotationTimeline = <T extends { timestamp: number; end_timestamp?
: startingXPos;
svg
.append('rect')
.classed('mlAnnotationRect', true)
.classed('ml-annotation__rect', true)
// If annotation is at the end, prevent overflow by shifting it back
.attr('x', xPos + annotationWidth >= endingXPos ? endingXPos - annotationWidth : xPos)
.attr('y', 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useCurrentThemeVars } from '../contexts/kibana';
import type { Annotation, AnnotationsTable } from '../../../common/types/annotations';
import type { ChartTooltipService } from '../components/chart_tooltip';
import { Y_AXIS_LABEL_PADDING, Y_AXIS_LABEL_WIDTH } from './constants';
import { getAnnotationStyles } from '../timeseriesexplorer/styles';

const ANNOTATION_CONTAINER_HEIGHT = 12;
const ANNOTATION_MIN_WIDTH = 8;
Expand All @@ -29,6 +30,8 @@ interface SwimlaneAnnotationContainerProps {
tooltipService: ChartTooltipService;
}

const annotationStyles = getAnnotationStyles();

export const SwimlaneAnnotationContainer: FC<SwimlaneAnnotationContainerProps> = ({
chartWidth,
domain,
Expand Down Expand Up @@ -135,7 +138,7 @@ export const SwimlaneAnnotationContainer: FC<SwimlaneAnnotationContainerProps> =
const xPos = d.start >= domain.min ? (xScale(d.start) as number) : startingXPos;
svg
.append('rect')
.classed('mlAnnotationRect', true)
.classed('ml-annotation__rect', true)
// If annotation is at the end, prevent overflow by shifting it back
.attr('x', xPos + annotationWidth >= endingXPos ? endingXPos - annotationWidth : xPos)
.attr('y', 0)
Expand Down Expand Up @@ -221,5 +224,5 @@ export const SwimlaneAnnotationContainer: FC<SwimlaneAnnotationContainerProps> =
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [chartWidth, domain, annotationsData, tooltipService]);

return <div ref={canvasRef} />;
return <div css={annotationStyles} ref={canvasRef} />;
};
17 changes: 17 additions & 0 deletions x-pack/plugins/ml/public/application/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* 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.
*/

// Replacement for ./_variables.scss as we aim to remove the scss files

export const mlColors = {
critical: '#FE5050',
major: '#FBA740',
minor: '#FDEC25',
warning: '#8BC8FB',
lowWarning: '#D2E9F7',
unknown: '#C0C0C0',
};

This file was deleted.

This file was deleted.

Loading

0 comments on commit 87c91f4

Please sign in to comment.