kopia lustrzana https://github.com/badgen/badgen
![]() |
||
---|---|---|
.github | ||
bench | ||
preview | ||
src | ||
tap-snapshots | ||
test | ||
.gitignore | ||
.npmignore | ||
.travis.yml | ||
LICENSE.md | ||
README.md | ||
package-lock.json | ||
package.json | ||
tsconfig.json |
README.md
badgen
Fast handcraft svg badge generator. Used on badgen.net.
- 🌀 Zero dependency
- ⚡️ Fast by design (see benchmarks)
- 👯 Pure JavaScript, running in node & browser
Usage
npm install badgen
const badgen = require('badgen')
// only `status` is required.
const svgString = badgen({
label: 'npm', // <Text>
labelColor: 'ADF' // <Color RGB> or <Color Name> (default 555)
status: 'v1.2.3', // <Text>, required
color: 'blue', // <Color RGB> or <Color Name> (default blue)
style: 'flat', // 'flat' or undefined
icon: 'data:image/svg+xml;base64,...', // Use icon
iconWidth: 13, // Set this if icon is not square
})
Available color names:
In browser
<script src="https://wzrd.in/standalone/badgen@latest"></script>
<script>
var svgString = badgen({ /*...*/ })
</script>
Benchmarks
npm run bench
on iMac 5K (Late 2014), 3.5G i5, with Node.js 12.11.0:
[classic] style, long params x 980,342 ops/sec ±0.36% (95 runs sampled)
[classic] style, full params x 1,282,650 ops/sec ±0.54% (93 runs sampled)
[classic] style, with emoji x 1,286,513 ops/sec ±0.30% (92 runs sampled)
[classic] style, with icon x 1,127,749 ops/sec ±0.38% (92 runs sampled)
[flat] style, long params x 780,018 ops/sec ±0.32% (93 runs sampled)
[flat] style, full params x 1,015,617 ops/sec ±0.27% (96 runs sampled)
[flat] style, with emoji x 1,033,564 ops/sec ±0.51% (95 runs sampled)
[flat] style, with icon x 988,562 ops/sec ±0.33% (96 runs sampled)
See Also
- gradient-badge - Badge generator with color gradient support