mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-18 23:06:40 +00:00
Add separator option to overflow icon menu (#13627)
This commit is contained in:
parent
37c2a3636e
commit
980156d23a
@ -19,6 +19,7 @@ export interface IconOverflowMenuItem {
|
||||
tooltip?: string;
|
||||
action: () => any;
|
||||
warning?: boolean;
|
||||
divider?: boolean;
|
||||
}
|
||||
|
||||
@customElement("ha-icon-overflow-menu")
|
||||
@ -46,23 +47,23 @@ export class HaIconOverflowMenu extends LitElement {
|
||||
slot="trigger"
|
||||
></ha-icon-button>
|
||||
|
||||
${this.items.map(
|
||||
(item) => html`
|
||||
<mwc-list-item
|
||||
graphic="icon"
|
||||
?disabled=${item.disabled}
|
||||
@click=${item.action}
|
||||
class=${classMap({ warning: Boolean(item.warning) })}
|
||||
>
|
||||
<div slot="graphic">
|
||||
<ha-svg-icon
|
||||
class=${classMap({ warning: Boolean(item.warning) })}
|
||||
.path=${item.path}
|
||||
></ha-svg-icon>
|
||||
</div>
|
||||
${item.label}
|
||||
</mwc-list-item>
|
||||
`
|
||||
${this.items.map((item) =>
|
||||
item.divider
|
||||
? html`<li divider role="separator"></li>`
|
||||
: html`<mwc-list-item
|
||||
graphic="icon"
|
||||
?disabled=${item.disabled}
|
||||
@click=${item.action}
|
||||
class=${classMap({ warning: Boolean(item.warning) })}
|
||||
>
|
||||
<div slot="graphic">
|
||||
<ha-svg-icon
|
||||
class=${classMap({ warning: Boolean(item.warning) })}
|
||||
.path=${item.path}
|
||||
></ha-svg-icon>
|
||||
</div>
|
||||
${item.label}
|
||||
</mwc-list-item> `
|
||||
)}
|
||||
</ha-button-menu>`
|
||||
: html`
|
||||
@ -70,6 +71,8 @@ export class HaIconOverflowMenu extends LitElement {
|
||||
${this.items.map((item) =>
|
||||
item.narrowOnly
|
||||
? ""
|
||||
: item.divider
|
||||
? html`<div role="separator"></div>`
|
||||
: html`<div>
|
||||
${item.tooltip
|
||||
? html`<paper-tooltip animation-delay="0" position="left">
|
||||
@ -114,6 +117,13 @@ export class HaIconOverflowMenu extends LitElement {
|
||||
display: flex;
|
||||
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;
|
||||
}
|
||||
`,
|
||||
];
|
||||
}
|
||||
|
@ -212,6 +212,9 @@ class HaAutomationPicker extends LitElement {
|
||||
),
|
||||
action: () => this._showTrace(automation),
|
||||
},
|
||||
{
|
||||
divider: true,
|
||||
},
|
||||
{
|
||||
path: mdiContentDuplicate,
|
||||
label: this.hass.localize(
|
||||
|
@ -157,6 +157,9 @@ class HaSceneDashboard extends LitElement {
|
||||
),
|
||||
action: () => this._activateScene(scene),
|
||||
},
|
||||
{
|
||||
divider: true,
|
||||
},
|
||||
{
|
||||
path: mdiContentDuplicate,
|
||||
label: this.hass.localize(
|
||||
|
@ -155,6 +155,9 @@ class HaScriptPicker extends LitElement {
|
||||
),
|
||||
action: () => this._showTrace(script),
|
||||
},
|
||||
{
|
||||
divider: true,
|
||||
},
|
||||
{
|
||||
path: mdiContentDuplicate,
|
||||
label: this.hass.localize(
|
||||
|
Loading…
x
Reference in New Issue
Block a user