add toggleable icons for the clipboard component
This commit is contained in:
@@ -47,7 +47,3 @@ window.customElements.define('template-builder', class extends HTMLElement {
|
||||
this.appElem?.remove()
|
||||
}
|
||||
})
|
||||
|
||||
document.addEventListener('clipboard-copy', function (event) {
|
||||
console.log('Copied to clipboard') // TODO: Add a toast message
|
||||
})
|
||||
|
||||
@@ -99,9 +99,16 @@ async function copy (button) {
|
||||
button.dispatchEvent(new CustomEvent('clipboard-copy', { bubbles: true }))
|
||||
}
|
||||
|
||||
function toggleActiveIcon () {
|
||||
if (button.classList.contains('swap')) {
|
||||
button.classList.toggle('swap-active')
|
||||
}
|
||||
}
|
||||
|
||||
if (text) {
|
||||
await copyText(text)
|
||||
trigger()
|
||||
toggleActiveIcon()
|
||||
} else if (id) {
|
||||
const root = 'getRootNode' in Element.prototype ? button.getRootNode() : button.ownerDocument
|
||||
|
||||
@@ -112,6 +119,7 @@ async function copy (button) {
|
||||
if (node) {
|
||||
await copyTarget(node)
|
||||
trigger()
|
||||
toggleActiveIcon()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user