├── .gitignore
├── dist
├── frozen.svg
├── locked.svg
├── stable.svg
├── unstable.svg
├── deprecated.svg
└── experimental.svg
├── generate.js
├── package.json
├── index.js
├── LICENSE.md
├── README.md
└── badge.js
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 |
--------------------------------------------------------------------------------
/dist/frozen.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/dist/locked.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/dist/stable.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/dist/unstable.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/dist/deprecated.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/dist/experimental.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/generate.js:
--------------------------------------------------------------------------------
1 | var badges = require('./')
2 | var path = require('path')
3 | var fs = require('fs')
4 |
5 | var header = [
6 | ''
12 |
13 | Object.keys(badges).forEach(function(name) {
14 | var filename = __dirname + '/dist/' + name + '.svg'
15 | var contents = header + badges[name] + footer
16 |
17 | console.error('generated "' + path.relative(__dirname, filename) + '"')
18 | fs.writeFileSync(filename, contents)
19 | })
20 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "stability-badges",
3 | "version": "0.1.1",
4 | "description": "A set of SVG badges to mark your modules with the Node stability index",
5 | "main": "index.js",
6 | "devDependencies": {},
7 | "scripts": {
8 | "prepublish": "node generate.js"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git://github.com/hughsk/stability-badges.git"
13 | },
14 | "keywords": [
15 | "stability",
16 | "badges",
17 | "readme",
18 | "image",
19 | "svg",
20 | "content"
21 | ],
22 | "author": "Hugh Kennedy (http://hughskennedy.com/)",
23 | "license": "MIT",
24 | "readmeFilename": "README.md"
25 | }
26 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | var badges = module.exports = {}
2 | var badge = require('./badge')
3 |
4 | badges.deprecated = badge('stability', 'deprecated', {
5 | categoryColor: '#C62914'
6 | , width: 110
7 | , labelWidth: 45
8 | })
9 |
10 | badges.experimental = badge('stability', 'experimental', {
11 | categoryColor: '#DD5F0A'
12 | , width: 117
13 | , labelWidth: 45
14 | })
15 |
16 | badges.unstable = badge('stability', 'unstable', {
17 | categoryColor: '#E5AE13'
18 | , width: 95
19 | , labelWidth: 45
20 | })
21 |
22 | badges.stable = badge('stability', 'stable', {
23 | categoryColor: '#74C614'
24 | , width: 85
25 | , labelWidth: 45
26 | })
27 |
28 | badges.frozen = badge('stability', 'frozen', {
29 | categoryColor: '#33C614'
30 | , width: 85
31 | , labelWidth: 45
32 | })
33 |
34 | badges.locked = badge('stability', 'locked', {
35 | categoryColor: '#14C6C6'
36 | , width: 85
37 | , labelWidth: 45
38 | })
39 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | This software is released under the MIT license:
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of
4 | this software and associated documentation files (the "Software"), to deal in
5 | the Software without restriction, including without limitation the rights to
6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7 | the Software, and to permit persons to whom the Software is furnished to do so,
8 | subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # stability-badges [](https://flattr.com/submit/auto?user_id=hughskennedy&url=http://github.com/badges/stability-badges&title=stability-badges&description=badges/stability-badges%20on%20GitHub&language=en_GB&tags=flattr,github,javascript&category=software) #
2 |
3 | A set of SVG badges to mark your modules with the
4 | [Node stability index](http://nodejs.org/api/documentation.html#documentation_stability_index).
5 |
6 | ### Stability: 0 - Deprecated ###
7 |
8 | [](http://github.com/badges/stability-badges)
9 |
10 | ``` markdown
11 | [](http://github.com/badges/stability-badges)
12 | ```
13 |
14 | ### Stability: 1 - Experimental ###
15 |
16 | [](http://github.com/badges/stability-badges)
17 |
18 | ``` markdown
19 | [](http://github.com/badges/stability-badges)
20 | ```
21 |
22 | ### Stability: 2 - Unstable ###
23 |
24 | [](http://github.com/badges/stability-badges)
25 |
26 | ``` markdown
27 | [](http://github.com/badges/stability-badges)
28 | ```
29 |
30 | ### Stability: 3 - Stable ###
31 |
32 | [](http://github.com/badges/stability-badges)
33 |
34 | ``` markdown
35 | [](http://github.com/badges/stability-badges)
36 | ```
37 |
38 | ### Stability: 4 - Frozen ###
39 |
40 | [](http://github.com/badges/stability-badges)
41 |
42 | ``` markdown
43 | [](http://github.com/badges/stability-badges)
44 | ```
45 |
46 | ### Stability: 5 - Locked ###
47 |
48 | [](http://github.com/badges/stability-badges)
49 |
50 | ``` markdown
51 | [](http://github.com/badges/stability-badges)
52 | ```
53 |
--------------------------------------------------------------------------------
/badge.js:
--------------------------------------------------------------------------------
1 | module.exports = badge
2 |
3 | function badge(label, category, options) {
4 | options = options || {}
5 |
6 | options.labelColor = options.labelColor || '#4b4b4b'
7 | options.categoryColor = options.categoryColor || '#74c614'
8 | options.width = options.width || 100
9 | options.labelWidth = options.labelWidth || 35
10 |
11 | var svg = ''
12 | var height = 19
13 | var shadow = 2
14 | var body = height - shadow
15 |
16 | // shadow
17 | svg += el('rect', {
18 | x: 0
19 | , y: 0
20 | , width: options.width
21 | , height: height
22 | , style: {
23 | fill: options.labelColor
24 | , opacity: 0.3
25 | }
26 | })
27 |
28 | svg += el('rect', {
29 | x: 0
30 | , y: 0
31 | , width: options.width
32 | , height: body
33 | , style: {
34 | fill: options.labelColor
35 | }
36 | })
37 |
38 | svg += el('rect', {
39 | x: options.labelWidth
40 | , y: 0
41 | , width: options.width - options.labelWidth
42 | , height: body
43 | , style: {
44 | fill: options.categoryColor
45 | }
46 | })
47 |
48 | svg += dropshadowText(5, body / 2, label)
49 | svg += dropshadowText(options.labelWidth + 5, body / 2, category)
50 |
51 | return svg
52 | }
53 |
54 | function el(el) {
55 | var args = Array.prototype.slice.call(arguments, 1)
56 | var str = '<' + el
57 |
58 | args.filter(function(arg) {
59 | return typeof arg !== 'string'
60 | }).forEach(function(opts) {
61 | Object.keys(opts).forEach(function(key) {
62 | var value = opts[key]
63 |
64 | if (Array.isArray(value)) value = value.join(' ')
65 | if (typeof value === 'object') {
66 | value = Object.keys(value).reduce(function(str, key) {
67 | str += key
68 | str += ':'
69 | str += value[key]
70 | str += ';'
71 | return str
72 | }, '')
73 | }
74 |
75 | str += ' '
76 | str += key
77 | str += '="'
78 | str += String(value).replace(/\"/g, '\\"')
79 | str += '"'
80 | })
81 | })
82 |
83 | str += '>'
84 |
85 | args.filter(function(arg) {
86 | return typeof arg === 'string'
87 | }).forEach(function(inner) {
88 | str += inner
89 | })
90 |
91 |
92 | str += '' + el + '>'
93 |
94 | return str
95 | }
96 |
97 | function dropshadowText(x, y, label) {
98 | return el('text', label, {
99 | x: x
100 | , y: y + 1
101 | , style: {
102 | 'fill': '#000'
103 | , 'opacity': 0.75
104 | }
105 | }) + el('text', label, {
106 | x: x
107 | , y: y
108 | , style: {
109 | 'fill': '#fff'
110 | }
111 | })
112 | }
113 |
--------------------------------------------------------------------------------