aboutsummaryrefslogtreecommitdiffstats
path: root/src/shared/styling.ts
blob: b19ace4efda1b0fe17910dc0969959875c348741 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/**
 * Applies a set of inline CSS styles to every element matching the
 * given CSS selector.
 *
 * @param selector - CSS selector string.
 * @param styles   - A map of CSS property names to values.
 */
export function styles(selector: string, styles: Record<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];
		}
	}
};