Files
shields/badge-maker
dependabot[bot] 6af9328e6d chore(deps-dev): bump is-svg from 4.3.2 to 5.0.0 (#8959)
* chore(deps-dev): bump is-svg from 4.3.2 to 5.0.0

Bumps [is-svg](https://github.com/sindresorhus/is-svg) from 4.3.2 to 5.0.0.
- [Release notes](https://github.com/sindresorhus/is-svg/releases)
- [Commits](https://github.com/sindresorhus/is-svg/compare/v4.3.2...v5.0.0)

---
updated-dependencies:
- dependency-name: is-svg
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* import is-svg with async dynamic imports

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: chris48s <git@chris-shaw.dev>
Co-authored-by: chris48s <chris48s@users.noreply.github.com>
2023-04-16 13:07:57 +01:00
..
2020-06-03 18:44:15 +01:00
2020-04-23 20:05:48 +01:00
2020-06-03 18:44:15 +01:00

badge-maker

npm version npm license npm type definitions

Installation

npm install badge-maker

Usage

On the console

npm install -g badge-maker
badge build passed :green > mybadge.svg

As a library

With CommonJS in JavaScript,

const { makeBadge, ValidationError } = require('badge-maker')

With ESM or TypeScript,

import { makeBadge, ValidationError } from 'badge-maker'
const format = {
  label: 'build',
  message: 'passed',
  color: 'green',
}

const svg = makeBadge(format)
console.log(svg) // <svg...

try {
  makeBadge({})
} catch (e) {
  console.log(e) // ValidationError: Field `message` is required
}

Node version support

The latest version of badge-maker supports all currently maintained Node versions. See the Node Release Schedule.

Format

The format is the following:

{
  label: 'build',  // (Optional) Badge label
  message: 'passed',  // (Required) Badge message
  labelColor: '#555',  // (Optional) Label color
  color: '#4c1',  // (Optional) Message color

  // (Optional) One of: 'plastic', 'flat', 'flat-square', 'for-the-badge' or 'social'
  // Each offers a different visual design.
  style: 'flat',
}

Colors

There are three ways to specify color and labelColor:

  1. One of the Shields named colors:
  • the default labelColor

  • the default color

  • the default color

  1. A three- or six-character hex color, optionally prefixed with #:
  • etc.
  1. Any valid CSS color, e.g.
  • rgb(...), rgba(...)
  • hsl(...), hsla(...)
  • etc.

Raster Formats

Conversion to raster formats is no longer directly supported. In javascript code, SVG badges can be converted to raster formats using a library like gm. On the console, the output of badge can be piped to a utility like imagemagick e.g: badge build passed :green | magick svg:- gif:-.