1 changed files with 0 additions and 42 deletions
@ -1,42 +0,0 @@ |
|||
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() |
|||
}) |
|||
} |
|||
} |
|||
Loading…
Reference in new issue