2020-02-14 12:51:45 +01:00
|
|
|
<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
|
2020-03-04 16:20:53 +01:00
|
|
|
export let type = "div"
|
2020-02-25 16:21:23 +01:00
|
|
|
export let backgroundColor
|
|
|
|
export let color
|
|
|
|
export let borderWidth
|
|
|
|
export let borderColor
|
|
|
|
export let borderStyle
|
|
|
|
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
|
|
|
$: cssVariables = {
|
|
|
|
backgroundColor,
|
|
|
|
color,
|
|
|
|
borderWidth,
|
|
|
|
borderColor,
|
|
|
|
borderStyle,
|
|
|
|
}
|
|
|
|
$: classes = `${createClasses(cssVariables)} ${className}`
|
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
|
|
|
|
}
|
2020-02-14 12:51:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2020-02-25 16:21:23 +01:00
|
|
|
{#if type === 'div'}
|
|
|
|
<div
|
|
|
|
class={classes}
|
|
|
|
bind:this={containerElement}
|
|
|
|
use:cssVars={cssVariables} />
|
|
|
|
{:else if type === 'header'}
|
|
|
|
<header
|
|
|
|
class={classes}
|
|
|
|
bind:this={containerElement}
|
|
|
|
use:cssVars={cssVariables} />
|
|
|
|
{:else if type === 'main'}
|
|
|
|
<main
|
|
|
|
class={classes}
|
|
|
|
bind:this={containerElement}
|
|
|
|
use:cssVars={cssVariables} />
|
|
|
|
{:else if type === 'footer'}
|
|
|
|
<footer
|
|
|
|
class={classes}
|
|
|
|
bind:this={containerElement}
|
|
|
|
use:cssVars={cssVariables} />
|
|
|
|
{:else if type === 'aside'}
|
|
|
|
<aside
|
|
|
|
class={classes}
|
|
|
|
bind:this={containerElement}
|
|
|
|
use:cssVars={cssVariables} />
|
|
|
|
{:else if type === 'summary'}
|
|
|
|
<summary
|
|
|
|
class={classes}
|
|
|
|
bind:this={containerElement}
|
|
|
|
use:cssVars={cssVariables} />
|
|
|
|
{:else if type === 'details'}
|
|
|
|
<details
|
|
|
|
class={classes}
|
|
|
|
bind:this={containerElement}
|
|
|
|
use:cssVars={cssVariables} />
|
|
|
|
{:else if type === 'article'}
|
|
|
|
<article
|
|
|
|
class={classes}
|
|
|
|
bind:this={containerElement}
|
|
|
|
use:cssVars={cssVariables} />
|
|
|
|
{:else if type === 'nav'}
|
|
|
|
<nav
|
|
|
|
class={classes}
|
|
|
|
bind:this={containerElement}
|
|
|
|
use:cssVars={cssVariables} />
|
|
|
|
{:else if type === 'mark'}
|
|
|
|
<mark
|
|
|
|
class={classes}
|
|
|
|
bind:this={containerElement}
|
|
|
|
use:cssVars={cssVariables} />
|
|
|
|
{:else if type === 'figure'}
|
|
|
|
<figure
|
|
|
|
class={classes}
|
|
|
|
bind:this={containerElement}
|
|
|
|
use:cssVars={cssVariables} />
|
|
|
|
{:else if type === 'figcaption'}
|
|
|
|
<figcaption
|
|
|
|
class={classes}
|
|
|
|
bind:this={containerElement}
|
|
|
|
use:cssVars={cssVariables} />
|
|
|
|
{:else if type === 'paragraph'}
|
|
|
|
<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>
|
2020-02-25 16:21:23 +01:00
|
|
|
.backgroundColor {
|
|
|
|
background-color: var(--backgroundColor);
|
|
|
|
}
|
2020-02-21 12:43:21 +01:00
|
|
|
|
2020-02-25 16:21:23 +01:00
|
|
|
.color {
|
|
|
|
color: var(--color);
|
|
|
|
}
|
2020-02-21 12:43:21 +01:00
|
|
|
|
2020-02-25 16:21:23 +01:00
|
|
|
.borderColor {
|
|
|
|
border-color: var(--borderColor);
|
|
|
|
}
|
2020-02-21 12:43:21 +01:00
|
|
|
|
2020-02-25 16:21:23 +01:00
|
|
|
.borderWidth {
|
|
|
|
border-width: var(--borderWidth);
|
|
|
|
}
|
2020-02-21 12:43:21 +01:00
|
|
|
|
2020-02-25 16:21:23 +01:00
|
|
|
.borderStyle {
|
|
|
|
border-style: var(--borderStyle);
|
|
|
|
}
|
2020-02-21 12:43:21 +01:00
|
|
|
</style>
|