Skip to content
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

Consolidate all icon button logic into <ha-icon-button> + ensure tooltip #9230

Merged
merged 33 commits into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
6c71a8c
Consolidate all icon logic into `<ha-icon-button` + ensure tooltip
spacegaier May 22, 2021
cc48c55
Merge branch 'dev' of https://github.com/home-assistant/frontend into…
spacegaier Jun 12, 2021
81e2efa
More icon conversions
spacegaier Jun 12, 2021
d7c16df
More icon conversions
spacegaier Jun 12, 2021
10b51e6
More icon conversions
spacegaier Jun 12, 2021
80c8162
More cleanups and mwc-icon-button replacements
spacegaier Oct 4, 2021
03c2f9d
Fix marked checkbox outlined icon
spacegaier Oct 4, 2021
613eb6c
Organize
spacegaier Oct 4, 2021
45bec38
Merge branch 'dev' of https://github.com/home-assistant/frontend into…
spacegaier Oct 4, 2021
d488cc7
Remove accidental file
spacegaier Oct 4, 2021
d51ebc1
Lint fix
spacegaier Oct 4, 2021
8685f6b
Linter fixes
spacegaier Oct 4, 2021
1290069
Prettier
spacegaier Oct 4, 2021
d08cadf
"hass:" icon replacements + various fixes
spacegaier Oct 4, 2021
5fa3c05
Linter fix
spacegaier Oct 4, 2021
e818d54
More mwc-icon-button replacements
spacegaier Oct 5, 2021
641da21
Merge branch 'dev' of https://github.com/home-assistant/frontend into…
spacegaier Oct 5, 2021
409132a
Typo fix in energy period selector
spacegaier Oct 5, 2021
e151d5d
ARIA fixes
spacegaier Oct 6, 2021
08a30ea
Merge branch 'dev' into ha-icon-button
spacegaier Oct 6, 2021
14dddd4
Changes from review
spacegaier Oct 7, 2021
91ba75b
Merge branch 'dev' into ha-icon-button
spacegaier Oct 7, 2021
4a6b2ad
Use correct ARIA property
spacegaier Oct 7, 2021
55cb582
Merge branch 'dev' into ha-icon-button
spacegaier Oct 8, 2021
ee08a88
Add label to icon button in zone edit
spacegaier Oct 8, 2021
6283ebe
Merge branch 'ha-icon-button' of https://github.com/spacegaier/fronte…
spacegaier Oct 8, 2021
9cbb40f
Prettier
spacegaier Oct 8, 2021
3f52c00
Merge branch 'dev' of https://github.com/home-assistant/frontend into…
spacegaier Oct 8, 2021
08637d6
Merge branch 'dev' of https://github.com/home-assistant/frontend into…
spacegaier Oct 14, 2021
dc2bae9
Cleanup imports
spacegaier Oct 14, 2021
7fd9a17
Use slot for non SVG icon
spacegaier Oct 14, 2021
8c32082
Merge branch 'dev' into ha-icon-button
spacegaier Oct 14, 2021
b0d6da1
Make slot unnamed + add missing usages
spacegaier Oct 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions hassio/src/addon-store/hassio-addon-store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "@material/mwc-icon-button/mwc-icon-button";
import { ActionDetail } from "@material/mwc-list/mwc-list-foundation";
import "@material/mwc-list/mwc-list-item";
import { mdiDotsVertical } from "@mdi/js";
Expand Down Expand Up @@ -92,9 +91,11 @@ class HassioAddonStore extends LitElement {
slot="toolbar-icon"
@action=${this._handleAction}
>
<mwc-icon-button slot="trigger" alt="menu">
<ha-svg-icon .path=${mdiDotsVertical}></ha-svg-icon>
</mwc-icon-button>
<ha-icon-button
spacegaier marked this conversation as resolved.
Show resolved Hide resolved
.label=${this.supervisor.localize("common.menu")}
.path=${mdiDotsVertical}
slot="trigger"
></ha-icon-button>
<mwc-list-item>
${this.supervisor.localize("store.repositories")}
</mwc-list-item>
Expand All @@ -113,6 +114,7 @@ class HassioAddonStore extends LitElement {
: html`
<div class="search">
<search-input
.hass=${this.hass}
no-label-float
no-underline
.filter=${this._filter}
Expand Down
8 changes: 5 additions & 3 deletions hassio/src/addon-view/config/hassio-addon-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ class HassioAddonConfig extends LitElement {
</h2>
<div class="card-menu">
<ha-button-menu corner="BOTTOM_START" @action=${this._handleAction}>
<mwc-icon-button slot="trigger">
<ha-svg-icon .path=${mdiDotsVertical}></ha-svg-icon>
</mwc-icon-button>
<ha-icon-button
spacegaier marked this conversation as resolved.
Show resolved Hide resolved
.label=${this.hass.localize("common.menu")}
.path=${mdiDotsVertical}
slot="trigger"
></ha-icon-button>
<mwc-list-item .disabled=${!this._canShowSchema}>
${this._yamlMode
? this.supervisor.localize(
Expand Down
4 changes: 2 additions & 2 deletions hassio/src/addon-view/info/hassio-addon-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,9 @@ class HassioAddonInfo extends LitElement {
<ha-label-badge
@click=${this._showMoreInfo}
id="docker_api"
.label=".${this.supervisor.localize(
.label=${this.supervisor.localize(
"addon.dashboard.capability.label.docker"
)}"
)}
description=""
>
<ha-svg-icon .path=${mdiDocker}></ha-svg-icon>
Expand Down
20 changes: 12 additions & 8 deletions hassio/src/backups/hassio-backups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,11 @@ export class HassioBackups extends LitElement {
slot="toolbar-icon"
@action=${this._handleAction}
>
<mwc-icon-button slot="trigger" alt="menu">
<ha-svg-icon .path=${mdiDotsVertical}></ha-svg-icon>
</mwc-icon-button>
<ha-icon-button
spacegaier marked this conversation as resolved.
Show resolved Hide resolved
.label=${this.hass.localize("common.menu")}
.path=${mdiDotsVertical}
slot="trigger"
></ha-icon-button>
<mwc-list-item>
${this.supervisor?.localize("common.reload")}
</mwc-list-item>
Expand Down Expand Up @@ -216,13 +218,15 @@ export class HassioBackups extends LitElement {
</mwc-button>
`
: html`
<mwc-icon-button
<ha-icon-button
.label=${this.supervisor.localize(
"snapshot.delete_selected"
)}
.path=${mdiDelete}
id="delete-btn"
class="warning"
@click=${this._deleteSelected}
>
<ha-svg-icon .path=${mdiDelete}></ha-svg-icon>
</mwc-icon-button>
></ha-icon-button>
<paper-tooltip animation-delay="0" for="delete-btn">
${this.supervisor.localize("backup.delete_selected")}
</paper-tooltip>
Expand Down Expand Up @@ -368,7 +372,7 @@ export class HassioBackups extends LitElement {
margin-right: -12px;
}
.header-btns > mwc-button,
.header-btns > mwc-icon-button {
.header-btns > ha-icon-button {
margin: 8px;
}
`,
Expand Down
2 changes: 1 addition & 1 deletion hassio/src/components/hassio-upload-backup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "@material/mwc-icon-button/mwc-icon-button";
import { mdiFolderUpload } from "@mdi/js";
import "@polymer/paper-input/paper-input-container";
import { html, LitElement, TemplateResult } from "lit";
Expand Down Expand Up @@ -31,6 +30,7 @@ export class HassioUploadBackup extends LitElement {
public render(): TemplateResult {
return html`
<ha-file-upload
.hass=${this.hass}
.uploading=${this._uploading}
.icon=${mdiFolderUpload}
accept="application/x-tar"
Expand Down
9 changes: 6 additions & 3 deletions hassio/src/dialogs/backup/dialog-hassio-backup-upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,12 @@ export class DialogHassioBackupUpload
<div slot="heading">
<ha-header-bar>
<span slot="title"> Upload backup </span>
<mwc-icon-button slot="actionItems" dialogAction="cancel">
<ha-svg-icon .path=${mdiClose}></ha-svg-icon>
</mwc-icon-button>
<ha-icon-button
.label=${this.hass.localize("common.close")}
.path=${mdiClose}
slot="actionItems"
dialogAction="cancel"
></ha-icon-button>
</ha-header-bar>
</div>
<hassio-upload-backup
Expand Down
17 changes: 11 additions & 6 deletions hassio/src/dialogs/backup/dialog-hassio-backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,12 @@ class HassioBackupDialog
<div slot="heading">
<ha-header-bar>
<span slot="title">${this._backup.name}</span>
<mwc-icon-button slot="actionItems" dialogAction="cancel">
<ha-svg-icon .path=${mdiClose}></ha-svg-icon>
</mwc-icon-button>
<ha-icon-button
.label=${this.hass.localize("common.close")}
.path=${mdiClose}
slot="actionItems"
dialogAction="cancel"
></ha-icon-button>
</ha-header-bar>
</div>
${this._restoringBackup
Expand Down Expand Up @@ -110,9 +113,11 @@ class HassioBackupDialog
@action=${this._handleMenuAction}
@closed=${stopPropagation}
>
<mwc-icon-button slot="trigger" alt="menu">
<ha-svg-icon .path=${mdiDotsVertical}></ha-svg-icon>
</mwc-icon-button>
<ha-icon-button
.label=${this.hass.localize("common.menu")}
.path=${mdiDotsVertical}
slot="trigger"
></ha-icon-button>
<mwc-list-item>Download Backup</mwc-list-item>
<mwc-list-item class="error">Delete Backup</mwc-list-item>
</ha-button-menu>`
Expand Down
11 changes: 7 additions & 4 deletions hassio/src/dialogs/hardware/dialog-hassio-hardware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,13 @@ class HassioHardwareDialog extends LitElement {
<h2>
${this._dialogParams.supervisor.localize("dialog.hardware.title")}
</h2>
<mwc-icon-button dialogAction="close">
<ha-svg-icon .path=${mdiClose}></ha-svg-icon>
</mwc-icon-button>
<ha-icon-button
.label=${this.hass.localize("common.close")}
.path=${mdiClose}
dialogAction="close"
></ha-icon-button>
<search-input
.hass=${this.hass}
autofocus
no-label-float
.filter=${this._filter}
Expand Down Expand Up @@ -141,7 +144,7 @@ class HassioHardwareDialog extends LitElement {
haStyle,
haStyleDialog,
css`
mwc-icon-button {
ha-icon-button {
position: absolute;
right: 16px;
top: 10px;
Expand Down
10 changes: 6 additions & 4 deletions hassio/src/dialogs/network/dialog-hassio-network.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import "@material/mwc-button/mwc-button";
import "@material/mwc-icon-button";
import "@material/mwc-list/mwc-list";
import "@material/mwc-list/mwc-list-item";
import "@material/mwc-tab";
Expand Down Expand Up @@ -104,9 +103,12 @@ export class DialogHassioNetwork
<span slot="title">
${this.supervisor.localize("dialog.network.title")}
</span>
<mwc-icon-button slot="actionItems" dialogAction="cancel">
<ha-svg-icon .path=${mdiClose}></ha-svg-icon>
</mwc-icon-button>
<ha-icon-button
.label=${this.hass.localize("common.close")}
.path=${mdiClose}
slot="actionItems"
dialogAction="cancel"
></ha-icon-button>
</ha-header-bar>
${this._interfaces.length > 1
? html`<mwc-tab-bar
Expand Down
12 changes: 5 additions & 7 deletions hassio/src/dialogs/registries/dialog-hassio-registries.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import "@material/mwc-button/mwc-button";
import "@material/mwc-icon-button/mwc-icon-button";
import "@material/mwc-list/mwc-list-item";
import { mdiDelete } from "@mdi/js";
import { PaperInputElement } from "@polymer/paper-input/paper-input";
Expand Down Expand Up @@ -110,16 +109,15 @@ class HassioRegistriesDialog extends LitElement {
)}:
${entry.username}</span
>
<mwc-icon-button
<ha-icon-button
spacegaier marked this conversation as resolved.
Show resolved Hide resolved
.entry=${entry}
.title=${this.supervisor.localize(
.label=${this.supervisor.localize(
"dialog.registries.remove"
)}
.path=${mdiDelete}
slot="meta"
@click=${this._removeRegistry}
>
<ha-svg-icon .path=${mdiDelete}></ha-svg-icon>
</mwc-icon-button>
></ha-icon-button>
</mwc-list-item>
`
)
Expand Down Expand Up @@ -234,7 +232,7 @@ class HassioRegistriesDialog extends LitElement {
mwc-button {
margin-left: 8px;
}
mwc-icon-button {
ha-icon-button {
color: var(--error-color);
margin: -10px;
}
Expand Down
10 changes: 4 additions & 6 deletions hassio/src/dialogs/repositories/dialog-hassio-repositories.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import "@material/mwc-button/mwc-button";
import "@material/mwc-icon-button/mwc-icon-button";
import { mdiDelete } from "@mdi/js";
import "@polymer/paper-input/paper-input";
import type { PaperInputElement } from "@polymer/paper-input/paper-input";
Expand Down Expand Up @@ -90,15 +89,14 @@ class HassioRepositoriesDialog extends LitElement {
<div secondary>${repo.maintainer}</div>
<div secondary>${repo.url}</div>
</paper-item-body>
<mwc-icon-button
<ha-icon-button
.slug=${repo.slug}
.title=${this._dialogParams!.supervisor.localize(
.label=${this._dialogParams!.supervisor.localize(
"dialog.repositories.remove"
)}
.path=${mdiDelete}
@click=${this._removeRepository}
>
<ha-svg-icon .path=${mdiDelete}></ha-svg-icon>
</mwc-icon-button>
></ha-icon-button>
</paper-item>
`
)
Expand Down
11 changes: 5 additions & 6 deletions hassio/src/ingress-view/hassio-ingress-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,11 @@ class HassioIngressView extends LitElement {

return html`${this.narrow || this.hass.dockedSidebar === "always_hidden"
? html`<div class="header">
<mwc-icon-button
aria-label=${this.hass.localize("ui.sidebar.sidebar_toggle")}
<ha-icon-button
.label=${this.hass.localize("ui.sidebar.sidebar_toggle")}
.path=${mdiMenu}
@click=${this._toggleMenu}
>
<ha-svg-icon .path=${mdiMenu}></ha-svg-icon>
</mwc-icon-button>
></ha-icon-button>
<div class="main-title">${this._addon.name}</div>
</div>
${iframe}`
Expand Down Expand Up @@ -241,7 +240,7 @@ class HassioIngressView extends LitElement {
flex-grow: 1;
}

mwc-icon-button {
ha-icon-button {
pointer-events: auto;
}

Expand Down
8 changes: 5 additions & 3 deletions hassio/src/system/hassio-host-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,11 @@ class HassioHostInfo extends LitElement {
: ""}

<ha-button-menu corner="BOTTOM_START">
<mwc-icon-button slot="trigger">
<ha-svg-icon .path=${mdiDotsVertical}></ha-svg-icon>
</mwc-icon-button>
<ha-icon-button
.label=${this.hass.localize("common.menu")}
.path=${mdiDotsVertical}
slot="trigger"
></ha-icon-button>
<mwc-list-item
.action=${"hardware"}
@click=${this._handleMenuAction}
Expand Down
18 changes: 10 additions & 8 deletions src/common/search/search-input.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "@material/mwc-icon-button/mwc-icon-button";
import { mdiClose, mdiMagnify } from "@mdi/js";
import "@polymer/paper-input/paper-input";
import type { PaperInputElement } from "@polymer/paper-input/paper-input";
Expand All @@ -11,11 +10,15 @@ import {
TemplateResult,
} from "lit";
import { customElement, property, query } from "lit/decorators";
import "../../components/ha-icon-button";
import "../../components/ha-svg-icon";
import { HomeAssistant } from "../../types";
import { fireEvent } from "../dom/fire_event";

@customElement("search-input")
class SearchInput extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;

@property() public filter?: string;

@property({ type: Boolean, attribute: "no-label-float" })
Expand Down Expand Up @@ -50,13 +53,12 @@ class SearchInput extends LitElement {
</slot>
${this.filter &&
html`
<mwc-icon-button
<ha-icon-button
slot="suffix"
@click=${this._clearSearch}
title="Clear"
>
<ha-svg-icon .path=${mdiClose}></ha-svg-icon>
</mwc-icon-button>
.label=${this.hass.localize("ui.common.clear")}
.path=${mdiClose}
></ha-icon-button>
`}
</paper-input>
`;
Expand Down Expand Up @@ -90,10 +92,10 @@ class SearchInput extends LitElement {
static get styles(): CSSResultGroup {
return css`
ha-svg-icon,
mwc-icon-button {
ha-icon-button {
color: var(--primary-text-color);
}
mwc-icon-button {
ha-icon-button {
--mdc-icon-button-size: 24px;
}
ha-svg-icon.prefix {
Expand Down
4 changes: 4 additions & 0 deletions src/components/data-table/ha-data-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import "../ha-checkbox";
import type { HaCheckbox } from "../ha-checkbox";
import "../ha-icon";
import { filterData, sortData } from "./sort-filter";
import { HomeAssistant } from "../../types";

declare global {
// for fire event
Expand Down Expand Up @@ -92,6 +93,8 @@ export interface SortableColumnContainer {

@customElement("ha-data-table")
export class HaDataTable extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;

@property({ type: Object }) public columns: DataTableColumnContainer = {};

@property({ type: Array }) public data: DataTableRowData[] = [];
Expand Down Expand Up @@ -231,6 +234,7 @@ export class HaDataTable extends LitElement {
? html`
<div class="table-header">
<search-input
.hass=${this.hass}
@value-changed=${this._handleSearchChange}
.label=${this.searchLabel}
.noLabelFloat=${this.noLabelFloat}
Expand Down
Loading