Skip to content

Commit

Permalink
feat(endpoint-badge): add logoSize support
Browse files Browse the repository at this point in the history
  • Loading branch information
LitoMore committed May 2, 2024
1 parent 1ab4a8d commit d1c8667
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/base-service/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const serviceDataSchema = Joi.object({
namedLogo: Joi.string(),
logoSvg: Joi.string(),
logoColor: optionalStringWhenNamedLogoPresent,
logoSize: optionalStringWhenNamedLogoPresent,
logoWidth: optionalNumberWhenAnyLogoPresent,
logoPosition: optionalNumberWhenAnyLogoPresent,
cacheSeconds: Joi.number().integer().min(0),
Expand Down
1 change: 1 addition & 0 deletions services/endpoint-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const endpointSchema = Joi.object({
namedLogo: Joi.string(),
logoSvg: Joi.string(),
logoColor: optionalStringWhenNamedLogoPresent,
logoSize: optionalStringWhenNamedLogoPresent,
logoWidth: optionalNumberWhenAnyLogoPresent,
logoPosition: optionalNumberWhenAnyLogoPresent,
style: Joi.string(),
Expand Down
10 changes: 10 additions & 0 deletions services/endpoint/endpoint.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ The endpoint badge takes a single required query param: <code>url</code>, which
named logo will be used and colored.
</td>
</tr>
<tr>
<td><code>logoSize</code></td>
<td>
Default: none. Make icons adaptively resize by setting auto.
Useful for some wider logos like <code>amd</code> and <code>amg</code>.
Supported for simple-icons logos only.
</td>
</tr>
<tr>
<td><code>logoWidth</code></td>
<td>
Expand Down Expand Up @@ -156,6 +164,7 @@ export default class Endpoint extends BaseJsonService {
namedLogo,
logoSvg,
logoColor,
logoSize,
logoWidth,
logoPosition,
style,
Expand All @@ -170,6 +179,7 @@ export default class Endpoint extends BaseJsonService {
namedLogo,
logoSvg,
logoColor,
logoSize,
logoWidth,
logoPosition,
style,
Expand Down
16 changes: 16 additions & 0 deletions services/endpoint/endpoint.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,22 @@ t.create('named logo with color')
expect(body).to.include(getSimpleIcon({ name: 'github', color: 'blue' }))
})

t.create('named logo with size')
.get('.svg?url=https://example.com/badge')
.intercept(nock =>
nock('https://example.com/').get('/badge').reply(200, {
schemaVersion: 1,
label: 'hey',
message: 'yo',
namedLogo: 'github',
logoSize: 'auto',
}),
)
.after((err, res, body) => {
expect(err).not.to.be.ok
expect(body).to.include(getSimpleIcon({ name: 'github', logoSize: 'auto' }))
})

const logoSvg = Buffer.from(
getShieldsIcon({ name: 'npm' }).replace('data:image/svg+xml;base64,', ''),
'base64',
Expand Down

0 comments on commit d1c8667

Please sign in to comment.