remove logoWidth param (#10878)
* remove `logoWidth` param Fixes #10285 * remove `logoWidth` param Fixes #10285 * fix: add `logoWidth` parameter to BaseService test
This commit is contained in:
@@ -47,10 +47,6 @@ const optionalStringWhenNamedLogoPresent = Joi.alternatives().conditional(
|
||||
},
|
||||
)
|
||||
|
||||
const optionalNumberWhenAnyLogoPresent = Joi.alternatives()
|
||||
.conditional('namedLogo', { is: Joi.string().required(), then: Joi.number() })
|
||||
.conditional('logoSvg', { is: Joi.string().required(), then: Joi.number() })
|
||||
|
||||
const serviceDataSchema = Joi.object({
|
||||
isError: Joi.boolean(),
|
||||
label: Joi.string().allow(''),
|
||||
@@ -66,7 +62,6 @@ const serviceDataSchema = Joi.object({
|
||||
logoSvg: Joi.string(),
|
||||
logoColor: optionalStringWhenNamedLogoPresent,
|
||||
logoSize: optionalStringWhenNamedLogoPresent,
|
||||
logoWidth: optionalNumberWhenAnyLogoPresent,
|
||||
cacheSeconds: Joi.number().integer().min(0),
|
||||
style: Joi.string(),
|
||||
})
|
||||
|
||||
@@ -20,7 +20,7 @@ import toArray from './to-array.js'
|
||||
// 1. When `?logo=` contains a simple-icons logo or contains a base64-encoded
|
||||
// SVG, that logo is used. When a `&logoColor=` is specified, that color is
|
||||
// used (except for the base64-encoded logos). Otherwise the default color
|
||||
// is used. The appearance of the logo can be customized using `logoWidth`,
|
||||
// is used.
|
||||
// When `?logo=` is specified, any logo-related parameters specified
|
||||
// dynamically by the service, or by default in the service, are ignored.
|
||||
// 2. The second precedence is the dynamic logo returned by a service. This is
|
||||
@@ -52,11 +52,7 @@ export default function coalesceBadge(
|
||||
colorB: legacyOverrideColor,
|
||||
colorA: legacyOverrideLabelColor,
|
||||
} = overrides
|
||||
let {
|
||||
logoWidth: overrideLogoWidth,
|
||||
color: overrideColor,
|
||||
labelColor: overrideLabelColor,
|
||||
} = overrides
|
||||
let { color: overrideColor, labelColor: overrideLabelColor } = overrides
|
||||
|
||||
// Only use the legacy properties if the new ones are not provided
|
||||
if (typeof overrideColor === 'undefined') {
|
||||
@@ -73,7 +69,6 @@ export default function coalesceBadge(
|
||||
if (typeof overrideLabelColor === 'number') {
|
||||
overrideLabelColor = `${overrideLabelColor}`
|
||||
}
|
||||
overrideLogoWidth = +overrideLogoWidth || undefined
|
||||
|
||||
const {
|
||||
isError,
|
||||
@@ -85,7 +80,6 @@ export default function coalesceBadge(
|
||||
namedLogo: serviceNamedLogo,
|
||||
logoColor: serviceLogoColor,
|
||||
logoSize: serviceLogoSize,
|
||||
logoWidth: serviceLogoWidth,
|
||||
link: serviceLink,
|
||||
cacheSeconds: serviceCacheSeconds,
|
||||
style: serviceStyle,
|
||||
@@ -131,7 +125,6 @@ export default function coalesceBadge(
|
||||
// If the logo has been overridden it does not make sense to inherit the
|
||||
// original width or position.
|
||||
logoSize = overrideLogoSize
|
||||
logoWidth = overrideLogoWidth
|
||||
} else {
|
||||
if (serviceLogoSvg) {
|
||||
logoSvgBase64 = svg2base64(serviceLogoSvg)
|
||||
@@ -143,12 +136,11 @@ export default function coalesceBadge(
|
||||
namedLogoColor = coalesce(overrideLogoColor, serviceLogoColor)
|
||||
}
|
||||
logoSize = coalesce(overrideLogoSize, serviceLogoSize)
|
||||
logoWidth = coalesce(overrideLogoWidth, serviceLogoWidth)
|
||||
}
|
||||
if (namedLogo) {
|
||||
const iconSize = getIconSize(String(namedLogo).toLowerCase())
|
||||
|
||||
if (!logoWidth && iconSize && logoSize === 'auto') {
|
||||
if (iconSize && logoSize === 'auto') {
|
||||
logoWidth = (iconSize.width / iconSize.height) * DEFAULT_LOGO_HEIGHT
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +185,6 @@ describe('coalesceBadge', function () {
|
||||
{
|
||||
namedLogo: 'appveyor',
|
||||
logoColor: 'red',
|
||||
logoWidth: 100,
|
||||
},
|
||||
{},
|
||||
).logo,
|
||||
@@ -246,20 +245,6 @@ describe('coalesceBadge', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('Logo width', function () {
|
||||
it('overrides the logoWidth', function () {
|
||||
expect(coalesceBadge({ logoWidth: 20 }, {}, {})).to.include({
|
||||
logoWidth: 20,
|
||||
})
|
||||
})
|
||||
|
||||
it('applies the logo width', function () {
|
||||
expect(
|
||||
coalesceBadge({}, { namedLogo: 'npm', logoWidth: 275 }, {}),
|
||||
).to.include({ logoWidth: 275 })
|
||||
})
|
||||
})
|
||||
|
||||
describe('Links', function () {
|
||||
it('overrides the links', function () {
|
||||
expect(
|
||||
|
||||
@@ -12,7 +12,6 @@ const globalQueryParams = new Set([
|
||||
'logo',
|
||||
'logoColor',
|
||||
'logoSize',
|
||||
'logoWidth',
|
||||
'link',
|
||||
'colorA',
|
||||
'colorB',
|
||||
|
||||
Reference in New Issue
Block a user