fix: btn list

This commit is contained in:
Xmader 2020-12-01 12:43:48 -05:00
parent b6837ee8e0
commit 2a29e378f2
No known key found for this signature in database
GPG Key ID: A20B97FB9EB730E4
1 changed files with 14 additions and 13 deletions

View File

@ -93,28 +93,29 @@ export class BtnList {
const btnParent = document.querySelector('div') as HTMLDivElement
const shadow = attachShadow(btnParent)
try {
const anchorDiv = this.getBtnParent()
const { width, top, left } = anchorDiv.getBoundingClientRect()
btnParent.style.width = `${width}px`
btnParent.style.top = `${top}px`
btnParent.style.left = `${left}px`
} catch (err) {
console.error(err)
}
// style the shadow DOM
const style = document.createElement('style')
style.innerText = btnListCss
shadow.append(style)
// hide buttons using the shadow DOM
const newParent = btnParent.cloneNode(false) as HTMLDivElement
newParent.append(...this.list.map(e => cloneBtn(e)))
shadow.append(newParent)
const slot = document.createElement('slot')
shadow.append(slot)
const newParent = document.createElement('div')
newParent.append(...this.list.map(e => cloneBtn(e)))
shadow.append(newParent)
try {
const anchorDiv = this.getBtnParent()
const { width, top, left } = anchorDiv.getBoundingClientRect()
newParent.style.width = `${width}px`
newParent.style.top = `${top}px`
newParent.style.left = `${left}px`
} catch (err) {
console.error(err)
}
return btnParent
}