Skip to content

Commit

Permalink
Feat: Set default color scheme for the color registries (#108)
Browse files Browse the repository at this point in the history
* Set default color scheme for the color registries

* fix: Add unit test
  • Loading branch information
kristw authored and zhaoyongjie committed Nov 17, 2021
1 parent aee0f40 commit dca5467
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { makeSingleton } from '@superset-ui/core';
import CategoricalScheme from './CategoricalScheme';
import ColorSchemeRegistry from './ColorSchemeRegistry';
import schemes from './colorSchemes/categorical/d3';

class CategoricalSchemeRegistry extends ColorSchemeRegistry<CategoricalScheme> {}
class CategoricalSchemeRegistry extends ColorSchemeRegistry<CategoricalScheme> {
constructor() {
super();

this.registerValue('SUPERSET_DEFAULT', schemes[0]);
}
}

const getInstance = makeSingleton(CategoricalSchemeRegistry);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { makeSingleton } from '@superset-ui/core';
import ColorSchemeRegistry from './ColorSchemeRegistry';
import SequentialScheme from './SequentialScheme';
import schemes from './colorSchemes/sequential/d3';

class SequentialSchemeRegistry extends ColorSchemeRegistry<SequentialScheme> {}
class SequentialSchemeRegistry extends ColorSchemeRegistry<SequentialScheme> {
constructor() {
super();

this.registerValue('SUPERSET_DEFAULT', schemes[0]);
}
}

const getInstance = makeSingleton(SequentialSchemeRegistry);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@
import SequentialScheme from '../../SequentialScheme';

const schemes = [
{
id: 'schemeRdBu',
label: 'red/blue',
isDiverging: true,
colors: [
'#67001f',
'#b2182b',
'#d6604d',
'#f4a582',
'#fddbc7',
'#d1e5f0',
'#92c5de',
'#4393c3',
'#2166ac',
'#053061',
],
},
{
id: 'schemeBrBG',
label: 'brown/green',
Expand Down Expand Up @@ -71,23 +88,6 @@ const schemes = [
'#7f3b08',
],
},
{
id: 'schemeRdBu',
label: 'red/blue',
isDiverging: true,
colors: [
'#67001f',
'#b2182b',
'#d6604d',
'#f4a582',
'#fddbc7',
'#d1e5f0',
'#92c5de',
'#4393c3',
'#2166ac',
'#053061',
],
},
{
id: 'schemeRdGy',
label: 'red/gray/black',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { CategoricalScheme, getCategoricalSchemeRegistry } from '../src';

describe('CategoricalSchemeRegistry', () => {
it('has default value out-of-the-box', () => {
expect(getCategoricalSchemeRegistry().get()).toBeInstanceOf(CategoricalScheme);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { SequentialScheme, getSequentialSchemeRegistry } from '../src';

describe('SequentialSchemeRegistry', () => {
it('has default value out-of-the-box', () => {
expect(getSequentialSchemeRegistry().get()).toBeInstanceOf(SequentialScheme);
});
});

0 comments on commit dca5467

Please sign in to comment.