-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create ColorSystem class and colors.json file (#1190)
update DataLoader to load color info from colors.json and update core/index.js to include references to ColorSystem add ColorSystem initAsync to Context.js, create getColorScheme method on ColorSystem class, import getColorScheme in styles.js start color refactor in styles.js bind getColorScheme method to 'this' and update constructor refactor styles.js into STYLES class and update import statements to reflect changes remove initAsync() call in Context.js file change class name to 'Styles', update imports, change DEFAULT to 'default' update styleMatch method, change all vars to static vars, fix formatting add script to build_data.js to minify colors.json remove static colors.json import, refactor getColorScheme method start Styles refactor to StyleSystem, move file to /modules/core, update import statements add StyleSystem reference to available systems set add styles system dependency to MapSystem remove StyleSystem import, update style vars to use context.systems refactor StyleSystem initialize colorData as class var, move getDataAsync function to startAsync remove StyleSystem import, set style var with context delete styles.js update MapSystem.Test to include colors and styles
- Loading branch information
Showing
12 changed files
with
730 additions
and
648 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"red": { | ||
"fill": { "color": "0xe06e5f", "alpha": 0.3 } | ||
}, | ||
"green": { | ||
"fill": { "color": "0x8cd05f", "alpha": 0.3 } | ||
}, | ||
"blue": { | ||
"fill": { "color": "0x77d4de", "alpha": 0.3 } | ||
}, | ||
"yellow": { | ||
"fill": { "color": "0xffff94", "alpha": 0.25 } | ||
}, | ||
"gold": { | ||
"fill": { "color": "0xc4be19", "alpha": 0.3 } | ||
}, | ||
"orange": { | ||
"fill": { "color": "0xd6881a", "alpha": 0.3 } | ||
}, | ||
"pink": { | ||
"fill": { "color": "0xe3a4f5", "alpha": 0.3 } | ||
}, | ||
"teal": { | ||
"fill": { "color": "0x99e1aa", "alpha": 0.3 } | ||
}, | ||
"lightgreen": { | ||
"fill": { "color": "0xbee83f", "alpha": 0.3 } | ||
}, | ||
"tan": { | ||
"fill": { "color": "0xf5dcba", "alpha": 0.3 } | ||
}, | ||
"darkgray": { | ||
"fill": { "color": "0x8c8c8c", "alpha": 0.5 } | ||
}, | ||
"lightgray": { | ||
"fill": { "color": "0xaaaaaa", "alpha": 0.3 } | ||
} | ||
} |
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,43 @@ | ||
import { AbstractSystem } from './AbstractSystem'; | ||
|
||
export class ColorSystem extends AbstractSystem { | ||
constructor(context) { | ||
super(context); | ||
this.id = 'colors'; | ||
this.context = context; | ||
this.dependencies = new Set(['dataloader']); | ||
this.autoStart = true; | ||
this._started = false; | ||
this.colorData = null; | ||
|
||
this.getColorScheme = this.getColorScheme.bind(this); | ||
} | ||
|
||
initAsync(){ | ||
for (const id of this.dependencies) { | ||
if (!this.context.systems[id]) { | ||
return Promise.reject(`Cannot init: ${this.id} requires ${id}`); | ||
} | ||
} | ||
return Promise.resolve(); | ||
} | ||
|
||
startAsync() { | ||
this._started = true; | ||
const context = this.context; | ||
const dataloader = context.systems.dataloader; | ||
|
||
dataloader.getDataAsync('colors') | ||
.then((data) => { this.colorData = data; } ); | ||
|
||
return Promise.resolve(); | ||
} | ||
|
||
resetAsync() { | ||
return Promise.resolve(); | ||
} | ||
|
||
getColorScheme() { | ||
return this.colorData; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -44,6 +44,7 @@ export class DataLoaderSystem extends AbstractSystem { | |
fileMap.set('shortcuts', 'data/shortcuts.min.json'); | ||
fileMap.set('territory_languages', 'data/territory_languages.min.json'); | ||
fileMap.set('wmf_sitematrix', 'https://cdn.jsdelivr.net/npm/[email protected]/wikipedia.min.json'); | ||
fileMap.set('colors', 'data/colors.min.json'); | ||
|
||
this.fileMap = fileMap; | ||
this._cachedData = {}; | ||
|
@@ -74,6 +75,7 @@ export class DataLoaderSystem extends AbstractSystem { | |
c.shortcuts = []; | ||
c.territory_languages = {}; | ||
c.wmf_sitematrix = [ ['English','English','en'], ['German', 'Deutsch', 'de'] ]; | ||
c.colors = {}; | ||
} | ||
} | ||
|
||
|
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
Oops, something went wrong.