Added hex colors to manifest.json (#294)
This commit is contained in:
parent
ede61f7058
commit
7be9023fba
1272
manifest.json
1272
manifest.json
File diff suppressed because it is too large
Load Diff
|
@ -48,7 +48,8 @@
|
||||||
"globby-cli": "^1.0.1",
|
"globby-cli": "^1.0.1",
|
||||||
"husky": "^1.3.1",
|
"husky": "^1.3.1",
|
||||||
"svgo": "^1.2.0",
|
"svgo": "^1.2.0",
|
||||||
"xo": "^0.24.0"
|
"xo": "^0.24.0",
|
||||||
|
"get-svg-colors": "^1.5.1"
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
"hooks": {
|
"hooks": {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const coins = require('coinlist');
|
const coins = require('coinlist');
|
||||||
|
const getColors = require('get-svg-colors');
|
||||||
const alphaSort = require('alpha-sort');
|
const alphaSort = require('alpha-sort');
|
||||||
const manifest = require('../manifest.json');
|
const manifest = require('../manifest.json');
|
||||||
|
|
||||||
|
@ -44,10 +45,19 @@ const overrides = new Map([
|
||||||
|
|
||||||
const icons = manifest.map(icon => {
|
const icons = manifest.map(icon => {
|
||||||
const id = typeof icon === 'string' ? icon : icon.symbol;
|
const id = typeof icon === 'string' ? icon : icon.symbol;
|
||||||
|
const fileName = `${id.toLowerCase()}.svg`;
|
||||||
|
const svgPath = path.resolve(__dirname, '../svg/color/', fileName);
|
||||||
|
let color;
|
||||||
|
if (fs.existsSync(svgPath)) {
|
||||||
|
const svg = fs.readFileSync(svgPath, 'utf8');
|
||||||
|
const fillColor = getColors(svg).fills[0];
|
||||||
|
color = fillColor ? fillColor.hex().toUpperCase() : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
symbol: id.toUpperCase(),
|
symbol: id.toUpperCase(),
|
||||||
name: overrides.get(id) || coins.get(id, 'name') || id
|
name: overrides.get(id) || coins.get(id, 'name') || id,
|
||||||
|
color
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue