gradio/ui/packages/app/src/components/Label/Label.svelte

36 lines
1.0 KiB
Svelte
Raw Normal View History

2022-03-08 21:35:42 +08:00
<script lang="ts">
2022-03-17 00:34:30 +08:00
import { createEventDispatcher } from "svelte";
2022-03-08 21:35:42 +08:00
import { Label } from "@gradio/label";
import { LineChart as LabelIcon } from "@gradio/icons";
import { Block, BlockLabel } from "@gradio/atoms";
import StatusTracker from "../StatusTracker/StatusTracker.svelte";
import type { LoadingStatus } from "../StatusTracker/types";
2022-03-08 21:35:42 +08:00
export let elem_id: string = "";
2022-03-08 21:35:42 +08:00
export let value: {
label: string;
confidences?: Array<{ label: string; confidence: number }>;
};
2022-05-13 08:23:45 +08:00
export let label: string = "Label";
2022-03-29 21:10:35 +08:00
export let loading_status: LoadingStatus;
export let show_label: boolean;
2022-03-17 00:34:30 +08:00
const dispatch = createEventDispatcher<{ change: undefined }>();
$: value, dispatch("change");
2022-03-08 21:35:42 +08:00
</script>
<Block {elem_id}>
<StatusTracker {...loading_status} />
<BlockLabel Icon={LabelIcon} {label} />
{#if value !== undefined && value !== null}
<Label {value} {show_label} />
{:else}
<div class="min-h-[6rem] flex justify-center items-center">
<div class="h-5 dark:text-white opacity-50"><LabelIcon /></div>
</div>
{/if}
</Block>