From df16163e4b6ba2d2f94904e22145dec725df3a11 Mon Sep 17 00:00:00 2001 From: Seth Trowbridge Date: Tue, 20 Jun 2023 06:51:38 -0400 Subject: [PATCH] mount started --- _lib_/mount.tsx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 _lib_/mount.tsx diff --git a/_lib_/mount.tsx b/_lib_/mount.tsx new file mode 100644 index 0000000..da350c5 --- /dev/null +++ b/_lib_/mount.tsx @@ -0,0 +1,27 @@ +import * as TW from "https://esm.sh/@twind/core@1.0.1"; +import TWPreTail from "https://esm.sh/@twind/preset-tailwind@1.0.1"; +import TWPreAuto from "https://esm.sh/@twind/preset-autoprefix@1.0.1"; + +const Configure = { + theme: {}, + presets:[TWPreTail(), TWPreAuto()] +} as TW.TwindUserConfig; + +export default (inElement:HTMLElement, inConfig?:TW.TwindUserConfig)=> +{ + const ShadowDOM = inElement.attachShadow({ mode: "open" }); + const ShadowDiv = document.createElement("div"); + const ShadowCSS = document.createElement("style"); + ShadowDOM.append(ShadowCSS); + ShadowDOM.append(ShadowDiv); + + const merge = inConfig ? {...Configure, ...inConfig} : Configure; + TW.observe(TW.twind(merge, TW.cssom(ShadowCSS)), ShadowDiv); + return ShadowDiv; +} + + +import * as App from "app"; +import React from "react"; +const Wrapper =()=> React.createElement(App.default, null, null); +React.render(React.createElement(Wrapper, null, null), document.querySelector("#app"));