mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-12 10:34:32 +08:00
600c97c807
* add line numbers and collapse + expand logic
* add story test and style tweaks
* add changeset
* allow expanding via preview
* story tweaks
* remove mobile/desktop story tests
* remove unused thing
* add mode param to view json as list
* add story
* add changeset
* add open param
* amend test
* * add cm-like theme colors
* prevent copy + pasting line numbers and toggle
* a11y tweaks
* remove mode as param and default to list view
* Revert "remove mode as param and default to list view"
This reverts commit 9051f15c5f
.
* Update gradio/components/json_component.py
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
* add changeset
* tweak
* fix nit
---------
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
60 lines
1.1 KiB
Svelte
60 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"
|
|
args={{
|
|
value: SAMPLE_JSON,
|
|
show_indices: true
|
|
}}
|
|
/>
|