From c026ebf23570cddcbd4b80dd943362805911eef2 Mon Sep 17 00:00:00 2001 From: Danial Date: Mon, 16 Oct 2017 09:52:28 +1300 Subject: [PATCH] for the badge style badges (#1166) https://forthebadge.com/ style of badges, with link support Close #818 --- lib/badge-data.js | 2 +- lib/badge.js | 4 ++++ templates/for-the-badge-template.svg | 23 +++++++++++++++++++++++ try.html | 4 ++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 templates/for-the-badge-template.svg diff --git a/lib/badge-data.js b/lib/badge-data.js index 864f9f707a..732bd51fca 100644 --- a/lib/badge-data.js +++ b/lib/badge-data.js @@ -31,7 +31,7 @@ function prependPrefix(s, prefix) { } function isValidStyle(style) { - const validStyles = ['default', 'plastic', 'flat', 'flat-square', 'social']; + const validStyles = ['default', 'plastic', 'flat', 'flat-square', 'for-the-badge', 'social']; return style ? validStyles.indexOf(style) >= 0 : false; } diff --git a/lib/badge.js b/lib/badge.js index b5de980970..a0d8e31bbe 100644 --- a/lib/badge.js +++ b/lib/badge.js @@ -96,6 +96,10 @@ function makeImage(data, cb) { if (!(data.template + '-' + data.format in templates)) { data.template = 'flat'; } + if (data.template === 'for-the-badge'){ + data.text[0] = data.text[0].toUpperCase(); + data.text[1] = data.text[1].toUpperCase(); + } if (data.colorscheme) { let pickedColorscheme = colorscheme[data.colorscheme]; if (!pickedColorscheme) { diff --git a/templates/for-the-badge-template.svg b/templates/for-the-badge-template.svg new file mode 100644 index 0000000000..34a1358cc7 --- /dev/null +++ b/templates/for-the-badge-template.svg @@ -0,0 +1,23 @@ + + + + + + + {{?it.logo}} + + {{?}} + {{=it.escapeXml(it.text[0].toUpperCase())}} + {{=it.escapeXml(it.text[1].toUpperCase())}} + + {{?(it.links[0] && it.links[0].length)}} + + + + {{?}} + {{?(it.links[0] && it.links[0].length || it.links[1] && it.links[1].length)}} + + + + {{?}} + diff --git a/try.html b/try.html index 076a250eff..c3fc3c8dbe 100644 --- a/try.html +++ b/try.html @@ -1373,6 +1373,10 @@ The following styles are available (flat is the default as of Feb 1st 2015): https://img.shields.io/badge/style-flat--squared-green.svg?style=flat-square + + https://img.shields.io/badge/style-for--the--badge-green.svg?style=for-the-badge + + https://img.shields.io/badge/style-social-green.svg?style=social