budibase/packages/standard-components/src/Container.svelte

51 lines
1.3 KiB
Svelte
Raw Normal View History

<script>
2020-02-25 16:21:23 +01:00
import { cssVars, createClasses } from "./cssVars"
2020-02-21 12:43:21 +01:00
2020-02-25 16:21:23 +01:00
export let className = ""
export let onLoad
export let type = "div"
2020-02-25 16:21:23 +01:00
export let _bb
2020-02-21 12:43:21 +01:00
2020-02-25 16:21:23 +01:00
let containerElement
let hasLoaded
let currentChildren
2020-02-21 12:43:21 +01:00
2020-02-25 16:21:23 +01:00
$: {
if (containerElement) {
_bb.attachChildren(containerElement)
if (!hasLoaded) {
_bb.call(onLoad)
hasLoaded = true
}
}
}
</script>
2020-02-25 16:21:23 +01:00
{#if type === 'div'}
<div bind:this={containerElement} />
2020-02-25 16:21:23 +01:00
{:else if type === 'header'}
<header bind:this={containerElement} />
2020-02-25 16:21:23 +01:00
{:else if type === 'main'}
<main bind:this={containerElement} />
2020-02-25 16:21:23 +01:00
{:else if type === 'footer'}
<footer bind:this={containerElement} />
2020-02-25 16:21:23 +01:00
{:else if type === 'aside'}
<aside bind:this={containerElement} />
2020-02-25 16:21:23 +01:00
{:else if type === 'summary'}
<summary bind:this={containerElement} />
2020-02-25 16:21:23 +01:00
{:else if type === 'details'}
<details bind:this={containerElement} />
2020-02-25 16:21:23 +01:00
{:else if type === 'article'}
<article bind:this={containerElement} />
2020-02-25 16:21:23 +01:00
{:else if type === 'nav'}
<nav bind:this={containerElement} />
2020-02-25 16:21:23 +01:00
{:else if type === 'mark'}
<mark bind:this={containerElement} />
2020-02-25 16:21:23 +01:00
{:else if type === 'figure'}
<figure bind:this={containerElement} />
2020-02-25 16:21:23 +01:00
{:else if type === 'figcaption'}
<figcaption bind:this={containerElement} />
2020-02-25 16:21:23 +01:00
{:else if type === 'paragraph'}
<p bind:this={containerElement} />
{/if}