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 # 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: 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 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 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`). 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 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 same dark grey, so you can rely on that default value by not providing a
providing a `"colorA"` field (such as above). `"colorA"` field (such as above).
You can also use the `"colorA"` and `"colorB"` fields directly in the badges if 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 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. // Template crafting action below.
var dot = require('dot'); var dot = require('dot');
var badgeData = require('./default-badges.json'); var colorscheme = require('./colorscheme.json');
var colorscheme = badgeData.colorschemes;
var template = fs.readFileSync('./template.svg'); var template = fs.readFileSync('./template.svg');
var imageTemplate = dot.template(''+template); 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,87 +1,58 @@
{ {
"badges": { "build-passed": {
"build-passed": { "text": [ "build", "passed" ],
"text": [ "build", "passed" ], "colorscheme": "brightgreen"
"colorscheme": "brightgreen"
},
"build-passing": {
"text": [ "build", "passing" ],
"colorscheme": "brightgreen"
},
"build-pending": {
"text": [ "build", "pending" ],
"colorscheme": "yellow"
},
"build-failing": {
"text": [ "build", "failing" ],
"colorscheme": "red"
},
"build-unknown": {
"text": [ "build", "unknown" ],
"colorscheme": "lightgrey"
},
"build-error": {
"text": [ "build", "error" ],
"colorscheme": "lightgrey"
},
"dependencies-none": {
"text": [ "dependencies", "none" ],
"colorscheme": "green"
},
"dependencies-up-to-date": {
"text": [ "dependencies", "up-to-date" ],
"colorscheme": "green"
},
"dependencies-out-of-date": {
"text": [ "dependencies", "out of date" ],
"colorscheme": "yellow"
},
"dependencies-update": {
"text": [ "dependencies", "update!" ],
"colorscheme": "red"
},
"dependencies-unknown": {
"text": [ "dependencies", "unknown" ],
"colorscheme": "lightgrey"
},
"cheez-whiz": {
"text": [ "cheez", "whiz" ],
"colorscheme": "yellow"
},
"tips-per-week": {
"text": [ "tips", "$21/week" ],
"colorB": "#94c600"
},
"coverage": {
"text": [ "coverage", "73%" ],
"colorscheme": "red"
}
}, },
"colorschemes": { "build-passing": {
"brightgreen": { "text": [ "build", "passing" ],
"colorA": "#555", "colorscheme": "brightgreen"
"colorB": "#4c1" },
}, "build-pending": {
"green": { "text": [ "build", "pending" ],
"colorB": "#97CA00" "colorscheme": "yellow"
}, },
"yellow": { "build-failing": {
"colorB": "#dfb317" "text": [ "build", "failing" ],
}, "colorscheme": "red"
"yellowgreen": { },
"colorB": "#a4a61d" "build-unknown": {
}, "text": [ "build", "unknown" ],
"orange": { "colorscheme": "lightgrey"
"colorB": "#be7d37" },
}, "build-error": {
"red": { "text": [ "build", "error" ],
"colorB": "#e05d44" "colorscheme": "lightgrey"
}, },
"lightgrey": { "dependencies-none": {
"colorB": "#9f9f9f" "text": [ "dependencies", "none" ],
}, "colorscheme": "green"
"lightgray": { },
"colorB": "#9f9f9f" "dependencies-up-to-date": {
} "text": [ "dependencies", "up-to-date" ],
"colorscheme": "green"
},
"dependencies-out-of-date": {
"text": [ "dependencies", "out of date" ],
"colorscheme": "yellow"
},
"dependencies-update": {
"text": [ "dependencies", "update!" ],
"colorscheme": "red"
},
"dependencies-unknown": {
"text": [ "dependencies", "unknown" ],
"colorscheme": "lightgrey"
},
"cheez-whiz": {
"text": [ "cheez", "whiz" ],
"colorscheme": "yellow"
},
"tips-per-week": {
"text": [ "tips", "$21/week" ],
"colorB": "#94c600"
},
"coverage": {
"text": [ "coverage", "73%" ],
"colorscheme": "red"
} }
} }

View File

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