mirror of https://github.com/docusealco/docuseal
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
592 B
20 lines
592 B
export default class extends HTMLElement {
|
|
connectedCallback () {
|
|
const button = this.querySelector('a, button, label')
|
|
|
|
const target = this.dataset.targetId ? document.getElementById(this.dataset.targetId) : button
|
|
|
|
button.addEventListener('click', () => {
|
|
this.dataset.classes.split(' ').forEach((cls) => {
|
|
if (this.dataset.action === 'remove') {
|
|
target.classList.remove(cls)
|
|
} else if (this.dataset.action === 'add') {
|
|
target.classList.add(cls)
|
|
} else {
|
|
target.classList.toggle(cls)
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|