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

45 lines
1.1 KiB
Svelte
Raw Normal View History

<script>
import { getContext } from "svelte"
2021-06-11 12:37:05 +02:00
const { styleable, builderStore } = getContext("sdk")
const component = getContext("component")
export let type
2021-06-11 12:37:05 +02:00
export let text
$: placeholder = $builderStore.inBuilder && !text
$: componentText = $builderStore.inBuilder
? text || "Placeholder text"
: text || ""
</script>
{#if type === "h1"}
2021-06-11 12:37:05 +02:00
<h1 class:placeholder use:styleable={$component.styles}>{componentText}</h1>
{:else if type === "h2"}
2021-06-11 12:37:05 +02:00
<h2 class:placeholder use:styleable={$component.styles}>{componentText}</h2>
{:else if type === "h3"}
2021-06-11 12:37:05 +02:00
<h3 class:placeholder use:styleable={$component.styles}>{componentText}</h3>
{:else if type === "h4"}
2021-06-11 12:37:05 +02:00
<h4 class:placeholder use:styleable={$component.styles}>{componentText}</h4>
{:else if type === "h5"}
2021-06-11 12:37:05 +02:00
<h5 class:placeholder use:styleable={$component.styles}>{componentText}</h5>
{:else if type === "h6"}
2021-06-11 12:37:05 +02:00
<h6 class:placeholder use:styleable={$component.styles}>{componentText}</h6>
{/if}
<style>
h1,
h2,
h3,
h4,
h5,
h6 {
white-space: pre-wrap;
}
2021-06-11 12:37:05 +02:00
.placeholder {
font-style: italic;
color: var(--grey-6);
}
</style>