mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Remove usage of deprecated getColorForTheme function (#49519)
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { createTheme } from '../themes';
|
||||
import { ThresholdsMode, Field, FieldType, FieldColorModeId } from '../types';
|
||||
import { getColorForTheme } from '../utils';
|
||||
import { ArrayVector } from '../vector/ArrayVector';
|
||||
|
||||
import { getScaleCalculator } from './scale';
|
||||
@@ -41,12 +40,12 @@ describe('getScaleCalculator', () => {
|
||||
const calc = getScaleCalculator(field, theme);
|
||||
expect(calc(true as any)).toEqual({
|
||||
percent: 1,
|
||||
color: getColorForTheme('green', theme.v1),
|
||||
color: theme.v1.visualization.getColorByName('green'),
|
||||
threshold: undefined,
|
||||
});
|
||||
expect(calc(false as any)).toEqual({
|
||||
percent: 0,
|
||||
color: getColorForTheme('red', theme.v1),
|
||||
color: theme.v1.visualization.getColorByName('red'),
|
||||
threshold: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
import { createTheme } from '../themes';
|
||||
|
||||
import { getColorForTheme } from './namedColorsPalette';
|
||||
|
||||
describe('colors', () => {
|
||||
const theme = createTheme();
|
||||
|
||||
describe('getColorFromHexRgbOrName', () => {
|
||||
it('returns black for unknown color', () => {
|
||||
expect(getColorForTheme('aruba-sunshine', theme.v1)).toBe('aruba-sunshine');
|
||||
expect(theme.v1.visualization.getColorByName('aruba-sunshine')).toBe('aruba-sunshine');
|
||||
});
|
||||
|
||||
it('returns dark hex variant for known color if theme not specified', () => {
|
||||
expect(getColorForTheme('semi-dark-blue', theme.v1)).toBe('#3274D9');
|
||||
expect(theme.v1.visualization.getColorByName('semi-dark-blue')).toBe('#3274D9');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,19 +1,3 @@
|
||||
import { GrafanaTheme, GrafanaThemeType } from '../types/theme';
|
||||
|
||||
/**
|
||||
* @deprecated use theme.visualization.getColorByName
|
||||
*/
|
||||
export function getColorForTheme(color: string, theme: GrafanaTheme): string {
|
||||
return theme.visualization.getColorByName(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use getColorForTheme
|
||||
*/
|
||||
export function getColorFromHexRgbOrName(color: string, type?: GrafanaThemeType): string {
|
||||
return 'gray';
|
||||
}
|
||||
|
||||
export const classicColors = [
|
||||
'#7EB26D', // 0: pale green
|
||||
'#EAB839', // 1: mustard
|
||||
|
||||
Reference in New Issue
Block a user