gradient-badge
Version:
Badge generator with gradient support
93 lines (66 loc) • 3.15 kB
Markdown
//www.npmjs.com/package/gradient-badge)
[![Build][build]](https://travis-ci.org/bokub/gradient-badge)
[![Coverage][coverage]](https://codecov.io/gh/bokub/gradient-badge)
[![Demo][demo-src]][demo]
[![code style][prettier]](https://github.com/prettier/prettier)
> Badge generator with gradient support 🍭
```
$ npm i gradient-badge
```
**gradient-badge** works exactly like [badgen](https://github.com/badgen/badgen), with the **`gradient`** parameter in addition.
**Node.js**
```javascript
const gradientBadge = require('gradient-badge');
const svgString = gradientBadge({
subject: 'version', // <text>
status: 'v1.2.3', // <text>
style: 'flat', // 'flat' or undefined, optional
// And any other parameter supported by badgen (icon, scale...)
gradient: ['pink', 'F78642'], // array of colors (Hexadecimal or name)
});
```
**Browser**
```html
<script src="https://cdn.jsdelivr.net/npm/gradient-badge"></script>
<script>
var svgString = gradientBadge({
/* same as above */
});
</script>
```
Result: ![Result][usage]
You can apply a color gradient to any badge already generated with badgen:
```javascript
const { badgen } = require('badgen');
const { applyGradient } = require('gradient-badge');
const originalBadge = badgen({
/* ... */
});
const svgString = applyGradient(originalBadge, ['B65CFF', 'cyan']);
```
Here are a few more examples of what you can do.
![Stars][stars] ![Standard][standard] ![Patreon][patreon] ![Instagram][instagram] ![Vue.js][vue] ![Rainbow][rainbow]
- [badgen](https://github.com/badgen/badgen) - Fast handcraft svg badge generator.
- [badge-action](https://github.com/emibcn/badge-action) - Create a badge using GitHub Actions.
[ ]: https://runkit.io/bokub/npm-version/branches/master/gradient-badge
[ ]: https://runkit.io/bokub/badge/branches/master/demo/available/ffb836-fc6d60
[ ]: https://runkit.io/bokub/badge/branches/master/code%20style/prettier/ff94c8-cacfda-61eddb
[ ]: https://runkit.io/bokub/build/branches/master/bokub/gradient-badge
[ ]: https://runkit.io/bokub/codecov/branches/master/bokub/gradient-badge
[ ]: https://runkit.io/bokub/badge/branches/master/version/v1.2.3/pink-F78642?style=flat
[ ]: https://git.io/gradientbadge
[ ]: https://runkit.io/bokub/badge/branches/master/stars/★★★★☆/00a65e-abf269
[ ]: https://runkit.io/bokub/badge/branches/master/code%20style/standard/ff22aa-bf00ff?style=flat
[ ]: https://runkit.io/bokub/badge/branches/master/become/a%20patron/f96854-f9be75
[ ]: https://runkit.io/bokub/badge/branches/master/follow%20me/instagram/833ab4-fd1d1d-fcb045
[ ]: https://runkit.io/bokub/badge/branches/master/built%20with/Vue.js/42b883-35495e?style=flat
[ ]: https://runkit.io/bokub/badge/branches/master/rainbow/compatible/ff4564-ffa82e-ffff00-21ed28-19ffa7-2edcff-5490ff-a787ff-ea8fff-ff5e84
[![npm][version]](https: