diff --git a/src/components/ha-menu-item.ts b/src/components/ha-menu-item.ts new file mode 100644 index 000000000000..e96e867f6f83 --- /dev/null +++ b/src/components/ha-menu-item.ts @@ -0,0 +1,37 @@ +import { customElement } from "lit/decorators"; +import "element-internals-polyfill"; +import { CSSResult, css } from "lit"; +import { MdMenuItem } from "@material/web/menu/menu-item"; + +@customElement("ha-menu-item") +export class HaMenuItem extends MdMenuItem { + static override styles: CSSResult[] = [ + ...MdMenuItem.styles, + css` + :host { + --ha-icon-display: block; + --md-sys-color-primary: var(--primary-text-color); + --md-sys-color-on-primary: var(--primary-text-color); + --md-sys-color-secondary: var(--secondary-text-color); + --md-sys-color-surface: var(--card-background-color); + --md-sys-color-on-surface: var(--primary-text-color); + --md-sys-color-on-surface-variant: var(--secondary-text-color); + --md-sys-color-secondary-container: rgba( + var(--rgb-primary-color), + 0.15 + ); + --md-sys-color-on-secondary-container: var(--text-primary-color); + --mdc-icon-size: 16px; + + --md-sys-color-on-primary-container: var(--primary-text-color); + --md-sys-color-on-secondary-container: var(--primary-text-color); + } + `, + ]; +} + +declare global { + interface HTMLElementTagNameMap { + "ha-menu-item": HaMenuItem; + } +} diff --git a/src/components/ha-menu.ts b/src/components/ha-menu.ts new file mode 100644 index 000000000000..d1a414698427 --- /dev/null +++ b/src/components/ha-menu.ts @@ -0,0 +1,22 @@ +import { customElement } from "lit/decorators"; +import "element-internals-polyfill"; +import { CSSResult, css } from "lit"; +import { MdMenu } from "@material/web/menu/menu"; + +@customElement("ha-menu") +export class HaMenu extends MdMenu { + static override styles: CSSResult[] = [ + ...MdMenu.styles, + css` + :host { + --md-sys-color-surface-container: var(--card-background-color); + } + `, + ]; +} + +declare global { + interface HTMLElementTagNameMap { + "ha-menu": HaMenu; + } +} diff --git a/src/layouts/hass-tabs-subpage-data-table.ts b/src/layouts/hass-tabs-subpage-data-table.ts index b4d4ddc58f26..293bcfd633c4 100644 --- a/src/layouts/hass-tabs-subpage-data-table.ts +++ b/src/layouts/hass-tabs-subpage-data-table.ts @@ -3,7 +3,6 @@ import "@lrnwebcomponents/simple-tooltip/simple-tooltip"; import "@material/mwc-button/mwc-button"; import "@material/web/menu/menu"; import type { MdMenu } from "@material/web/menu/menu"; -import "@material/web/menu/menu-item"; import { mdiArrowDown, mdiArrowUp, @@ -36,6 +35,8 @@ import type { } from "../components/data-table/ha-data-table"; import "../components/ha-dialog"; import "../components/search-input-outlined"; +import "../components/ha-menu"; +import "../components/ha-menu-item"; import type { HomeAssistant, Route } from "../types"; import "./hass-tabs-subpage"; import type { PageNavigation } from "./hass-tabs-subpage"; @@ -409,37 +410,37 @@ export class HaTabsSubpageDataTable extends LitElement { `}