forked from tsai/budibase
8 changed files with 154 additions and 45 deletions
@ -1,49 +1,88 @@ |
|||||
<script> |
<script> |
||||
export let className = "" |
import { cssVars, createClasses } from "./cssVars" |
||||
export let onLoad |
|
||||
export let type |
export let className = "" |
||||
export let _bb |
export let onLoad |
||||
|
export let type |
||||
let containerElement |
export let backgroundColor |
||||
let hasLoaded; |
export let color |
||||
let currentChildren; |
export let borderWidth |
||||
|
export let borderColor |
||||
$: { |
export let borderStyle |
||||
if(containerElement) { |
export let _bb |
||||
_bb.attachChildren(containerElement) |
|
||||
if (!hasLoaded) { |
let containerElement |
||||
_bb.call(onLoad) |
let hasLoaded; |
||||
hasLoaded = true |
let currentChildren; |
||||
} |
|
||||
|
$: cssVariables = { |
||||
|
backgroundColor, color, |
||||
|
borderWidth, borderColor, |
||||
|
borderStyle |
||||
|
} |
||||
|
$: classes = `${createClasses(cssVariables)} ${className}` |
||||
|
|
||||
|
$: { |
||||
|
if(containerElement) { |
||||
|
_bb.attachChildren(containerElement) |
||||
|
if (!hasLoaded) { |
||||
|
_bb.call(onLoad) |
||||
|
hasLoaded = true |
||||
} |
} |
||||
} |
} |
||||
|
} |
||||
|
|
||||
</script> |
</script> |
||||
|
|
||||
{#if type === "div"} |
{#if type === "div"} |
||||
<div class={className} bind:this={containerElement} /> |
<div class={classes} bind:this={containerElement} use:cssVars={cssVariables} /> |
||||
{:else if type === "header"} |
{:else if type === "header"} |
||||
<header class={className} bind:this={containerElement} /> |
<header class={classes} bind:this={containerElement} use:cssVars={cssVariables} /> |
||||
{:else if type === "main"} |
{:else if type === "main"} |
||||
<main class={className} bind:this={containerElement} /> |
<main class={classes} bind:this={containerElement} use:cssVars={cssVariables} /> |
||||
{:else if type === "footer"} |
{:else if type === "footer"} |
||||
<footer class={className} bind:this={containerElement} /> |
<footer class={classes} bind:this={containerElement} use:cssVars={cssVariables} /> |
||||
{:else if type === "aside"} |
{:else if type === "aside"} |
||||
<aside class={className} bind:this={containerElement} /> |
<aside class={classes} bind:this={containerElement} use:cssVars={cssVariables} /> |
||||
{:else if type === "summary"} |
{:else if type === "summary"} |
||||
<summary class={className} bind:this={containerElement} /> |
<summary class={classes} bind:this={containerElement} use:cssVars={cssVariables} /> |
||||
{:else if type === "details"} |
{:else if type === "details"} |
||||
<details class={className} bind:this={containerElement} /> |
<details class={classes} bind:this={containerElement} use:cssVars={cssVariables} /> |
||||
{:else if type === "article"} |
{:else if type === "article"} |
||||
<article class={className} bind:this={containerElement} /> |
<article class={classes} bind:this={containerElement} use:cssVars={cssVariables} /> |
||||
{:else if type === "nav"} |
{:else if type === "nav"} |
||||
<nav class={className} bind:this={containerElement} /> |
<nav class={classes} bind:this={containerElement} use:cssVars={cssVariables} /> |
||||
{:else if type === "mark"} |
{:else if type === "mark"} |
||||
<mark class={className} bind:this={containerElement} /> |
<mark class={classes} bind:this={containerElement} use:cssVars={cssVariables} /> |
||||
{:else if type === "figure"} |
{:else if type === "figure"} |
||||
<figure class={className} bind:this={containerElement} /> |
<figure class={classes} bind:this={containerElement} use:cssVars={cssVariables} /> |
||||
{:else if type === "figcaption"} |
{:else if type === "figcaption"} |
||||
<figcaption class={className} bind:this={containerElement} /> |
<figcaption class={classes} bind:this={containerElement} use:cssVars={cssVariables} /> |
||||
{:else if type === "paragraph"} |
{:else if type === "paragraph"} |
||||
<p class={className} bind:this={containerElement} /> |
<p class={classes} bind:this={containerElement} use:cssVars={cssVariables} /> |
||||
{/if} |
{/if} |
||||
|
|
||||
|
|
||||
|
<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> |
||||
|
|||||
@ -1,3 +1,3 @@ |
|||||
import { container, text, heading, input, select, option, button, login, nav, table } from "../index" |
import * as components from "../index" |
||||
|
|
||||
export default { container, text, heading, input, select, option, button, login, nav, table } |
export default components |
||||
|
|||||
Loading…
Reference in new issue