Add separator option to overflow icon menu (#13627)

This commit is contained in:
Philip Allgaier 2022-09-07 15:56:18 +02:00 committed by GitHub
parent 37c2a3636e
commit 980156d23a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 17 deletions

View File

@ -19,6 +19,7 @@ export interface IconOverflowMenuItem {
tooltip?: string; tooltip?: string;
action: () => any; action: () => any;
warning?: boolean; warning?: boolean;
divider?: boolean;
} }
@customElement("ha-icon-overflow-menu") @customElement("ha-icon-overflow-menu")
@ -46,9 +47,10 @@ export class HaIconOverflowMenu extends LitElement {
slot="trigger" slot="trigger"
></ha-icon-button> ></ha-icon-button>
${this.items.map( ${this.items.map((item) =>
(item) => html` item.divider
<mwc-list-item ? html`<li divider role="separator"></li>`
: html`<mwc-list-item
graphic="icon" graphic="icon"
?disabled=${item.disabled} ?disabled=${item.disabled}
@click=${item.action} @click=${item.action}
@ -61,8 +63,7 @@ export class HaIconOverflowMenu extends LitElement {
></ha-svg-icon> ></ha-svg-icon>
</div> </div>
${item.label} ${item.label}
</mwc-list-item> </mwc-list-item> `
`
)} )}
</ha-button-menu>` </ha-button-menu>`
: html` : html`
@ -70,6 +71,8 @@ export class HaIconOverflowMenu extends LitElement {
${this.items.map((item) => ${this.items.map((item) =>
item.narrowOnly item.narrowOnly
? "" ? ""
: item.divider
? html`<div role="separator"></div>`
: html`<div> : html`<div>
${item.tooltip ${item.tooltip
? html`<paper-tooltip animation-delay="0" position="left"> ? html`<paper-tooltip animation-delay="0" position="left">
@ -114,6 +117,13 @@ export class HaIconOverflowMenu extends LitElement {
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
} }
li[role="separator"] {
border-bottom-color: var(--divider-color);
}
div[role="separator"] {
border-right: 1px solid var(--divider-color);
width: 1px;
}
`, `,
]; ];
} }

View File

@ -212,6 +212,9 @@ class HaAutomationPicker extends LitElement {
), ),
action: () => this._showTrace(automation), action: () => this._showTrace(automation),
}, },
{
divider: true,
},
{ {
path: mdiContentDuplicate, path: mdiContentDuplicate,
label: this.hass.localize( label: this.hass.localize(

View File

@ -157,6 +157,9 @@ class HaSceneDashboard extends LitElement {
), ),
action: () => this._activateScene(scene), action: () => this._activateScene(scene),
}, },
{
divider: true,
},
{ {
path: mdiContentDuplicate, path: mdiContentDuplicate,
label: this.hass.localize( label: this.hass.localize(

View File

@ -155,6 +155,9 @@ class HaScriptPicker extends LitElement {
), ),
action: () => this._showTrace(script), action: () => this._showTrace(script),
}, },
{
divider: true,
},
{ {
path: mdiContentDuplicate, path: mdiContentDuplicate,
label: this.hass.localize( label: this.hass.localize(