Add PoC of using a custom component inside client library
This commit is contained in:
parent
3a340379e9
commit
0ec6ac3372
|
@ -85,8 +85,18 @@
|
||||||
builderStore.actions.notifyLoaded()
|
builderStore.actions.notifyLoaded()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// TODO: remove. this is a test to render the first custom component
|
||||||
|
console.log(window["##BUDIBASE_CUSTOM_COMPONENTS##"]?.[0])
|
||||||
|
const custom = window["##BUDIBASE_CUSTOM_COMPONENTS##"]?.[0]?.Component
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{#if custom}
|
||||||
|
<div style="padding: 20px;">
|
||||||
|
<svelte:component this={custom} />
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if dataLoaded}
|
{#if dataLoaded}
|
||||||
<div
|
<div
|
||||||
id="spectrum-root"
|
id="spectrum-root"
|
||||||
|
|
|
@ -3,6 +3,12 @@ import { builderStore, appStore, devToolsStore } from "./stores"
|
||||||
import loadSpectrumIcons from "@budibase/bbui/spectrum-icons-rollup.js"
|
import loadSpectrumIcons from "@budibase/bbui/spectrum-icons-rollup.js"
|
||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
|
|
||||||
|
// Provide svelte and svelte/internal as globals for custom components
|
||||||
|
import * as svelte from "svelte"
|
||||||
|
import * as internal from "svelte/internal"
|
||||||
|
window.svelte_internal = internal
|
||||||
|
window.svelte = svelte
|
||||||
|
|
||||||
// Initialise spectrum icons
|
// Initialise spectrum icons
|
||||||
loadSpectrumIcons()
|
loadSpectrumIcons()
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,11 @@
|
||||||
</script>
|
</script>
|
||||||
<script type="application/javascript" src={clientLibPath}>
|
<script type="application/javascript" src={clientLibPath}>
|
||||||
</script>
|
</script>
|
||||||
|
<!-- Custom components need inserted after the core client library -->
|
||||||
|
<!-- But before loadBudibase is called -->
|
||||||
|
<script
|
||||||
|
type="application/javascript"
|
||||||
|
src="https://cdn.kingston.dev/plugin.min.js"></script>
|
||||||
<script type="application/javascript">
|
<script type="application/javascript">
|
||||||
if (window.loadBudibase) {
|
if (window.loadBudibase) {
|
||||||
window.loadBudibase()
|
window.loadBudibase()
|
||||||
|
|
Loading…
Reference in New Issue