Skip to content

Commit 2812691

Browse files
committed
Support bold and italic text in storybooks
1 parent 1158cba commit 2812691

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
<script lang="ts">
22
import RenderContent from './RenderContent.svelte';
33
import type { Wrapper } from './schema/sofria-schema';
4+
import { makesBold, makesItalic } from './schema/wrappers';
45
56
export let wrapper: Wrapper;
7+
8+
const bold = makesBold(wrapper);
9+
const italic = makesItalic(wrapper);
610
</script>
711

8-
<RenderContent content={wrapper.content} />
12+
{#if bold || italic}
13+
<span class:font-bold={bold} class:italic>
14+
<RenderContent content={wrapper.content} />
15+
</span>
16+
{:else}
17+
<RenderContent content={wrapper.content} />
18+
{/if}

src/lib/components/sofria-render-json/SofriaRender.svelte

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
1010
export let document: Document;
1111
12+
console.log(JSON.stringify(document));
13+
1214
let mainSequence: Sequence;
1315
1416
if (isFlatDocument(document)) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { Wrapper } from './sofria-schema';
2+
3+
export function makesBold(wrapper: Wrapper) {
4+
return ['usfm:bd', 'usfm:bdit'].includes(wrapper.subtype);
5+
}
6+
7+
export function makesItalic(wrapper: Wrapper) {
8+
return ['usfm:it', 'usfm:bdit'].includes(wrapper.subtype);
9+
}

0 commit comments

Comments
 (0)