Skip to content

Commit

Permalink
fix(pushbutton-element): incorrect colors for button gradient on safa…
Browse files Browse the repository at this point in the history
…ri when there are multiple buttons

close #153
  • Loading branch information
AriellaE committed Jun 27, 2023
1 parent c108fa8 commit ea919b6
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/pushbutton-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ export class PushbuttonElement extends LitElement {
-moz-appearance: none;
}
button:active .button-circle {
fill: url(#grad-down);
}
.clickable-element {
cursor: pointer;
}
Expand All @@ -56,7 +52,7 @@ export class PushbuttonElement extends LitElement {

render() {
const { color, label } = this;
const buttonFill = this.pressed ? 'url(#grad-down)' : 'url(#grad-up)';
const buttonFill = this.pressed ? `url(#grad-down-${color})` : `url(#grad-up-${color})`;

return html`
<button
Expand All @@ -76,18 +72,24 @@ export class PushbuttonElement extends LitElement {
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
>
<style>
button:active .button-circle {
fill: url(#grad-down-${color});
}
</style>
<defs>
<linearGradient id="grad-up" x1="0" x2="1" y1="0" y2="1">
<linearGradient id="grad-up-${color}" x1="0" x2="1" y1="0" y2="1">
<stop stop-color="#ffffff" offset="0" />
<stop stop-color="${color}" offset="0.3" />
<stop stop-color="${color}" offset="0.5" />
<stop offset="1" />
</linearGradient>
<linearGradient id="grad-down-${color}" x1="1" x2="0" y1="1" y2="0">
<stop stop-color="#ffffff" offset="0" />
<stop stop-color="${color}" offset="0.3" />
<stop stop-color="${color}" offset="0.5" />
<stop offset="1" />
</linearGradient>
<linearGradient
id="grad-down"
xlink:href="#grad-up"
gradientTransform="rotate(180,0.5,0.5)"
></linearGradient>
</defs>
<rect x="0" y="0" width="12" height="12" rx=".44" ry=".44" fill="#464646" />
<rect x=".75" y=".75" width="10.5" height="10.5" rx=".211" ry=".211" fill="#eaeaea" />
Expand Down

0 comments on commit ea919b6

Please sign in to comment.