2023-07-31 22:54:29 +08:00
|
|
|
<script>
|
|
|
|
import { Meta, Template, Story } from "@storybook/addon-svelte-csf";
|
2023-09-13 09:47:16 +08:00
|
|
|
import HighlightedText from "./interactive/InteractiveHighlightedText.svelte";
|
2023-08-24 04:48:10 +08:00
|
|
|
import { Gradio } from "../app/src/gradio_helper";
|
2023-07-31 22:54:29 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<Meta title="Components/HighlightedText" component={HighlightedText} />
|
|
|
|
|
|
|
|
<Template let:args>
|
|
|
|
<HighlightedText
|
|
|
|
value={[
|
|
|
|
["zebras", "+"],
|
|
|
|
["dogs", "-"],
|
2023-09-13 09:47:16 +08:00
|
|
|
["elephants", "+"],
|
2023-07-31 22:54:29 +08:00
|
|
|
]}
|
2023-08-24 04:48:10 +08:00
|
|
|
gradio={new Gradio(
|
|
|
|
0,
|
|
|
|
document.body,
|
|
|
|
"light",
|
|
|
|
"1.1.1",
|
|
|
|
"http://localhost:7860"
|
|
|
|
)}
|
2023-07-31 22:54:29 +08:00
|
|
|
{...args}
|
|
|
|
/>
|
|
|
|
</Template>
|
|
|
|
|
|
|
|
<Story name="Highlighted Text" />
|
|
|
|
<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={{
|
2023-09-13 09:47:16 +08:00
|
|
|
value: [["zebras", "+"], ["\n"], ["dogs", "-"], ["\n"], ["elephants", "+"]],
|
2023-07-31 22:54:29 +08:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<Story
|
|
|
|
name="Highlighted Text with color map"
|
|
|
|
args={{ color_map: { "+": "green", "-": "red" } }}
|
|
|
|
/>
|
2023-09-13 09:47:16 +08:00
|
|
|
|
|
|
|
<Story
|
|
|
|
name="Highlighted Text with combine adjacent"
|
|
|
|
args={{
|
|
|
|
value: [
|
|
|
|
["The", null],
|
|
|
|
["quick", "adjective"],
|
|
|
|
[" sneaky", "adjective"],
|
|
|
|
["fox", "subject"],
|
|
|
|
[" jumped ", "past tense verb"],
|
|
|
|
["over the", null],
|
|
|
|
["lazy dog", "object"],
|
|
|
|
],
|
|
|
|
combine_adjacent: true,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<Story
|
|
|
|
name="Highlighted Text without combine adjacent"
|
|
|
|
args={{
|
|
|
|
value: [
|
|
|
|
["The", null],
|
|
|
|
["quick", "adjective"],
|
|
|
|
[" sneaky", "adjective"],
|
|
|
|
["fox", "subject"],
|
|
|
|
[" jumped ", "past tense verb"],
|
|
|
|
["over the", null],
|
|
|
|
["lazy dog", "object"],
|
|
|
|
],
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<Story
|
|
|
|
name="Highlighted Text with combine adjacent and new lines"
|
|
|
|
args={{
|
|
|
|
value: [
|
|
|
|
["The", null],
|
|
|
|
["quick", "adjective"],
|
|
|
|
[" sneaky", "adjective"],
|
|
|
|
["fox", "subject"],
|
|
|
|
["\n"],
|
|
|
|
["jumped", "past tense verb"],
|
|
|
|
["\n"],
|
|
|
|
["over the", null],
|
|
|
|
["lazy dog", "object"],
|
|
|
|
],
|
|
|
|
combine_adjacent: true,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<Story
|
|
|
|
name="Highlighted Text in scores mode"
|
|
|
|
args={{
|
|
|
|
value: [
|
|
|
|
["the", -1],
|
|
|
|
["quick", 1],
|
|
|
|
["fox", 0.3],
|
|
|
|
],
|
|
|
|
|
|
|
|
show_legend: true,
|
|
|
|
}}
|
|
|
|
/>
|