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

30 lines
559 B
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")
2021-06-11 12:37:05 +02:00
export let text
2021-06-11 12:37:05 +02:00
$: placeholder = $builderStore.inBuilder && !text
$: componentText = $builderStore.inBuilder
? text || "Placeholder text"
: text || ""
</script>
2021-06-11 12:37:05 +02:00
<p use:styleable={$component.styles} class:placeholder>
{componentText}
</p>
<style>
2021-02-23 11:04:07 +01:00
p {
display: inline-block;
2021-02-23 11:04:07 +01:00
white-space: pre-wrap;
}
2021-06-11 12:37:05 +02:00
.placeholder {
font-style: italic;
2021-06-11 12:37:05 +02:00
color: var(--grey-6);
}
</style>