mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-30 20:56:36 +00:00
parent
c574556deb
commit
6ca944b7ef
@ -9,6 +9,7 @@ import {
|
|||||||
PropertyValues,
|
PropertyValues,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import { repeat } from "lit-html/directives/repeat";
|
import { repeat } from "lit-html/directives/repeat";
|
||||||
|
import { classMap } from "lit-html/directives/class-map";
|
||||||
import { PaperInputElement } from "@polymer/paper-input/paper-input";
|
import { PaperInputElement } from "@polymer/paper-input/paper-input";
|
||||||
import "@polymer/paper-checkbox/paper-checkbox";
|
import "@polymer/paper-checkbox/paper-checkbox";
|
||||||
|
|
||||||
@ -26,8 +27,6 @@ import {
|
|||||||
} from "../../../data/shopping-list";
|
} from "../../../data/shopping-list";
|
||||||
import { ShoppingListCardConfig, SensorCardConfig } from "./types";
|
import { ShoppingListCardConfig, SensorCardConfig } from "./types";
|
||||||
import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_element";
|
import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_element";
|
||||||
import { actionHandler } from "../common/directives/action-handler-directive";
|
|
||||||
import { classMap } from "lit-html/directives/class-map";
|
|
||||||
|
|
||||||
@customElement("hui-shopping-list-card")
|
@customElement("hui-shopping-list-card")
|
||||||
class HuiShoppingListCard extends LitElement implements LovelaceCard {
|
class HuiShoppingListCard extends LitElement implements LovelaceCard {
|
||||||
@ -118,46 +117,40 @@ class HuiShoppingListCard extends LitElement implements LovelaceCard {
|
|||||||
<div class="addRow">
|
<div class="addRow">
|
||||||
<ha-icon
|
<ha-icon
|
||||||
class="addButton"
|
class="addButton"
|
||||||
@click="${this._addItem}"
|
|
||||||
icon="hass:plus"
|
icon="hass:plus"
|
||||||
.title="${this.hass!.localize(
|
.title=${this.hass!.localize(
|
||||||
"ui.panel.lovelace.cards.shopping-list.add_item"
|
"ui.panel.lovelace.cards.shopping-list.add_item"
|
||||||
)}"
|
)}
|
||||||
|
@click=${this._addItem}
|
||||||
>
|
>
|
||||||
</ha-icon>
|
</ha-icon>
|
||||||
<paper-item-body>
|
<paper-input
|
||||||
<paper-input
|
no-label-float
|
||||||
no-label-float
|
class="addBox"
|
||||||
class="addBox"
|
placeholder=${this.hass!.localize(
|
||||||
placeholder="${this.hass!.localize(
|
"ui.panel.lovelace.cards.shopping-list.add_item"
|
||||||
"ui.panel.lovelace.cards.shopping-list.add_item"
|
)}
|
||||||
)}"
|
@keydown=${this._addKeyPress}
|
||||||
@keydown="${this._addKeyPress}"
|
></paper-input>
|
||||||
></paper-input>
|
|
||||||
</paper-item-body>
|
|
||||||
</div>
|
</div>
|
||||||
${repeat(
|
${repeat(
|
||||||
this._uncheckedItems!,
|
this._uncheckedItems!,
|
||||||
(item) => item.id,
|
(item) => item.id,
|
||||||
(item, index) =>
|
(item) =>
|
||||||
html`
|
html`
|
||||||
<div class="editRow">
|
<div class="editRow">
|
||||||
<paper-checkbox
|
<paper-checkbox
|
||||||
slot="item-icon"
|
|
||||||
id="${index}"
|
|
||||||
?checked="${item.complete}"
|
|
||||||
.itemId="${item.id}"
|
|
||||||
@click="${this._completeItem}"
|
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
|
?checked=${item.complete}
|
||||||
|
.itemId=${item.id}
|
||||||
|
@click=${this._completeItem}
|
||||||
></paper-checkbox>
|
></paper-checkbox>
|
||||||
<paper-item-body>
|
<paper-input
|
||||||
<paper-input
|
no-label-float
|
||||||
no-label-float
|
.value=${item.name}
|
||||||
.value="${item.name}"
|
.itemId=${item.id}
|
||||||
.itemId="${item.id}"
|
@change=${this._saveEdit}
|
||||||
@change="${this._saveEdit}"
|
></paper-input>
|
||||||
></paper-input>
|
|
||||||
</paper-item-body>
|
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
)}
|
)}
|
||||||
@ -165,45 +158,40 @@ class HuiShoppingListCard extends LitElement implements LovelaceCard {
|
|||||||
? html`
|
? html`
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
<div class="checked">
|
<div class="checked">
|
||||||
<span class="label">
|
<span>
|
||||||
${this.hass!.localize(
|
${this.hass!.localize(
|
||||||
"ui.panel.lovelace.cards.shopping-list.checked_items"
|
"ui.panel.lovelace.cards.shopping-list.checked_items"
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
<ha-icon
|
<ha-icon
|
||||||
class="clearall"
|
class="clearall"
|
||||||
@action=${this._clearItems}
|
|
||||||
.actionHandler=${actionHandler()}
|
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
icon="hass:notification-clear-all"
|
icon="hass:notification-clear-all"
|
||||||
.title="${this.hass!.localize(
|
.title=${this.hass!.localize(
|
||||||
"ui.panel.lovelace.cards.shopping-list.clear_items"
|
"ui.panel.lovelace.cards.shopping-list.clear_items"
|
||||||
)}"
|
)}
|
||||||
|
@click=${this._clearItems}
|
||||||
>
|
>
|
||||||
</ha-icon>
|
</ha-icon>
|
||||||
</div>
|
</div>
|
||||||
${repeat(
|
${repeat(
|
||||||
this._checkedItems!,
|
this._checkedItems!,
|
||||||
(item) => item.id,
|
(item) => item.id,
|
||||||
(item, index) =>
|
(item) =>
|
||||||
html`
|
html`
|
||||||
<div class="editRow">
|
<div class="editRow">
|
||||||
<paper-checkbox
|
<paper-checkbox
|
||||||
slot="item-icon"
|
|
||||||
id="${index}"
|
|
||||||
?checked="${item.complete}"
|
|
||||||
.itemId="${item.id}"
|
|
||||||
@click="${this._completeItem}"
|
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
|
?checked=${item.complete}
|
||||||
|
.itemId=${item.id}
|
||||||
|
@click=${this._completeItem}
|
||||||
></paper-checkbox>
|
></paper-checkbox>
|
||||||
<paper-item-body>
|
<paper-input
|
||||||
<paper-input
|
no-label-float
|
||||||
no-label-float
|
.value=${item.name}
|
||||||
.value="${item.name}"
|
.itemId=${item.id}
|
||||||
.itemId="${item.id}"
|
@change=${this._saveEdit}
|
||||||
@change="${this._saveEdit}"
|
></paper-input>
|
||||||
></paper-input>
|
|
||||||
</paper-item-body>
|
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
)}
|
)}
|
||||||
@ -216,8 +204,7 @@ class HuiShoppingListCard extends LitElement implements LovelaceCard {
|
|||||||
static get styles(): CSSResult {
|
static get styles(): CSSResult {
|
||||||
return css`
|
return css`
|
||||||
ha-card {
|
ha-card {
|
||||||
padding-bottom: 16px;
|
padding: 16px;
|
||||||
padding-top: 16px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.has-header {
|
.has-header {
|
||||||
@ -225,63 +212,51 @@ class HuiShoppingListCard extends LitElement implements LovelaceCard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.editRow,
|
.editRow,
|
||||||
.addRow {
|
.addRow,
|
||||||
|
.checked {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.addRow ha-icon {
|
||||||
|
color: var(--secondary-text-color);
|
||||||
|
--iron-icon-width: 26px;
|
||||||
|
--iron-icon-height: 26px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.addButton {
|
.addButton {
|
||||||
padding: 9px 15px 11px 15px;
|
padding-right: 16px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
paper-item-body {
|
|
||||||
width: 75%;
|
|
||||||
}
|
|
||||||
|
|
||||||
paper-checkbox {
|
paper-checkbox {
|
||||||
padding: 11px 11px 11px 18px;
|
padding-left: 4px;
|
||||||
|
padding-right: 20px;
|
||||||
|
--paper-checkbox-label-spacing: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
paper-input {
|
paper-input {
|
||||||
--paper-input-container-underline: {
|
flex-grow: 1;
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
--paper-input-container-underline-focus: {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
--paper-input-container-underline-disabled: {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
position: relative;
|
|
||||||
top: 1px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.checked {
|
.checked {
|
||||||
margin-left: 17px;
|
margin: 12px 0;
|
||||||
margin-bottom: 11px;
|
justify-content: space-between;
|
||||||
margin-top: 11px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.label {
|
.checked span {
|
||||||
color: var(--primary-color);
|
color: var(--primary-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.divider {
|
.divider {
|
||||||
height: 1px;
|
height: 1px;
|
||||||
background-color: var(--divider-color);
|
background-color: var(--divider-color);
|
||||||
margin: 10px;
|
margin: 10px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.clearall {
|
.clearall {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
margin-bottom: 3px;
|
|
||||||
float: right;
|
|
||||||
padding-right: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.addRow > ha-icon {
|
|
||||||
color: var(--secondary-text-color);
|
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user