diff --git a/public/app/features/alerting/unified/components/rule-editor/QueryRows.tsx b/public/app/features/alerting/unified/components/rule-editor/QueryRows.tsx index 4bde536aa5e..1bd3a6598f1 100644 --- a/public/app/features/alerting/unified/components/rule-editor/QueryRows.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/QueryRows.tsx @@ -9,7 +9,7 @@ import { ThresholdsConfig, ThresholdsMode, } from '@grafana/data'; -import { getDataSourceSrv } from '@grafana/runtime'; +import { config, getDataSourceSrv } from '@grafana/runtime'; import { QueryWrapper } from './QueryWrapper'; import { AlertQuery } from 'app/types/unified-alerting-dto'; import { isExpressionQuery } from 'app/features/expressions/guards'; @@ -211,7 +211,7 @@ export class QueryRows extends PureComponent { steps: [ { value: -Infinity, - color: 'green', + color: config.theme2.colors.success.main, }, ], }; @@ -219,7 +219,7 @@ export class QueryRows extends PureComponent { record[refId].steps.push({ value: threshold, - color: 'red', + color: config.theme2.colors.error.main, }); }); } diff --git a/public/app/plugins/panel/timeseries/plugins/ThresholdDragHandle.tsx b/public/app/plugins/panel/timeseries/plugins/ThresholdDragHandle.tsx index 7bc93429fc7..26ef7e18307 100644 --- a/public/app/plugins/panel/timeseries/plugins/ThresholdDragHandle.tsx +++ b/public/app/plugins/panel/timeseries/plugins/ThresholdDragHandle.tsx @@ -1,4 +1,4 @@ -import React, { useMemo, useState } from 'react'; +import React, { useState } from 'react'; import { css } from '@emotion/css'; import { Threshold, GrafanaTheme2 } from '@grafana/data'; import { useStyles2, useTheme2 } from '@grafana/ui'; @@ -24,10 +24,8 @@ export const ThresholdDragHandle: React.FC = ({ const theme = useTheme2(); const styles = useStyles2(getStyles); const [currentValue, setCurrentValue] = useState(step.value); - - const textColor = useMemo(() => { - return theme.colors.getContrastText(theme.visualization.getColorByName(step.color)); - }, [step.color, theme]); + const bgColor = theme.visualization.getColorByName(step.color); + const textColor = theme.colors.getContrastText(bgColor); return ( = ({ >
{formatValue(currentValue)}