-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support bold and italic text in storybooks
- Loading branch information
Showing
3 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |