Skip to content

Commit

Permalink
make drop-shadow more pronounced
Browse files Browse the repository at this point in the history
  • Loading branch information
chris48s committed Jan 21, 2024
1 parent dd56710 commit 4394b2e
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions badge-maker/lib/badge-renderers.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,24 @@ class Badge {
textLength: FONT_SCALE_UP_FACTOR * textWidth,
},
})
const shadow = this.constructor.shadow ? shadowText : ''
const shadowBlur = new XmlElement({
name: 'text',
content: [content],
attrs: {
'aria-hidden': 'true',
x,
y: 150 + this.constructor.verticalMargin,
fill: shadowColor,
'fill-opacity': '.80',
filter: 'url(#blur)',
transform: FONT_SCALE_DOWN_VALUE,
textLength: FONT_SCALE_UP_FACTOR * textWidth,
},
})

const shadow = this.constructor.shadow
? new ElementList({ content: [shadowBlur, shadowText] })
: ''

if (!link) {
return new ElementList({ content: [shadow, text] })
Expand Down Expand Up @@ -416,6 +433,17 @@ class Flat extends Badge {
}

render() {
const blur = new XmlElement({
name: 'filter',
content: [
new XmlElement({
name: 'feGaussianBlur',
attrs: { in: 'SourceGraphic', stdDeviation: '16' },
}),
],
attrs: { id: 'blur' },
})

const gradient = new XmlElement({
name: 'linearGradient',
content: [
Expand Down Expand Up @@ -446,7 +474,7 @@ class Flat extends Badge {
accessibleText: this.accessibleText,
height: this.constructor.height,
},
[gradient, clipPath, backgroundGroup, this.foregroundGroupElement],
[blur, gradient, clipPath, backgroundGroup, this.foregroundGroupElement],
)
}
}
Expand Down

0 comments on commit 4394b2e

Please sign in to comment.