forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] Anomaly Detection: Migrate chart tooltip from SCSS to emotion (e…
…lastic#199417) ## Summary Part of elastic#140695 Migrates SCSS to emotion for the Anomaly Detection chart tooltip. ![CleanShot 2024-11-08 at 08 01 22@2x](https://github.com/user-attachments/assets/a7cd94c2-15b7-42bc-b98a-3596eaeeafe1) ### 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)
- Loading branch information
Showing
4 changed files
with
88 additions
and
57 deletions.
There are no files selected for viewing
47 changes: 0 additions & 47 deletions
47
x-pack/plugins/ml/public/application/components/chart_tooltip/_chart_tooltip.scss
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
x-pack/plugins/ml/public/application/components/chart_tooltip/_index.scss
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
x-pack/plugins/ml/public/application/components/chart_tooltip/chart_tooltip_styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* 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 { css } from '@emotion/react'; | ||
|
||
import { mathWithUnits, transparentize, useEuiTheme } from '@elastic/eui'; | ||
// @ts-expect-error style types not defined | ||
import { euiToolTipStyles } from '@elastic/eui/lib/components/tool_tip/tool_tip.styles'; | ||
|
||
import { useCurrentEuiThemeVars } from '@kbn/ml-kibana-theme'; | ||
|
||
import { useMlKibana } from '../../contexts/kibana'; | ||
|
||
export const useChartTooltipStyles = () => { | ||
const euiThemeContext = useEuiTheme(); | ||
const { | ||
services: { theme }, | ||
} = useMlKibana(); | ||
const { euiTheme } = useCurrentEuiThemeVars(theme); | ||
const euiStyles = euiToolTipStyles(euiThemeContext); | ||
|
||
return { | ||
mlChartTooltip: css([ | ||
euiStyles.euiToolTip, | ||
{ | ||
fontSize: euiTheme.euiFontSizeXS, | ||
padding: 0, | ||
transition: `opacity ${euiTheme.euiAnimSpeedNormal}`, | ||
pointerEvents: 'none', | ||
userSelect: 'none', | ||
maxWidth: '512px', | ||
position: 'relative', | ||
}, | ||
]), | ||
mlChartTooltipList: css({ | ||
margin: euiTheme.euiSizeXS, | ||
paddingBottom: euiTheme.euiSizeXS, | ||
}), | ||
mlChartTooltipHeader: css({ | ||
fontWeight: euiTheme.euiFontWeightBold, | ||
padding: `${euiTheme.euiSizeXS} ${mathWithUnits(euiTheme.euiSizeS, (x) => x * 2)}`, | ||
marginBottom: euiTheme.euiSizeXS, | ||
borderBottom: `1px solid ${transparentize(euiTheme.euiBorderColor, 0.8)}`, | ||
}), | ||
mlChartTooltipItem: css({ | ||
display: 'flex', | ||
padding: '3px', | ||
boxSizing: 'border-box', | ||
borderLeft: `${euiTheme.euiSizeXS} solid transparent`, | ||
}), | ||
mlChartTooltipLabel: css({ | ||
minWidth: '1px', | ||
}), | ||
mlChartTooltipValue: css({ | ||
fontWeight: euiTheme.euiFontWeightBold, | ||
textAlign: 'right', | ||
fontFeatureSettings: 'tnum', | ||
marginLeft: '8px', | ||
}), | ||
}; | ||
}; |