Skip to content

Commit

Permalink
Support bold and italic text in storybooks
Browse files Browse the repository at this point in the history
  • Loading branch information
gmjgeek committed Aug 8, 2024
1 parent 1158cba commit 2812691
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/lib/components/sofria-render-json/RenderWrapper.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
<script lang="ts">
import RenderContent from './RenderContent.svelte';
import type { Wrapper } from './schema/sofria-schema';
import { makesBold, makesItalic } from './schema/wrappers';
export let wrapper: Wrapper;
const bold = makesBold(wrapper);
const italic = makesItalic(wrapper);
</script>

<RenderContent content={wrapper.content} />
{#if bold || italic}
<span class:font-bold={bold} class:italic>
<RenderContent content={wrapper.content} />
</span>
{:else}
<RenderContent content={wrapper.content} />
{/if}
2 changes: 2 additions & 0 deletions src/lib/components/sofria-render-json/SofriaRender.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
export let document: Document;
console.log(JSON.stringify(document));
let mainSequence: Sequence;
if (isFlatDocument(document)) {
Expand Down
9 changes: 9 additions & 0 deletions src/lib/components/sofria-render-json/schema/wrappers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { Wrapper } from './sofria-schema';

export function makesBold(wrapper: Wrapper) {
return ['usfm:bd', 'usfm:bdit'].includes(wrapper.subtype);
}

export function makesItalic(wrapper: Wrapper) {
return ['usfm:it', 'usfm:bdit'].includes(wrapper.subtype);
}

0 comments on commit 2812691

Please sign in to comment.