Skip to content

Commit

Permalink
show state
Browse files Browse the repository at this point in the history
  • Loading branch information
RFDarter committed Dec 23, 2024
1 parent 0141c63 commit 3ada94f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 10 additions & 0 deletions packages/v3/src/css/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,14 @@ export default css`
background-color: rgba(127, 127, 127, 0.2);
transition-duration: 1s;
}
.abuttonIsState {
background-color: #28a745;
color: white;
border: none;
padding: 10px 20px;
font-size: 16px;
border-radius: 4px;
transition: background-color 0.3s ease;
}
`;
10 changes: 6 additions & 4 deletions packages/v3/src/esp-entity-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,12 @@ class ActionRenderer {
return this[method]();
}

private _actionButton(entity: entityConfig, label: string, action: string) {
private _actionButton(entity: entityConfig, label: string, action: string, isCurrentState: boolean = false) {
if (!entity) return;
let a = action || label.toLowerCase();
return html`<button
class="abutton"
class="${isCurrentState ? 'abuttonIsState' : 'abutton'}"
?disabled=${isCurrentState}
@click=${() => this.actioner?.restAction(entity, a)}
>
${label}
Expand Down Expand Up @@ -737,8 +738,9 @@ class ActionRenderer {
}
render_valve() {
if (!this.entity) return;
return html`${this._actionButton(this.entity, "OPEN", "open")}
console.log(this.entity.state)
return html`${this._actionButton(this.entity, "OPEN", "open", this.entity.state === "OPEN")}
${this._actionButton(this.entity, "☐", "stop")}
${this._actionButton(this.entity, "CLOSE", "close")}`;
${this._actionButton(this.entity, "CLOSE", "close", this.entity.state === "CLOSED")}`;
}
}

0 comments on commit 3ada94f

Please sign in to comment.