Add basic list menu elements and fix alwaysToggle to only trigger if the popup is open.
This commit is contained in:
61
tp-popup-menu-item.js
Normal file
61
tp-popup-menu-item.js
Normal file
@ -0,0 +1,61 @@
|
||||
/**
|
||||
@license
|
||||
Copyright (c) 2024 trading_peter
|
||||
This program is available under Apache License Version 2.0
|
||||
*/
|
||||
|
||||
import '@tp/tp-icon/tp-icon.js';
|
||||
import { LitElement, html, css } from 'lit';
|
||||
|
||||
class TpPopupMenuItem extends LitElement {
|
||||
static get styles() {
|
||||
return [
|
||||
css`
|
||||
:host {
|
||||
display: block;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
:host([disabled]) {
|
||||
cursor: default;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.wrap {
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr;
|
||||
grid-column-gap: 10px;
|
||||
align-items: center;
|
||||
padding: 6px 12px;
|
||||
color: var(--tp-popup-menu-item-color, #000);
|
||||
background: var(--tp-popup-menu-item-bg, transparent);
|
||||
}
|
||||
`
|
||||
];
|
||||
}
|
||||
|
||||
render() {
|
||||
const { icon } = this;
|
||||
|
||||
return html`
|
||||
<div class="wrap" ?noicon=${!icon}>
|
||||
${icon ? html`
|
||||
<tp-icon .icon=${icon}></tp-icon>
|
||||
` : null}
|
||||
<div class="label">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
static get properties() {
|
||||
return {
|
||||
icon: { type: Object },
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
window.customElements.define('tp-popup-menu-item', TpPopupMenuItem);
|
Reference in New Issue
Block a user