badgen/README.md

82 wiersze
2.8 KiB
Markdown
Czysty Zwykły widok Historia

2018-08-22 08:05:46 +00:00
# badgen
2018-07-18 07:38:59 +00:00
2018-08-08 20:05:01 +00:00
[![npm version][npm-src]][npm-href]
[![Coverage Status][coveralls-src]][coveralls-href]
[![Install size][packagephobia-src]][packagephobia-href]
[![License][license-src]][license-href]
2018-05-30 03:13:32 +00:00
2018-08-04 12:58:11 +00:00
Fast handcraft svg badge generator. Used on [badgen.net](https://badgen.net).
2018-05-30 03:13:32 +00:00
2018-08-23 02:23:52 +00:00
- 🌀 Zero dependency
2018-07-19 06:54:54 +00:00
- ⚡️ Fast by design (see [benchmarks](#benchmarks))
- 👯‍ Pure JavaScript, running in node & browser
2018-06-23 09:54:52 +00:00
2018-05-30 03:13:32 +00:00
## Usage
2018-06-23 03:20:45 +00:00
`npm install badgen`
2018-05-30 03:13:32 +00:00
2018-06-23 03:20:45 +00:00
```javascript
const badgen = require('badgen')
2018-05-30 03:13:32 +00:00
2018-06-23 03:20:45 +00:00
const svgString = badgen({
2019-07-06 07:34:14 +00:00
label: 'npm', // <Text>
2018-06-29 15:21:35 +00:00
status: 'v1.2.3', // <Text>
2018-07-20 08:30:13 +00:00
color: 'blue', // <Color RGB> or <Color Name>, optional
style: 'flat', // 'flat' or undefined, optional
2018-09-08 03:57:39 +00:00
icon: 'data:image/svg+xml;base64,...', // Use icon, optional
2019-07-06 07:34:14 +00:00
iconWidth: 13, // Use this if icon is not square
labelColor: 'red' // <Color RGB> or <Color Name>, optional
2018-07-16 13:58:23 +00:00
})
2018-06-23 03:20:45 +00:00
```
2018-06-22 17:20:48 +00:00
2018-06-29 15:21:35 +00:00
Available color names:
2018-07-27 06:45:25 +00:00
![](https://badgen.net/badge/color/blue/blue)
![](https://badgen.net/badge/color/cyan/cyan)
![](https://badgen.net/badge/color/green/green)
![](https://badgen.net/badge/color/yellow/yellow)
![](https://badgen.net/badge/color/orange/orange)
![](https://badgen.net/badge/color/red/red)
![](https://badgen.net/badge/color/pink/pink)
![](https://badgen.net/badge/color/purple/purple)
![](https://badgen.net/badge/color/grey/grey)
2018-08-24 14:02:08 +00:00
![](https://badgen.net/badge/color/black/black)
2018-06-29 15:21:35 +00:00
2018-09-08 03:57:39 +00:00
### In browser
```html
<script src="https://cdn.jsdelivr.net/npm/badgen/badgen.min.js"></script>
<script>
var svgString = badgen({ /*...*/ })
</script>
```
2018-06-23 09:54:52 +00:00
## Benchmarks
2018-08-23 02:29:08 +00:00
`npm run bench` on my MacBook Pro (Early 2015), 2.7G i5, with Node.js 10.9.0:
2018-06-23 09:54:52 +00:00
```bash
2018-08-31 05:36:46 +00:00
[classic] style, long params x 784,111 ops/sec ±1.53% (89 runs sampled)
[classic] style, full params x 1,096,667 ops/sec ±1.37% (90 runs sampled)
[classic] style, with emoji x 1,086,230 ops/sec ±1.85% (92 runs sampled)
[classic] style, with icon x 941,914 ops/sec ±0.41% (93 runs sampled)
[flat] style, long params x 546,447 ops/sec ±0.52% (91 runs sampled)
[flat] style, full params x 612,977 ops/sec ±1.08% (94 runs sampled)
[flat] style, with emoji x 620,193 ops/sec ±0.95% (92 runs sampled)
[flat] style, with icon x 566,848 ops/sec ±0.84% (93 runs sampled)
2018-06-23 09:54:52 +00:00
```
2018-09-12 03:22:02 +00:00
## See Also
- [gradient-badge][gradient-badge] - Badge generator with color gradient support
2018-08-08 20:05:01 +00:00
[npm-src]: https://badgen.net/npm/v/badgen
[npm-href]: https://www.npmjs.com/package/badgen
[packagephobia-src]: https://badgen.net/packagephobia/install/badgen
[packagephobia-href]: https://packagephobia.now.sh/result?p=badgen
[coveralls-src]: https://badgen.net/coveralls/c/github/amio/badgen/master
[coveralls-href]: https://coveralls.io/github/amio/badgen?branch=master
[license-src]: https://badgen.net/github/license/amio/badgen
[license-href]: LICENSE.md
2018-09-12 03:22:02 +00:00
[gradient-badge]: https://github.com/bokub/gradient-badge