-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Use shopping list card in panel #7519
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
bramkragten
merged 6 commits into
home-assistant:dev
from
iantrich:remove-shopping-panel
Nov 5, 2020
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d3fa894
remove shopping-list panel
iantrich ef58429
cleanup
iantrich b455ced
use lovelace card in shopping-list panel
iantrich 6097009
fix typo
iantrich 284fd32
add conversation
iantrich 03339ff
address review comments
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 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 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| import "@polymer/app-layout/app-header/app-header"; | ||
| import "@polymer/app-layout/app-toolbar/app-toolbar"; | ||
| import { | ||
| css, | ||
| CSSResultArray, | ||
| customElement, | ||
| html, | ||
| internalProperty, | ||
| LitElement, | ||
| property, | ||
| PropertyValues, | ||
| TemplateResult, | ||
| } from "lit-element"; | ||
| import memoizeOne from "memoize-one"; | ||
| import { mdiMicrophone } from "@mdi/js"; | ||
|
|
||
| import { HomeAssistant } from "../../types"; | ||
| import { haStyle } from "../../resources/styles"; | ||
| import { createCardElement } from "../lovelace/create-element/create-card-element"; | ||
| import { LovelaceCard } from "../lovelace/types"; | ||
| import { HuiErrorCard } from "../lovelace/cards/hui-error-card"; | ||
| import { isComponentLoaded } from "../../common/config/is_component_loaded"; | ||
| import { showVoiceCommandDialog } from "../../dialogs/voice-command-dialog/show-ha-voice-command-dialog"; | ||
|
|
||
| import "../../components/ha-menu-button"; | ||
| import "../../layouts/ha-app-layout"; | ||
|
|
||
| @customElement("ha-panel-shopping-list") | ||
| class PanelShoppingList extends LitElement { | ||
| @property({ attribute: false }) public hass!: HomeAssistant; | ||
|
|
||
| @property({ type: Boolean, reflect: true }) public narrow!: boolean; | ||
|
|
||
| @internalProperty() private _card!: LovelaceCard | HuiErrorCard; | ||
|
|
||
| private _conversation = memoizeOne((_components) => | ||
| isComponentLoaded(this.hass, "conversation") | ||
| ); | ||
|
|
||
| protected firstUpdated(changedProperties: PropertyValues): void { | ||
| super.firstUpdated(changedProperties); | ||
|
|
||
| this._card = createCardElement({ type: "shopping-list" }) as LovelaceCard; | ||
| this._card.hass = this.hass; | ||
| } | ||
|
|
||
| protected updated(changedProperties: PropertyValues): void { | ||
| super.updated(changedProperties); | ||
|
|
||
| if (changedProperties.has("hass")) { | ||
| this._card.hass = this.hass; | ||
| } | ||
| } | ||
|
|
||
| protected render(): TemplateResult { | ||
| return html` | ||
| <ha-app-layout> | ||
| <app-header fixed slot="header"> | ||
| <app-toolbar> | ||
| <ha-menu-button | ||
| .hass=${this.hass} | ||
| .narrow=${this.narrow} | ||
| ></ha-menu-button> | ||
| <div main-title>${this.hass.localize("panel.shopping_list")}</div> | ||
| ${this._conversation(this.hass.config.components) | ||
| ? html` | ||
| <mwc-icon-button | ||
| .label=${this.hass!.localize( | ||
| "ui.panel.shopping_list.start_conversation" | ||
| )} | ||
| @click=${this._showVoiceCommandDialog} | ||
| > | ||
| <ha-svg-icon .path=${mdiMicrophone}></ha-svg-icon> | ||
| </mwc-icon-button> | ||
| ` | ||
| : ""} | ||
| </app-toolbar> | ||
| </app-header> | ||
| <div id="columns"> | ||
| <div class="column"> | ||
| ${this._card} | ||
| </div> | ||
| </div> | ||
| </ha-app-layout> | ||
| `; | ||
| } | ||
|
|
||
| private _showVoiceCommandDialog(): void { | ||
| showVoiceCommandDialog(this); | ||
| } | ||
|
|
||
| static get styles(): CSSResultArray { | ||
| return [ | ||
| haStyle, | ||
| css` | ||
| :host { | ||
| --mdc-theme-primary: var(--app-header-text-color); | ||
| display: block; | ||
| height: 100%; | ||
| } | ||
| :host([narrow]) app-toolbar mwc-button { | ||
| width: 65px; | ||
| } | ||
| .heading { | ||
| overflow: hidden; | ||
| white-space: nowrap; | ||
| margin-top: 4px; | ||
| } | ||
| #columns { | ||
| display: flex; | ||
| flex-direction: row; | ||
| justify-content: center; | ||
| margin-left: 4px; | ||
| margin-right: 4px; | ||
| } | ||
| .column { | ||
| flex: 1 0 0; | ||
| max-width: 500px; | ||
| min-width: 0; | ||
| } | ||
| `, | ||
| ]; | ||
| } | ||
| } | ||
|
|
||
| declare global { | ||
| interface HTMLElementTagNameMap { | ||
| "ha-panel-shopping-list": PanelShoppingList; | ||
| } | ||
| } | ||
Oops, something went wrong.
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.