Sunsetting Shields custom logos (#10347)
* Sunsetting Shields custom logos * Reinstate info to contribute to SimpleIcons * Mention that no changes are required
This commit is contained in:
committed by
GitHub
parent
67deddb8a9
commit
1e4c8f54d7
29
lib/logos.js
29
lib/logos.js
@@ -6,9 +6,7 @@ import {
|
||||
} from '../badge-maker/lib/color.js'
|
||||
import coalesce from '../core/base-service/coalesce.js'
|
||||
import { svg2base64, getIconSize, resetIconPosition } from './svg-helpers.js'
|
||||
import loadLogos from './load-logos.js'
|
||||
import loadSimpleIcons from './load-simple-icons.js'
|
||||
const logos = loadLogos()
|
||||
const simpleIcons = loadSimpleIcons()
|
||||
|
||||
// for backwards-compatibility with deleted logos
|
||||
@@ -19,6 +17,7 @@ const logoAliases = {
|
||||
scrutinizer: 'scrutinizer-ci',
|
||||
stackoverflow: 'stack-overflow',
|
||||
tfs: 'azure-devops',
|
||||
travis: 'travisci',
|
||||
}
|
||||
const lightThreshold = 0.4
|
||||
const darkThreshold = 0.6
|
||||
@@ -59,24 +58,6 @@ function decodeDataUrlFromQueryParam(value) {
|
||||
return isDataUrl(maybeDataUrl) ? maybeDataUrl : undefined
|
||||
}
|
||||
|
||||
function getShieldsIcon({ name, color }) {
|
||||
if (!(name in logos)) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
const { svg, base64, isMonochrome } = logos[name]
|
||||
const svgColor = toSvgColor(color)
|
||||
if (svgColor) {
|
||||
if (isMonochrome) {
|
||||
return svg2base64(svg.replace(/fill="(.+?)"/g, `fill="${svgColor}"`))
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
} else {
|
||||
return base64
|
||||
}
|
||||
}
|
||||
|
||||
function getSimpleIconStyle({ icon, style }) {
|
||||
const { hex } = icon
|
||||
if (style !== 'social' && brightness(normalizeColor(hex)) <= lightThreshold) {
|
||||
@@ -93,7 +74,7 @@ function getSimpleIconStyle({ icon, style }) {
|
||||
// badge. If `size` is not 'auto', the icon will be displayed at its original.
|
||||
// https://github.com/badges/shields/pull/9191
|
||||
function getSimpleIcon({ name, color, style, size }) {
|
||||
const key = name === 'travis' ? 'travis-ci' : name.replace(/ /g, '-')
|
||||
const key = name.replace(/ /g, '-')
|
||||
|
||||
if (!(key in simpleIcons)) {
|
||||
return undefined
|
||||
@@ -134,10 +115,7 @@ function prepareNamedLogo({ name, color, style, size }) {
|
||||
name = logoAliases[name]
|
||||
}
|
||||
|
||||
return (
|
||||
getShieldsIcon({ name, color }) ||
|
||||
getSimpleIcon({ name, color, style, size })
|
||||
)
|
||||
return getSimpleIcon({ name, color, style, size })
|
||||
}
|
||||
|
||||
function makeLogo(defaultNamedLogo, overrides) {
|
||||
@@ -159,7 +137,6 @@ export {
|
||||
isDataUrl,
|
||||
decodeDataUrlFromQueryParam,
|
||||
prepareNamedLogo,
|
||||
getShieldsIcon,
|
||||
getSimpleIcon,
|
||||
makeLogo,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user