File size: 3,146 Bytes
0ad74ed |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
<script>
import { Meta, Template, Story } from "@storybook/addon-svelte-csf";
import HighlightedText from "./Index.svelte";
</script>
<Meta title="Components/HighlightedText" component={HighlightedText} />
<Template let:args>
<HighlightedText
value={[
{ token: "zebras", class_or_confidence: "+" },
{ token: "dogs", class_or_confidence: "-" },
{ token: "elephants", class_or_confidence: "+" }
]}
{...args}
/>
</Template>
<Story name="Highlighted Text Default" />
<Story name="Highlighted Text with legend" args={{ show_legend: true }} />
<Story name="Highlighted Text with label" args={{ label: "animals" }} />
<Story
name="Highlighted Text with new lines"
args={{
value: [
{ token: "zebras", class_or_confidence: "+" },
{ token: "\n" },
{ token: "dogs", class_or_confidence: "-" },
{ token: "\n" },
{ token: "elephants", class_or_confidence: "+" }
]
}}
/>
<Story
name="Highlighted Text with color map"
args={{ color_map: { "+": "green", "-": "red" } }}
/>
<Story
name="Highlighted Text with combine adjacent"
args={{
value: [
{ token: "The", class_or_confidence: null },
{ token: "quick", class_or_confidence: "adjective" },
{ token: " sneaky", class_or_confidence: "adjective" },
{ token: "fox", class_or_confidence: "subject" },
{ token: " jumped ", class_or_confidence: "past tense verb" },
{ token: "over the", class_or_confidence: null },
{ token: "lazy dog", class_or_confidence: "object" }
],
combine_adjacent: true
}}
/>
<Story
name="Highlighted Text without combine adjacent"
args={{
value: [
{ token: "The", class_or_confidence: null },
{ token: "quick", class_or_confidence: "adjective" },
{ token: " sneaky", class_or_confidence: "adjective" },
{ token: "fox", class_or_confidence: "subject" },
{ token: " jumped ", class_or_confidence: "past tense verb" },
{ token: "over the", class_or_confidence: null },
{ token: "lazy dog", class_or_confidence: "object" }
]
}}
/>
<Story
name="Highlighted Text with combine adjacent and new lines"
args={{
value: [
{ token: "The", class_or_confidence: null },
{ token: "quick", class_or_confidence: "adjective" },
{ token: " sneaky", class_or_confidence: "adjective" },
{ token: "fox", class_or_confidence: "subject" },
{ token: "\n", class_or_confidence: null },
{ token: " jumped ", class_or_confidence: "past tense verb" },
{ token: "\n", class_or_confidence: null },
{ token: "over the", class_or_confidence: null },
{ token: "lazy dog", class_or_confidence: "object" }
],
combine_adjacent: true
}}
/>
<Story
name="Highlighted Text in scores mode"
args={{
value: [
{ token: "the", class_or_confidence: -1 },
{ token: "quick", class_or_confidence: 1 },
{ token: "fox", class_or_confidence: 0.3 }
],
show_legend: true
}}
/>
<Story
name="Highlighted Text with hidden inline category"
args={{
value: [
{ token: "the", class_or_confidence: -1 },
{ token: "quick", class_or_confidence: 1 },
{ token: "fox", class_or_confidence: 0.3 }
],
show_legend: false,
show_inline_category: false,
interactive: false
}}
/>
|