2019-09-19 05:35:40 +02:00
|
|
|
<script>
|
2020-11-18 20:18:18 +01:00
|
|
|
import { getContext } from "svelte"
|
|
|
|
|
2021-06-11 12:37:05 +02:00
|
|
|
const { styleable, builderStore } = getContext("sdk")
|
2020-11-24 12:02:10 +01:00
|
|
|
const component = getContext("component")
|
2020-11-17 15:06:43 +01:00
|
|
|
|
2021-06-11 12:37:05 +02:00
|
|
|
export let text
|
2021-06-23 15:21:37 +02:00
|
|
|
export let color
|
|
|
|
export let align
|
|
|
|
export let bold
|
|
|
|
export let italic
|
|
|
|
export let underline
|
|
|
|
export let size
|
2021-06-08 09:00:54 +02:00
|
|
|
|
2021-06-11 12:37:05 +02:00
|
|
|
$: placeholder = $builderStore.inBuilder && !text
|
|
|
|
$: componentText = $builderStore.inBuilder
|
|
|
|
? text || "Placeholder text"
|
|
|
|
: text || ""
|
2021-06-23 15:21:37 +02:00
|
|
|
|
|
|
|
// Add color styles to main styles object, otherwise the styleable helper
|
|
|
|
// overrides the color when it's passed as inline style.
|
|
|
|
$: styles = {
|
|
|
|
...$component.styles,
|
|
|
|
normal: {
|
|
|
|
...$component.styles?.normal,
|
|
|
|
color,
|
|
|
|
},
|
|
|
|
}
|
2019-09-19 05:35:40 +02:00
|
|
|
</script>
|
|
|
|
|
2021-06-23 15:21:37 +02:00
|
|
|
<p
|
|
|
|
use:styleable={styles}
|
|
|
|
class:placeholder
|
|
|
|
class:bold
|
|
|
|
class:italic
|
|
|
|
class:underline
|
|
|
|
class="align--{align || 'left'} size--{size || 'M'}"
|
|
|
|
>
|
2021-06-11 12:37:05 +02:00
|
|
|
{componentText}
|
2021-06-08 09:00:54 +02:00
|
|
|
</p>
|
2020-10-16 09:34:17 +02:00
|
|
|
|
|
|
|
<style>
|
2021-02-23 11:04:07 +01:00
|
|
|
p {
|
2020-10-16 09:34:17 +02:00
|
|
|
display: inline-block;
|
2021-02-23 11:04:07 +01:00
|
|
|
white-space: pre-wrap;
|
2020-10-16 09:34:17 +02:00
|
|
|
}
|
2021-06-11 12:37:05 +02:00
|
|
|
.placeholder {
|
2021-06-08 09:00:54 +02:00
|
|
|
font-style: italic;
|
2021-06-11 12:37:05 +02:00
|
|
|
color: var(--grey-6);
|
2021-06-08 09:00:54 +02:00
|
|
|
}
|
2021-06-23 15:21:37 +02:00
|
|
|
.bold {
|
|
|
|
font-weight: 600;
|
|
|
|
}
|
|
|
|
.italic {
|
|
|
|
font-style: italic;
|
|
|
|
}
|
|
|
|
.underline {
|
|
|
|
text-decoration: underline;
|
|
|
|
}
|
|
|
|
.size--S {
|
|
|
|
font-size: 14px;
|
|
|
|
}
|
|
|
|
.size--M {
|
|
|
|
font-size: 16px;
|
|
|
|
}
|
|
|
|
.size--L {
|
|
|
|
font-size: 18px;
|
|
|
|
}
|
|
|
|
.align--left {
|
|
|
|
text-align: left;
|
|
|
|
}
|
|
|
|
.align--center {
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
.align--right {
|
|
|
|
text-align: right;
|
|
|
|
}
|
|
|
|
.align-justify {
|
|
|
|
text-align: justify;
|
|
|
|
}
|
2020-10-16 09:34:17 +02:00
|
|
|
</style>
|