This commit is contained in:
14
public/ts/ui/switch.ts
Normal file
14
public/ts/ui/switch.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
export function toggleSwitch(el: HTMLElement | null, force?: boolean) {
|
||||
if (!el) return;
|
||||
const next = force === undefined ? !el.classList.contains('on') : force;
|
||||
el.classList.toggle('on', next);
|
||||
}
|
||||
|
||||
export function getSwitch(el: HTMLElement | null) {
|
||||
return el?.classList.contains('on') ?? false;
|
||||
}
|
||||
|
||||
export function setSwitch(el: HTMLElement | null, value: boolean) {
|
||||
if (!el) return;
|
||||
el.classList.toggle('on', value);
|
||||
}
|
||||
Reference in New Issue
Block a user