2020-02-14 12:51:45 +01:00
|
|
|
<script>
|
2020-02-21 12:43:21 +01:00
|
|
|
import { cssVars, createClasses } from "./cssVars"
|
|
|
|
|
|
|
|
export let className = ""
|
|
|
|
export let onLoad
|
|
|
|
export let type
|
|
|
|
export let backgroundColor
|
|
|
|
export let color
|
|
|
|
export let borderWidth
|
|
|
|
export let borderColor
|
|
|
|
export let borderStyle
|
|
|
|
export let _bb
|
|
|
|
|
|
|
|
let containerElement
|
|
|
|
let hasLoaded;
|
|
|
|
let currentChildren;
|
|
|
|
|
|
|
|
$: cssVariables = {
|
|
|
|
backgroundColor, color,
|
|
|
|
borderWidth, borderColor,
|
|
|
|
borderStyle
|
|
|
|
}
|
|
|
|
$: classes = `${createClasses(cssVariables)} ${className}`
|
|
|
|
|
|
|
|
$: {
|
|
|
|
if(containerElement) {
|
|
|
|
_bb.attachChildren(containerElement)
|
|
|
|
if (!hasLoaded) {
|
|
|
|
_bb.call(onLoad)
|
|
|
|
hasLoaded = true
|
2020-02-14 12:51:45 +01:00
|
|
|
}
|
|
|
|
}
|
2020-02-21 12:43:21 +01:00
|
|
|
}
|
2020-02-14 12:51:45 +01:00
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
{#if type === "div"}
|
2020-02-21 12:43:21 +01:00
|
|
|
<div class={classes} bind:this={containerElement} use:cssVars={cssVariables} />
|
2020-02-14 12:51:45 +01:00
|
|
|
{:else if type === "header"}
|
2020-02-21 12:43:21 +01:00
|
|
|
<header class={classes} bind:this={containerElement} use:cssVars={cssVariables} />
|
2020-02-14 12:51:45 +01:00
|
|
|
{:else if type === "main"}
|
2020-02-21 12:43:21 +01:00
|
|
|
<main class={classes} bind:this={containerElement} use:cssVars={cssVariables} />
|
2020-02-14 12:51:45 +01:00
|
|
|
{:else if type === "footer"}
|
2020-02-21 12:43:21 +01:00
|
|
|
<footer class={classes} bind:this={containerElement} use:cssVars={cssVariables} />
|
2020-02-14 12:51:45 +01:00
|
|
|
{:else if type === "aside"}
|
2020-02-21 12:43:21 +01:00
|
|
|
<aside class={classes} bind:this={containerElement} use:cssVars={cssVariables} />
|
2020-02-14 12:51:45 +01:00
|
|
|
{:else if type === "summary"}
|
2020-02-21 12:43:21 +01:00
|
|
|
<summary class={classes} bind:this={containerElement} use:cssVars={cssVariables} />
|
2020-02-14 12:51:45 +01:00
|
|
|
{:else if type === "details"}
|
2020-02-21 12:43:21 +01:00
|
|
|
<details class={classes} bind:this={containerElement} use:cssVars={cssVariables} />
|
2020-02-14 12:51:45 +01:00
|
|
|
{:else if type === "article"}
|
2020-02-21 12:43:21 +01:00
|
|
|
<article class={classes} bind:this={containerElement} use:cssVars={cssVariables} />
|
2020-02-14 12:51:45 +01:00
|
|
|
{:else if type === "nav"}
|
2020-02-21 12:43:21 +01:00
|
|
|
<nav class={classes} bind:this={containerElement} use:cssVars={cssVariables} />
|
2020-02-14 12:51:45 +01:00
|
|
|
{:else if type === "mark"}
|
2020-02-21 12:43:21 +01:00
|
|
|
<mark class={classes} bind:this={containerElement} use:cssVars={cssVariables} />
|
2020-02-14 12:51:45 +01:00
|
|
|
{:else if type === "figure"}
|
2020-02-21 12:43:21 +01:00
|
|
|
<figure class={classes} bind:this={containerElement} use:cssVars={cssVariables} />
|
2020-02-14 12:51:45 +01:00
|
|
|
{:else if type === "figcaption"}
|
2020-02-21 12:43:21 +01:00
|
|
|
<figcaption class={classes} bind:this={containerElement} use:cssVars={cssVariables} />
|
2020-02-14 12:51:45 +01:00
|
|
|
{:else if type === "paragraph"}
|
2020-02-21 12:43:21 +01:00
|
|
|
<p class={classes} bind:this={containerElement} use:cssVars={cssVariables} />
|
2020-02-14 12:51:45 +01:00
|
|
|
{/if}
|
2020-02-21 12:43:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
|
|
|
.backgroundColor {
|
|
|
|
background-color: var(--backgroundColor)
|
|
|
|
}
|
|
|
|
|
|
|
|
.color {
|
|
|
|
color: var(--color)
|
|
|
|
}
|
|
|
|
|
|
|
|
.borderColor {
|
|
|
|
border-color: var(--borderColor)
|
|
|
|
}
|
|
|
|
|
|
|
|
.borderWidth {
|
|
|
|
border-width: var(--borderWidth)
|
|
|
|
}
|
|
|
|
|
|
|
|
.borderStyle {
|
|
|
|
border-style: var(--borderStyle)
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|