badge-up2
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

badge-up2

Build codecov npm downloads

This is a simple library that generates SVG badges, based on badge-up.

Install

npm install badge-up2

Basic Usage

const { basic, basicColors } = require('badge-up2');
const svg = basic('batman', 'component', basicColors.green);

example

The color argument can be a CSS color, or one of the specially named colors found in basicColors.

Advanced Usage

With this API you can create arbitrary badges with an arbitrary number of sections.

Each section is either a string or a hash. The hash should have the following properties:

  • text: The text to display in the section
  • color (optional): The background color of the section. This can be either a six-character hex code or a css color name.
  • strokeColor (optional): The color of the section border

If color is not provided, then a default is used. The default color for the first section is #696969 and #d3d3d3 for subsequent sections. Passing a string rather than a hash is equivalent to passing a hash with only the text property.

const { badge } = require('badge-up2');
const sections = [
    'foo/far;fun',
    { text: 'bar\nbaz', color: 'orange'},
    { text: 'mork "mindy"', color: 'olive', strokeColor: 'white'},
    { text: '<∀>', color: 'moccasin'},
];
const svg = badge(sections);

example

Readme

Keywords

Package Sidebar

Install

npm i badge-up2

Weekly Downloads

51

Version

2.0.1

License

MIT

Unpacked Size

17.5 kB

Total Files

11

Last publish

Collaborators

  • stevenhair