commit d88629cd709591c7b6c51a3d66efdc259236708f parent bf8ca89de9d42da997abf5fc3cf42a5a61489290 Author: triesap <137732411+triesap@users.noreply.github.com> Date: Sun, 6 Oct 2024 10:17:10 +0000 apps-lib: add view effect utils Diffstat:
| M | apps-lib/src/lib/utils/client.ts | | | 9 | +++++++++ |
1 file changed, 9 insertions(+), 0 deletions(-)
diff --git a/apps-lib/src/lib/utils/client.ts b/apps-lib/src/lib/utils/client.ts @@ -125,3 +125,11 @@ export const get_layout = (val: string | false): AppLayoutKey => { return `base`; }; }; + +export const view_effect = <T extends string>(view: T): void => { + for (const el of document.querySelectorAll(`[data-view]`)) + el.classList.toggle( + `hidden`, + el.getAttribute(`data-view`) !== view, + ); +}; +\ No newline at end of file