mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
Rename color constants and move util function into separate file (#6074)
* rename constant colors to UPPERCASE * Move isDefined into its own file and add unit test
This commit is contained in:
committed by
Grace Guo
parent
c0f685b640
commit
64383ce96e
22
superset/assets/spec/javascripts/utils/isDefined_spec.js
Normal file
22
superset/assets/spec/javascripts/utils/isDefined_spec.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import { it, describe } from 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import isDefined from '../../../src/utils/isDefined';
|
||||
|
||||
describe('isDefined(value)', () => {
|
||||
it('returns true if value is not null and not undefined', () => {
|
||||
expect(isDefined(0)).to.equal(true);
|
||||
expect(isDefined(1)).to.equal(true);
|
||||
expect(isDefined('')).to.equal(true);
|
||||
expect(isDefined('a')).to.equal(true);
|
||||
expect(isDefined([])).to.equal(true);
|
||||
expect(isDefined([0])).to.equal(true);
|
||||
expect(isDefined([1])).to.equal(true);
|
||||
expect(isDefined({})).to.equal(true);
|
||||
expect(isDefined({ a: 1 })).to.equal(true);
|
||||
expect(isDefined([{}])).to.equal(true);
|
||||
});
|
||||
it('returns false otherwise', () => {
|
||||
expect(isDefined(null)).to.equal(false);
|
||||
expect(isDefined(undefined)).to.equal(false);
|
||||
});
|
||||
});
|
||||
@@ -45,7 +45,7 @@ import {
|
||||
mainMetric,
|
||||
} from '../modules/utils';
|
||||
import * as v from './validators';
|
||||
import { colorPrimary } from '../modules/colors';
|
||||
import { PRIMARY_COLOR } from '../modules/colors';
|
||||
import { defaultViewport } from '../modules/geo';
|
||||
import ColumnOption from '../components/ColumnOption';
|
||||
import OptionDescription from '../components/OptionDescription';
|
||||
@@ -240,7 +240,7 @@ export const controls = {
|
||||
label: t('Fixed Color'),
|
||||
description: t('Use this to define a static color for all circles'),
|
||||
type: 'ColorPickerControl',
|
||||
default: colorPrimary,
|
||||
default: PRIMARY_COLOR,
|
||||
renderTrigger: true,
|
||||
},
|
||||
|
||||
@@ -248,7 +248,7 @@ export const controls = {
|
||||
label: t('Target Color'),
|
||||
description: t('Color of the target location'),
|
||||
type: 'ColorPickerControl',
|
||||
default: colorPrimary,
|
||||
default: PRIMARY_COLOR,
|
||||
renderTrigger: true,
|
||||
},
|
||||
|
||||
@@ -272,7 +272,7 @@ export const controls = {
|
||||
label: t('Fill Color'),
|
||||
description: t(' Set the opacity to 0 if you do not want to override the color specified in the GeoJSON'),
|
||||
type: 'ColorPickerControl',
|
||||
default: colorPrimary,
|
||||
default: PRIMARY_COLOR,
|
||||
renderTrigger: true,
|
||||
},
|
||||
|
||||
@@ -280,7 +280,7 @@ export const controls = {
|
||||
label: t('Stroke Color'),
|
||||
description: t(' Set the opacity to 0 if you do not want to override the color specified in the GeoJSON'),
|
||||
type: 'ColorPickerControl',
|
||||
default: colorPrimary,
|
||||
default: PRIMARY_COLOR,
|
||||
renderTrigger: true,
|
||||
},
|
||||
|
||||
@@ -1853,7 +1853,7 @@ export const controls = {
|
||||
color: {
|
||||
type: 'ColorPickerControl',
|
||||
label: t('Color'),
|
||||
default: colorPrimary,
|
||||
default: PRIMARY_COLOR,
|
||||
description: t('Pick a color'),
|
||||
},
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import d3 from 'd3';
|
||||
import sequentialSchemes from './colorSchemes/sequential';
|
||||
|
||||
export const brandColor = '#00A699';
|
||||
export const colorPrimary = { r: 0, g: 122, b: 135, a: 1 };
|
||||
export const BRAND_COLOR = '#00A699';
|
||||
export const PRIMARY_COLOR = { r: 0, g: 122, b: 135, a: 1 };
|
||||
|
||||
export function hexToRGB(hex, alpha = 255) {
|
||||
if (!hex) {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
const SVG_NS = 'http://www.w3.org/2000/svg';
|
||||
import isDefined from '../utils/isDefined';
|
||||
|
||||
function isDefined(x) {
|
||||
return x !== null && x !== undefined;
|
||||
}
|
||||
const SVG_NS = 'http://www.w3.org/2000/svg';
|
||||
|
||||
export function getTextDimension({
|
||||
text,
|
||||
|
||||
3
superset/assets/src/utils/isDefined.js
Normal file
3
superset/assets/src/utils/isDefined.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export default function isDefined(x) {
|
||||
return x !== null && x !== undefined;
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import shortid from 'shortid';
|
||||
import { XYChart, AreaSeries, CrossHair, LinearGradient } from '@data-ui/xy-chart';
|
||||
import { brandColor } from '../../modules/colors';
|
||||
import { BRAND_COLOR } from '../../modules/colors';
|
||||
import { formatDateVerbose } from '../../modules/dates';
|
||||
import { computeMaxFontSize } from '../../modules/visUtils';
|
||||
|
||||
@@ -63,7 +63,7 @@ const defaultProps = {
|
||||
showTrendLine: false,
|
||||
startYAxisAtZero: true,
|
||||
trendLineData: null,
|
||||
mainColor: brandColor,
|
||||
mainColor: BRAND_COLOR,
|
||||
renderTooltip: renderTooltipFactory(identity),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user