Skip to content

Commit ea919b6

Browse files
committed
fix(pushbutton-element): incorrect colors for button gradient on safari when there are multiple buttons
close #153
1 parent c108fa8 commit ea919b6

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/pushbutton-element.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ export class PushbuttonElement extends LitElement {
3333
-moz-appearance: none;
3434
}
3535
36-
button:active .button-circle {
37-
fill: url(#grad-down);
38-
}
39-
4036
.clickable-element {
4137
cursor: pointer;
4238
}
@@ -56,7 +52,7 @@ export class PushbuttonElement extends LitElement {
5652

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

6157
return html`
6258
<button
@@ -76,18 +72,24 @@ export class PushbuttonElement extends LitElement {
7672
xmlns="http://www.w3.org/2000/svg"
7773
xmlns:xlink="http://www.w3.org/1999/xlink"
7874
>
75+
<style>
76+
button:active .button-circle {
77+
fill: url(#grad-down-${color});
78+
}
79+
</style>
7980
<defs>
80-
<linearGradient id="grad-up" x1="0" x2="1" y1="0" y2="1">
81+
<linearGradient id="grad-up-${color}" x1="0" x2="1" y1="0" y2="1">
82+
<stop stop-color="#ffffff" offset="0" />
83+
<stop stop-color="${color}" offset="0.3" />
84+
<stop stop-color="${color}" offset="0.5" />
85+
<stop offset="1" />
86+
</linearGradient>
87+
<linearGradient id="grad-down-${color}" x1="1" x2="0" y1="1" y2="0">
8188
<stop stop-color="#ffffff" offset="0" />
8289
<stop stop-color="${color}" offset="0.3" />
8390
<stop stop-color="${color}" offset="0.5" />
8491
<stop offset="1" />
8592
</linearGradient>
86-
<linearGradient
87-
id="grad-down"
88-
xlink:href="#grad-up"
89-
gradientTransform="rotate(180,0.5,0.5)"
90-
></linearGradient>
9193
</defs>
9294
<rect x="0" y="0" width="12" height="12" rx=".44" ry=".44" fill="#464646" />
9395
<rect x=".75" y=".75" width="10.5" height="10.5" rx=".211" ry=".211" fill="#eaeaea" />

0 commit comments

Comments
 (0)