15 lines
379 B
JavaScript
15 lines
379 B
JavaScript
export function toggleSwitch(el, force) {
|
|
if (!el)
|
|
return;
|
|
const next = force === undefined ? !el.classList.contains('on') : force;
|
|
el.classList.toggle('on', next);
|
|
}
|
|
export function getSwitch(el) {
|
|
return el?.classList.contains('on') ?? false;
|
|
}
|
|
export function setSwitch(el, value) {
|
|
if (!el)
|
|
return;
|
|
el.classList.toggle('on', value);
|
|
}
|