From 01fc6e01272f0ff386ea1ffc8f97cfeaf7c810e7 Mon Sep 17 00:00:00 2001 From: Ariella Eliassaf Date: Tue, 27 Jun 2023 14:37:00 +0300 Subject: [PATCH] fix(pushbutton-element): The button gradient turns black when there are multiple buttons with the same color and we change the color of one of these buttons. #153 --- src/pushbutton-element.ts | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/pushbutton-element.ts b/src/pushbutton-element.ts index c0f1d61..e61386d 100644 --- a/src/pushbutton-element.ts +++ b/src/pushbutton-element.ts @@ -9,6 +9,9 @@ export class PushbuttonElement extends LitElement { @property() pressed = false; @property() label = ''; + private static pushbuttonCounter = 0; + private uniqueId; + readonly pinInfo: ElementPin[] = [ { name: '1.l', x: 0, y: 13, signals: [] }, { name: '2.l', x: 0, y: 32, signals: [] }, @@ -16,6 +19,11 @@ export class PushbuttonElement extends LitElement { { name: '2.r', x: 67, y: 32, signals: [] }, ]; + constructor() { + super(); + this.uniqueId = 'pushbutton' + PushbuttonElement.pushbuttonCounter++; + } + static get styles() { return css` :host { @@ -33,6 +41,14 @@ export class PushbuttonElement extends LitElement { -moz-appearance: none; } + .button-active-circle { + opacity: 0; + } + + button:active .button-active-circle { + opacity: 1; + } + .clickable-element { cursor: pointer; } @@ -51,8 +67,8 @@ export class PushbuttonElement extends LitElement { } render() { - const { color, label } = this; - const buttonFill = this.pressed ? `url(#grad-down-${color})` : `url(#grad-up-${color})`; + const { color, label, uniqueId } = this; + const buttonFill = this.pressed ? `url(#grad-down-${uniqueId})` : `url(#grad-up-${uniqueId})`; return html`