mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
support three letter hex color strings
This commit is contained in:
parent
db8c74c4c3
commit
169732997d
@ -59,6 +59,8 @@ describe('colors', () => {
|
|||||||
it('returns color if specified as hex or rgb/a', () => {
|
it('returns color if specified as hex or rgb/a', () => {
|
||||||
expect(getColorFromHexRgbOrName('ff0000')).toBe('ff0000');
|
expect(getColorFromHexRgbOrName('ff0000')).toBe('ff0000');
|
||||||
expect(getColorFromHexRgbOrName('#ff0000')).toBe('#ff0000');
|
expect(getColorFromHexRgbOrName('#ff0000')).toBe('#ff0000');
|
||||||
|
expect(getColorFromHexRgbOrName('#FF0000')).toBe('#FF0000');
|
||||||
|
expect(getColorFromHexRgbOrName('#CCC')).toBe('#CCC');
|
||||||
expect(getColorFromHexRgbOrName('rgb(0,0,0)')).toBe('rgb(0,0,0)');
|
expect(getColorFromHexRgbOrName('rgb(0,0,0)')).toBe('rgb(0,0,0)');
|
||||||
expect(getColorFromHexRgbOrName('rgba(0,0,0,1)')).toBe('rgba(0,0,0,1)');
|
expect(getColorFromHexRgbOrName('rgba(0,0,0,1)')).toBe('rgba(0,0,0,1)');
|
||||||
});
|
});
|
||||||
|
@ -73,7 +73,7 @@ export const getColorDefinition = (hex: string, theme: GrafanaThemeType): ColorD
|
|||||||
};
|
};
|
||||||
|
|
||||||
const isHex = (color: string) => {
|
const isHex = (color: string) => {
|
||||||
const hexRegex = /^((0x){0,1}|#{0,1})([0-9A-F]{8}|[0-9A-F]{6})$/gi;
|
const hexRegex = /^((0x){0,1}|#{0,1})([0-9A-F]{8}|[0-9A-F]{6}|[0-9A-F]{3})$/gi;
|
||||||
return hexRegex.test(color);
|
return hexRegex.test(color);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user