get it working

pages^2
bat 3 years ago
parent e99214ffdc
commit d8492c1a88

@ -1,22 +1,27 @@
export class ButtonGroup extends HTMLElement { export class ButtonGroup extends HTMLElement {
constructor() { constructor() {
super() super()
this.attachShadow({open: true}) this.attachShadow({mode: 'open'})
} }
connectedCallback() { connectedCallback() {
const style = document.createElement('style') const style = document.createElement('style')
style.value = ` style.textContent = `
:host { :host {
display: flex; display: flex;
direction: row-reverse; flex-direction: row-reverse;
gap: 5px; gap: 5px;
} }
button { button {
font-size: 16px;
font-family: sans-serif; font-family: sans-serif;
font-weight: normal; font-weight: normal;
background: #111; background: #111;
color: #eee; color: #eee;
margin: 0;
border: none;
padding: 5px 10px;
border-radius: 3px;
} }
` `
this.shadowRoot.appendChild(style) this.shadowRoot.appendChild(style)
@ -26,7 +31,7 @@ export class ButtonGroup extends HTMLElement {
const el = document.createElement('button') const el = document.createElement('button')
el.innerText = text el.innerText = text
el.classList.add(cls) el.classList.add(cls)
el.addEventListener('click', () => handler) el.addEventListener('click', handler)
this.shadowRoot.appendChild(el) this.shadowRoot.appendChild(el)
return el return el
} }

Loading…
Cancel
Save