forked from apache/superset
-
Notifications
You must be signed in to change notification settings - Fork 4
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 (#69)
* Refactor: Convert color to TS
- Loading branch information
1 parent
1d62f76
commit fded8f1
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
10 changes: 0 additions & 10 deletions
10
...-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-color/src/ColorScheme.js
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
...-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-color/src/ColorScheme.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 |
---|---|---|
@@ -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
...i/packages/superset-ui-color/src/index.js → ...i/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
5 changes: 5 additions & 0 deletions
5
superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-color/src/types.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 |
---|---|---|
@@ -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.
2 changes: 1 addition & 1 deletion
2
...ntend/temporary_superset_ui/superset-ui/packages/superset-ui-core/src/utils/isRequired.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,3 +1,3 @@ | ||
export default function isRequired(field: string) { | ||
export default function isRequired(field: string): never { | ||
throw new Error(`${field} is required.`); | ||
} |