You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
export class PageMenu extends HTMLElement {
|
|
|
|
|
constructor() {
|
|
|
|
|
super()
|
|
|
|
|
this.attachShadow({mode: 'open'})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
connectedCallback() {
|
|
|
|
|
const style = document.createElement('style')
|
|
|
|
|
style.textContent = `
|
|
|
|
|
:host {
|
|
|
|
|
background: #222;
|
|
|
|
|
color: #ddd;
|
|
|
|
|
padding: 3px;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: stretch;
|
|
|
|
|
min-width: 180px;
|
|
|
|
|
}
|
|
|
|
|
button {
|
|
|
|
|
background: #222;
|
|
|
|
|
font-size: 120%;
|
|
|
|
|
border: none;
|
|
|
|
|
color: inherit;
|
|
|
|
|
padding: 4px 10px;
|
|
|
|
|
text-align: left;
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
this.shadowRoot.append(style)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
add(text, handler) {
|
|
|
|
|
const btn = document.createElement('button')
|
|
|
|
|
btn.innerText = text
|
|
|
|
|
this.shadowRoot.appendChild(btn)
|
|
|
|
|
btn.addEventListener('click', () => {
|
|
|
|
|
this.dispatchEvent(new CustomEvent(
|
|
|
|
|
'close-menu', {bubbles: true}
|
|
|
|
|
))
|
|
|
|
|
handler()
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|