Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show empty JSON icon when value is null #5944

Merged
merged 9 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/twenty-dryers-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/json": patch
"gradio": patch
---

fix:Show empty JSON icon when `value` is `null`
6 changes: 0 additions & 6 deletions js/json/static/JSON.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<script lang="ts">
import { onDestroy } from "svelte";
import { fade } from "svelte/transition";
import { JSON as JSONIcon } from "@gradio/icons";
import { Empty } from "@gradio/atoms";
import JSONNode from "./JSONNode.svelte";
import { Copy, Check } from "@gradio/icons";

Expand Down Expand Up @@ -58,10 +56,6 @@
<div class="json-holder">
<JSONNode {value} depth={0} />
</div>
{:else}
<Empty>
<JSONIcon />
</Empty>
{/if}

<style>
Expand Down
9 changes: 8 additions & 1 deletion js/json/static/JSONNode.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<script lang="ts">
import { JSON as JSONIcon } from "@gradio/icons";
import { Empty } from "@gradio/atoms";

export let value: any;
export let depth: number;
export let collapsed = depth > 4;
Expand Down Expand Up @@ -57,7 +60,11 @@
&#125;
{/if}
{:else if value === null}
<div class="json-item null">null</div>
<div class="json-item null">
<Empty>
<JSONIcon />
</Empty>
</div>
{:else if typeof value === "string"}
<div class="json-item string">
"{value}"
Expand Down
Loading