audiogram-beta/index.html

40 lines
1.2 KiB
HTML
Raw Normal View History

2022-11-24 14:15:34 -05:00
<p class="text-red-500 p-4">outside (should ignore classes and be unstyled)</p>
2022-11-24 12:16:57 -05:00
<div id="app"></div>
2022-11-24 14:15:34 -05:00
<script type="module">
2022-11-24 19:44:05 -05:00
import React from "https://esm.sh/preact@10.11.3/compat";
import {html} from "https://esm.sh/htm@3.1.1/preact";
2022-11-24 14:15:34 -05:00
2022-11-24 19:44:05 -05:00
import * as TW from "https://esm.sh/@twind/core@1.0.1";
2022-11-24 14:15:34 -05:00
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 styles = document.createElement("style");
const root = document.querySelector("#app");
2022-11-24 19:44:05 -05:00
const appShadow = root.attachShadow({mode: "open"});
2022-11-24 14:15:34 -05:00
const appShadowRoot = document.createElement("div");
appShadow.append(styles);
appShadow.append(appShadowRoot);
2022-11-24 19:44:05 -05:00
const inst = TW.twind({presets:[TWPreTail(), TWPreAuto()]}, TW.cssom(styles));
TW.observe(inst, appShadowRoot);
const El =()=>
{
const [StateGet, StateSet] = React.useState(false);
return html`
<div class=${StateGet ? "text-white bg-black": "text-red"} onClick=${e=>StateSet(!StateGet)}>
click
</div>
`;
}
React.render(html`
<p class="text(yellow-500 lg) p-4 font(sans black)">
inside (should be styled)
<${El}/>
</p>`, appShadowRoot);
2022-11-24 14:15:34 -05:00
</script>