Separate color scheme data in its own file.

This commit is contained in:
Thaddee Tyl 2014-01-03 16:27:18 +01:00
parent 3f906d533b
commit 9bdbe595b9
5 changed files with 87 additions and 91 deletions

View File

@ -4,7 +4,7 @@ See <https://github.com/h5bp/lazyweb-requests/issues/150>.
# Contribute
If you want to add a badge, only modify `badges.json`.
If you want to add a badge, you only need to modify `badges.json`.
The format is the following:
@ -17,7 +17,7 @@ The format is the following:
}
```
Color schemes are located at the bottom of the file. Each scheme has a name and
Color schemes are located in `colorscheme.json`. Each scheme has a name and
a [CSS/SVG color](http://www.w3.org/TR/SVG/types.html#DataTypeColor) for the
color used in the first box (for the first piece of text, field `colorA`) and
for the one used in the second box (field `colorB`).
@ -29,8 +29,8 @@ for the one used in the second box (field `colorB`).
```
Both `colorA` and `colorB` have default values. Usually, the first box uses the
same dark grey, so you can rely on that default value by not
providing a `"colorA"` field (such as above).
same dark grey, so you can rely on that default value by not providing a
`"colorA"` field (such as above).
You can also use the `"colorA"` and `"colorB"` fields directly in the badges if
you don't want to make a color scheme for it. In that case, remove the

View File

@ -9,8 +9,7 @@ canvasContext.font = '10px Verdana';
// Template crafting action below.
var dot = require('dot');
var badgeData = require('./default-badges.json');
var colorscheme = badgeData.colorschemes;
var colorscheme = require('./colorscheme.json');
var template = fs.readFileSync('./template.svg');
var imageTemplate = dot.template(''+template);

27
colorscheme.json Normal file
View File

@ -0,0 +1,27 @@
{
"brightgreen": {
"colorA": "#555",
"colorB": "#4c1"
},
"green": {
"colorB": "#97CA00"
},
"yellow": {
"colorB": "#dfb317"
},
"yellowgreen": {
"colorB": "#a4a61d"
},
"orange": {
"colorB": "#be7d37"
},
"red": {
"colorB": "#e05d44"
},
"lightgrey": {
"colorB": "#9f9f9f"
},
"lightgray": {
"colorB": "#9f9f9f"
}
}

View File

@ -1,5 +1,4 @@
{
"badges": {
"build-passed": {
"text": [ "build", "passed" ],
"colorscheme": "brightgreen"
@ -56,32 +55,4 @@
"text": [ "coverage", "73%" ],
"colorscheme": "red"
}
},
"colorschemes": {
"brightgreen": {
"colorA": "#555",
"colorB": "#4c1"
},
"green": {
"colorB": "#97CA00"
},
"yellow": {
"colorB": "#dfb317"
},
"yellowgreen": {
"colorB": "#a4a61d"
},
"orange": {
"colorB": "#be7d37"
},
"red": {
"colorB": "#e05d44"
},
"lightgrey": {
"colorB": "#9f9f9f"
},
"lightgray": {
"colorB": "#9f9f9f"
}
}
}

View File

@ -3,8 +3,7 @@ var path = require('path');
var Promise = require('es6-promise').Promise;
// Fetch default badge information.
var badgeData = require('./default-badges.json');
var badges = badgeData.badges;
var badges = require('./default-badges.json');
var badge = require('./badge.js');
// Construct the image sheet.