Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(endpoint-badge): add logoSize support; test [endpoint] #10132

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Default: none. Make icons adaptively resize by setting auto.
Default: none. Make icons adaptively resize by setting <code>auto</code>.

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
Loading