mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-11 20:10:24 +00:00
Convert ha-menu-button to TS (#2825)
* Convert ha-menu-button to TS * Address comments * Fix icon searcher
This commit is contained in:
44
src/components/ha-menu-button.ts
Normal file
44
src/components/ha-menu-button.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import "@polymer/paper-icon-button/paper-icon-button";
|
||||
import {
|
||||
property,
|
||||
TemplateResult,
|
||||
LitElement,
|
||||
html,
|
||||
customElement,
|
||||
} from "lit-element";
|
||||
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
|
||||
@customElement("ha-menu-button")
|
||||
class HaMenuButton extends LitElement {
|
||||
@property({ type: Boolean })
|
||||
public showMenu = false;
|
||||
|
||||
@property({ type: Boolean })
|
||||
public hassio = false;
|
||||
|
||||
protected render(): TemplateResult | void {
|
||||
return html`
|
||||
<paper-icon-button
|
||||
.icon=${this.hassio ? "hassio:menu" : "hass:menu"}
|
||||
@click=${this._toggleMenu}
|
||||
></paper-icon-button>
|
||||
`;
|
||||
}
|
||||
|
||||
// We are not going to use ShadowDOM as we're rendering a single element
|
||||
// without any CSS used.
|
||||
protected createRenderRoot(): Element | ShadowRoot {
|
||||
return this;
|
||||
}
|
||||
|
||||
private _toggleMenu(): void {
|
||||
fireEvent(this, this.showMenu ? "hass-close-menu" : "hass-open-menu");
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
"ha-menu-button": HaMenuButton;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user