import { Fragment, default as React } from 'react'; import PropTypes from 'prop-types'; import StaticBadgeMaker from './static-badge-maker'; import DynamicBadgeMaker from './dynamic-badge-maker'; import { staticBadgeUrl } from '../lib/badge-url'; import { advertisedStyles, logos } from '../../supported-features.json'; export default class Usage extends React.PureComponent { static propTypes = { baseUri: PropTypes.string.isRequired, longCache: PropTypes.bool.isRequired, }; renderColorExamples () { const { baseUri, longCache } = this.props; const colors = [ 'brightgreen', 'green', 'yellowgreen', 'yellow', 'orange', 'red', 'lightgrey', 'blue', 'ff69b4', ]; return (

{ colors.map((color, i) => ( {color} {} ))}

); } renderStyleExamples () { const { baseUri, longCache } = this.props; return ( { advertisedStyles.map((style, i) => { const badgeUri = staticBadgeUrl( baseUri, 'style', style, 'green', { longCache, style }); return ( ); })}
{style} {badgeUri}
); } static renderNamedLogos() { const renderLogo = logo => {logo}; const [first, ...rest] = logos; return [renderLogo(first)].concat( rest.reduce((result, logo) => result.concat([', ', renderLogo(logo)]), []) ); } render() { const { baseUri } = this.props; return (

Your Badge

Static


{baseUri}/badge/<SUBJECT>-<STATUS>-<COLOR>.svg

Dashes -- - Dash
Underscores __ _ Underscore
_ or Space     Space
{ this.renderColorExamples() }

Dynamic

/badge/dynamic/json.svg?url=<URL>&label=<LABEL>&query=<$.DATA.SUBDATA>&colorB=<COLOR>&prefix=<PREFIX>&suffix=<SUFFIX>

/badge/dynamic/xml.svg?url=<URL>&label=<LABEL>&query=<//data/subdata>&colorB=<COLOR>&prefix=<PREFIX>&suffix=<SUFFIX>

/badge/dynamic/yaml.svg?url=<URL>&label=<LABEL>&query=<$.DATA.SUBDATA>&colorB=<COLOR>&prefix=<PREFIX>&suffix=<SUFFIX>


Styles

The following styles are available (flat is the default as of Feb 1st 2015):

{ this.renderStyleExamples() }

Here are a few other parameters you can use: (connecting several with "&" is possible)

?label=healthinesses Override the default left-hand-side text ( URL-Encoding {} needed for spaces or special characters!)
?logo=appveyor Insert one of the named logos ({this.constructor.renderNamedLogos()})
?logo=data:image/png;base64,… Insert custom logo image (≥ 14px high)
?logoWidth=40 Set the horizontal space to give to the logo
?link=http://left&link=http://right Specify what clicking on the left/right of a badge should do (esp. for social badge style)
?colorA=abcdef Set background of the left part (hex, rgb, rgba, hsl, hsla and css named colors supported)
?colorB=fedcba Set background of the right part (hex, rgb, rgba, hsl, hsla and css named colors supported)
?maxAge=3600 Set the HTTP cache lifetime in secs (values below the default will be ignored)

We support .svg, .json, .png and a few others, but use them responsibly.

); } }