forked from MapComplete/MapComplete
Experimenting with Svelte: build a wrapper to convert 'old' components into Svelte, add a community index overview
This commit is contained in:
parent
dfc7ba2114
commit
02da80c311
11 changed files with 250 additions and 55 deletions
17
UI/Base/ToSvelte.svelte
Normal file
17
UI/Base/ToSvelte.svelte
Normal file
|
@ -0,0 +1,17 @@
|
|||
<script lang="ts">
|
||||
import BaseUIElement from "../BaseUIElement.js";
|
||||
import { onMount } from "svelte";
|
||||
|
||||
export let construct: BaseUIElement | (() => BaseUIElement);
|
||||
let elem: HTMLElement;
|
||||
onMount(() => {
|
||||
let html: HTMLElement
|
||||
if (typeof construct === "function") {
|
||||
html = construct().ConstructElement();
|
||||
} else {
|
||||
html = construct.ConstructElement();
|
||||
}
|
||||
elem.appendChild(html)
|
||||
});
|
||||
</script>
|
||||
<span bind:this={elem}></span>
|
Loading…
Add table
Add a link
Reference in a new issue