Chore: Remove usage of deprecated getColorForTheme function (#49519)

This commit is contained in:
kay delaney
2022-05-26 14:11:44 +01:00
committed by GitHub
parent 386181cf45
commit 308ceebdd1
15 changed files with 35 additions and 66 deletions

View File

@@ -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,
});
});

View File

@@ -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');
});
});
});

View File

@@ -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