Skip to content

Commit

Permalink
Add logo style badges - popout, popout-square (#1478)
Browse files Browse the repository at this point in the history
* add logo style badges

add new styles:
- flat-logo
- flat-square-logo

* rename flat-logo -> popout

flat-logo -> popout
flat-square-logo -> popout-square

* default centered, add logoAlign param

* fix test

* logoAlign -> logoPosition

* reverse logoPosition direction

* fixup
  • Loading branch information
RedSparr0w authored Jul 28, 2018
1 parent 329db7d commit 409bcd1
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/badge-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ function makeBadgeData(defaultLabel, overrides) {
colorscheme: 'lightgrey',
template: overrides.style,
logo: makeLogo(undefined, overrides),
logoPosition: +overrides.logoPosition,
logoWidth: +overrides.logoWidth,
links: toArray(overrides.link),
colorA: makeColor(overrides.colorA),
Expand Down
2 changes: 2 additions & 0 deletions lib/badge-data.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ describe('Badge data helpers', function() {
label: 'no, my badge',
style: 'flat-square',
logo: 'image/svg+xml;base64,PHN2ZyB4bWxu',
logoPosition: 10,
logoWidth: '25',
link: 'https://example.com/',
colorA: 'blue',
Expand All @@ -76,6 +77,7 @@ describe('Badge data helpers', function() {
colorscheme: 'lightgrey',
template: 'flat-square',
logo: 'data:image/svg+xml;base64,PHN2ZyB4bWxu',
logoPosition: 10,
logoWidth: 25,
links: ['https://example.com/'],
colorA: 'blue',
Expand Down
2 changes: 2 additions & 0 deletions lib/export-supported-features-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const supportedFeatures = {
'flat',
'flat-square',
'for-the-badge',
'popout',
'popout-square',
'social',
],
};
Expand Down
10 changes: 10 additions & 0 deletions lib/make-badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ function makeBadge (measurer, {
colorA,
colorB,
logo,
logoPosition,
logoWidth,
links = ['', ''],
}) {
Expand All @@ -122,6 +123,14 @@ function makeBadge (measurer, {
if (!(`${template}-${format}` in templates)) {
template = format === 'svg' ? 'flat' : 'default';
}
if (template.startsWith('popout')) {
if (logo){
logoPosition = (logoPosition <= 10 && logoPosition >= -10) ? logoPosition : 0;
logoWidth = +logoWidth || 32;
} else {
template = template.replace('popout', 'flat');
}
}
if (template === 'social') {
text[0] = capitalize(text[0]);
} else if (template === 'for-the-badge') {
Expand Down Expand Up @@ -164,6 +173,7 @@ function makeBadge (measurer, {
],
links: links.map(escapeXml),
logo,
logoPosition,
logoWidth,
logoPadding,
colorA,
Expand Down
1 change: 1 addition & 0 deletions lib/request-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const globalQueryParams = new Set([
'style',
'link',
'logo',
'logoPosition',
'logoWidth',
'link',
'colorA',
Expand Down
23 changes: 23 additions & 0 deletions templates/popout-square-template.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions templates/popout-template.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 409bcd1

Please sign in to comment.