From 068a14ffa464d6cb0ccc5c3cec11d10d8cceae90 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> Date: Sun, 26 Mar 2023 22:39:07 +0530 Subject: Sharing code between scripts for reduced bundle size. --- src/shared/styling.ts | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/shared/styling.ts (limited to 'src/shared/styling.ts') diff --git a/src/shared/styling.ts b/src/shared/styling.ts new file mode 100644 index 0000000..0e527d9 --- /dev/null +++ b/src/shared/styling.ts @@ -0,0 +1,8 @@ +export const styles = (selector: string, styles: { [key: string]: string }) => { + const elements = Array.from(document.querySelectorAll(selector)) as HTMLElement[]; + for (const element of elements) { + for (const styleType in styles) { + element.style[styleType as any] = styles[styleType]; + } + } +}; -- cgit v1.2.3