-
Notifications
You must be signed in to change notification settings - Fork 3.7k
♻️ change call-service row to button row #4744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e1bf33c
♻️ change call-service row to button row
iantrich d43a541
address comments
iantrich 03b8720
cleanup
iantrich 7fada23
address comments
iantrich 0963d14
remove unused function
iantrich 4cacf89
address comments
iantrich 4dab3d1
super
iantrich c783275
Add CallServiceConfig back in
bramkragten 56209cd
Merge branch 'dev' into new-button-row
bramkragten 3a8a845
Update types.ts
iantrich 43cfd9e
Update types.ts
iantrich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| import { | ||
| html, | ||
| LitElement, | ||
| TemplateResult, | ||
| customElement, | ||
| property, | ||
| css, | ||
| CSSResult, | ||
| } from "lit-element"; | ||
| import "@material/mwc-button"; | ||
|
|
||
| import "../../../components/ha-icon"; | ||
|
|
||
| import { LovelaceRow, ButtonRowConfig } from "../entity-rows/types"; | ||
| import { HomeAssistant } from "../../../types"; | ||
| import { actionHandler } from "../common/directives/action-handler-directive"; | ||
| import { hasAction } from "../common/has-action"; | ||
| import { ActionHandlerEvent } from "../../../data/lovelace"; | ||
| import { handleAction } from "../common/handle-action"; | ||
|
|
||
| @customElement("hui-button-row") | ||
| export class HuiButtonRow extends LitElement implements LovelaceRow { | ||
| public hass?: HomeAssistant; | ||
| @property() private _config?: ButtonRowConfig; | ||
|
|
||
| public setConfig(config: ButtonRowConfig): void { | ||
| if (!config) { | ||
| throw new Error("Error in card configuration."); | ||
| } | ||
|
|
||
| if (!config.name) { | ||
| throw new Error("Error in card configuration. No name specified."); | ||
| } | ||
|
|
||
| if (!config.tap_action) { | ||
| throw new Error("Error in card configuration. No action specified."); | ||
| } | ||
|
|
||
| this._config = config; | ||
| } | ||
|
|
||
| protected render(): TemplateResult { | ||
| if (!this._config) { | ||
| return html``; | ||
| } | ||
|
|
||
| return html` | ||
| <ha-icon .icon=${this._config.icon || "hass:remote"}></ha-icon> | ||
| <div class="flex"> | ||
| <div>${this._config.name}</div> | ||
| <mwc-button | ||
| @action=${this._handleAction} | ||
| .actionHandler=${actionHandler({ | ||
| hasHold: hasAction(this._config!.hold_action), | ||
| hasDoubleClick: hasAction(this._config!.double_tap_action), | ||
| })} | ||
| >${this._config.action_name | ||
| ? this._config.action_name | ||
| : this.hass!.localize("ui.card.service.run")}</mwc-button | ||
| > | ||
| </div> | ||
| `; | ||
| } | ||
|
|
||
| static get styles(): CSSResult { | ||
| return css` | ||
| :host { | ||
| display: flex; | ||
| align-items: center; | ||
| } | ||
| ha-icon { | ||
| padding: 8px; | ||
| color: var(--paper-item-icon-color); | ||
| } | ||
| .flex { | ||
| flex: 1; | ||
| overflow: hidden; | ||
| margin-left: 16px; | ||
| display: flex; | ||
| justify-content: space-between; | ||
| align-items: center; | ||
| } | ||
| .flex div { | ||
| white-space: nowrap; | ||
| overflow: hidden; | ||
| text-overflow: ellipsis; | ||
| } | ||
| mwc-button { | ||
| margin-right: -0.57em; | ||
| } | ||
| `; | ||
| } | ||
|
|
||
| private _handleAction(ev: ActionHandlerEvent) { | ||
| handleAction(this, this.hass!, this._config!, ev.detail.action!); | ||
| } | ||
| } | ||
|
|
||
| declare global { | ||
| interface HTMLElementTagNameMap { | ||
| "hui-button-row": HuiButtonRow; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.