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

58 lines
1.3 KiB
Svelte
Raw Normal View History

<script>
2020-02-03 10:50:30 +01:00
import { buildStyle } from "./buildStyle"
export let text = ""
export let className = ""
export let formattingTag = ""
2020-02-03 10:50:30 +01:00
export let font = ""
export let textAlign = ""
export let verticalAlign = ""
export let color = ""
2020-02-03 10:50:30 +01:00
export let _bb
2020-02-03 10:50:30 +01:00
let style = ""
const isTag = tag => (formattingTag || "").indexOf(tag) > -1
2020-02-03 10:50:30 +01:00
$: {
style = buildStyle({
font,
verticalAlign,
color,
"text-align": textAlign,
"vertical-align": verticalAlign,
})
}
</script>
{#if isTag("none")}
2020-02-20 18:06:50 +01:00
<span>{text}</span>
{:else if isTag("<b>")}
<b class={className} {style}>{text}</b>
{:else if isTag("<strong>")}
<strong class={className} {style}>{text}</strong>
{:else if isTag("<i>")}
<i class={className} {style}>{text}</i>
{:else if isTag("<em>")}
<em class={className} {style}>{text}</em>
{:else if isTag("<mark>")}
<mark class={className} {style}>{text}</mark>
{:else if isTag("<small>")}
<small class={className} {style}>{text}</small>
{:else if isTag("<del>")}
<del class={className} {style}>{text}</del>
{:else if isTag("<ins>")}
<ins class={className} {style}>{text}</ins>
{:else if isTag("<sub>")}
<sub class={className} {style}>{text}</sub>
{:else if isTag("<sup>")}
<sup class={className} {style}>{text}</sup>
{:else}
{text}
{/if}