forked from apache/superset
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate @superset-ui/color to TypeScript (apache#69)
* Refactor: Convert color to TS
- Loading branch information
Showing
28 changed files
with
95 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
}, | ||
"dependencies": { | ||
"@superset-ui/core": "^0.7.0", | ||
"@types/d3-scale": "^2.0.2", | ||
"d3-scale": "^2.1.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
3 changes: 2 additions & 1 deletion
3
...src/CategoricalSchemeRegistrySingleton.js → ...src/CategoricalSchemeRegistrySingleton.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export interface ColorSchemeConfig { | ||
colors: string[]; | ||
description?: string; | ||
id: string; | ||
label?: string; | ||
} | ||
|
||
export default class ColorScheme { | ||
colors: string[]; | ||
description: string; | ||
id: string; | ||
label: string; | ||
|
||
constructor(config: ColorSchemeConfig) { | ||
const { colors, description = '', id, label } = config; | ||
this.id = id; | ||
this.label = label || id; | ||
this.colors = colors; | ||
this.description = description; | ||
} | ||
} |
6 changes: 5 additions & 1 deletion
6
...erset-ui-color/src/ColorSchemeRegistry.js → ...erset-ui-color/src/ColorSchemeRegistry.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
import { RegistryWithDefaultKey } from '@superset-ui/core'; | ||
|
||
export default class ColorSchemeRegistry extends RegistryWithDefaultKey { | ||
export default class ColorSchemeRegistry<T> extends RegistryWithDefaultKey<T> { | ||
constructor() { | ||
super({ | ||
name: 'ColorScheme', | ||
setFirstItemAsDefault: true, | ||
}); | ||
} | ||
|
||
get(key?: string) { | ||
return super.get(key) as T | undefined; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
.../src/SequentialSchemeRegistrySingleton.js → .../src/SequentialSchemeRegistrySingleton.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion
3
packages/superset-ui-color/src/index.js → packages/superset-ui-color/src/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import * as CategoricalColorNamespace from './CategoricalColorNamespace'; | ||
|
||
export { CategoricalColorNamespace }; | ||
export { ColorSchemeConfig } from './ColorScheme'; | ||
export { default as CategoricalColorScale } from './CategoricalColorScale'; | ||
export { default as CategoricalScheme } from './CategoricalScheme'; | ||
export { default as getCategoricalSchemeRegistry } from './CategoricalSchemeRegistrySingleton'; | ||
export { default as getSequentialSchemeRegistry } from './SequentialSchemeRegistrySingleton'; | ||
export { default as SequentialScheme } from './SequentialScheme'; | ||
export { default as SequentialScheme, SequentialSchemeConfig } from './SequentialScheme'; | ||
|
||
export const BRAND_COLOR = '#00A699'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* eslint-disable import/prefer-default-export */ | ||
|
||
export interface ColorsLookup { | ||
[key: string]: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export default function isRequired(field: string) { | ||
export default function isRequired(field: string): never { | ||
throw new Error(`${field} is required.`); | ||
} |