mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-15 02:11:15 +08:00
87e3537342
* add height param and styles * use lines instead of height * replace height with lines * add param and add description to gr.code * add title attr * remove styling * format * fix test * add changeset * revert to height * remove lines logic * add changeset * code param tweak * remove redundant code * tweak test * revert onDestroy removal * fix test * tweak * docstring * height fix --------- Co-authored-by: pngwn <hello@pngwn.io> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
61 lines
1.1 KiB
Svelte
61 lines
1.1 KiB
Svelte
<script context="module">
|
|
import { Template, Story } from "@storybook/addon-svelte-csf";
|
|
import JSON from "./Index.svelte";
|
|
import { userEvent, within } from "@storybook/test";
|
|
|
|
const SAMPLE_JSON = {
|
|
items: {
|
|
item: [
|
|
{
|
|
id: "0001",
|
|
type: null,
|
|
is_good: false,
|
|
ppu: 0.55,
|
|
batters: {
|
|
batter: [{ id: "1001", type: "Regular" }]
|
|
},
|
|
topping: [{ id: "5002", type: "Glazed" }]
|
|
}
|
|
]
|
|
}
|
|
};
|
|
|
|
export const meta = {
|
|
title: "Components/JSON",
|
|
component: JSON
|
|
};
|
|
</script>
|
|
|
|
<Template let:args>
|
|
<JSON value={SAMPLE_JSON} {...args} />
|
|
</Template>
|
|
|
|
<Story name="Default JSON" args={{}} />
|
|
|
|
<Story
|
|
name="JSON Interactions"
|
|
args={{
|
|
value: SAMPLE_JSON,
|
|
interactive: true
|
|
}}
|
|
play={async ({ canvasElement }) => {
|
|
const canvas = within(canvasElement);
|
|
|
|
const toggles = within(canvasElement).getAllByRole("button");
|
|
await userEvent.click(toggles[1]);
|
|
await userEvent.click(toggles[1]);
|
|
|
|
await userEvent.click(toggles[2]);
|
|
await userEvent.click(canvas.getAllByText("Object(2)")[0]);
|
|
}}
|
|
/>
|
|
|
|
<Story
|
|
name="JSON viewed as list with height"
|
|
args={{
|
|
value: SAMPLE_JSON,
|
|
show_indices: true,
|
|
height: 200
|
|
}}
|
|
/>
|