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

30 lines
991 B
Svelte
Raw Normal View History

<script>
import { buildStyle } from "./buildStyle.js"
export let className = ""
export let type
export let _bb
2020-04-22 12:52:55 +02:00
export let text = ""
export let fontFamily = ""
export let color = ""
let containerElement
2020-04-22 12:52:55 +02:00
$: containerElement && !text && _bb.attachChildren(containerElement)
$: style = buildStyle({ "font-family": fontFamily, color })
// $: console.log("HEADING", color)
</script>
2020-02-25 16:21:23 +01:00
{#if type === 'h1'}
<h1 class={className} {style} bind:this={containerElement}>{text}</h1>
2020-02-25 16:21:23 +01:00
{:else if type === 'h2'}
<h2 class={className} {style} bind:this={containerElement}>{text}</h2>
2020-02-25 16:21:23 +01:00
{:else if type === 'h3'}
<h3 class={className} {style} bind:this={containerElement}>{text}</h3>
2020-02-25 16:21:23 +01:00
{:else if type === 'h4'}
<h4 class={className} {style} bind:this={containerElement}>{text}</h4>
2020-02-25 16:21:23 +01:00
{:else if type === 'h5'}
<h5 class={className} {style} bind:this={containerElement}>{text}</h5>
2020-02-25 16:21:23 +01:00
{:else if type === 'h6'}
<h6 class={className} {style} bind:this={containerElement}>{text}</h6>
{/if}