From 5404a95c15e176d25728bf1a319ddb9828b23625 Mon Sep 17 00:00:00 2001 From: Josh Kingsley Date: Sat, 25 Oct 2025 20:46:35 +0300 Subject: refactor(web): re-organize files --- web/src/html.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 web/src/html.ts (limited to 'web/src/html.ts') diff --git a/web/src/html.ts b/web/src/html.ts new file mode 100644 index 0000000..5bfff21 --- /dev/null +++ b/web/src/html.ts @@ -0,0 +1,26 @@ +export type CreateElement = { + (...children: (Node | string)[]): T; + (attrs: Partial, ...children: (Node | string)[]): T; +}; + +type ElementCreator = { + [K in keyof HTMLElementTagNameMap]: CreateElement; +}; + +const h = new Proxy({} as ElementCreator, { + get: + (_, tag: string) => + (...args: any[]) => { + const el = document.createElement(tag); + + if (typeof args[0] === "object") { + Object.assign(el, args.shift()); + } + + el.append(...args.flat()); + + return el; + }, +}); + +export default h; -- cgit v1.2.3