2022-04-14 22:12:30 +08:00
|
|
|
<script lang="ts">
|
|
|
|
import { createEventDispatcher } from "svelte";
|
2023-01-18 04:47:40 +08:00
|
|
|
import { BlockLabel, Empty } from "@gradio/atoms";
|
2022-04-14 22:12:30 +08:00
|
|
|
|
2022-05-10 08:26:09 +08:00
|
|
|
import { Image } from "@gradio/icons";
|
2022-04-14 22:12:30 +08:00
|
|
|
|
|
|
|
export let value: null | string;
|
|
|
|
export let label: string | undefined = undefined;
|
2022-04-27 18:47:15 +08:00
|
|
|
export let show_label: boolean;
|
2022-04-14 22:12:30 +08:00
|
|
|
|
|
|
|
const dispatch = createEventDispatcher<{
|
|
|
|
change: string;
|
|
|
|
}>();
|
|
|
|
|
|
|
|
$: value && dispatch("change", value);
|
|
|
|
</script>
|
|
|
|
|
2022-05-10 08:26:09 +08:00
|
|
|
<BlockLabel {show_label} Icon={Image} label={label || "Image"} />
|
2022-04-26 22:48:39 +08:00
|
|
|
{#if value === null}
|
2023-01-18 04:47:40 +08:00
|
|
|
<Empty size="large" unpadded_box={true}><Image /></Empty>
|
2022-04-26 22:48:39 +08:00
|
|
|
{:else}
|
2023-01-18 04:47:40 +08:00
|
|
|
<img src={value} alt="" />
|
2022-04-26 22:48:39 +08:00
|
|
|
{/if}
|
2023-01-18 04:47:40 +08:00
|
|
|
|
|
|
|
<style>
|
|
|
|
img {
|
|
|
|
width: var(--size-full);
|
|
|
|
height: var(--size-full);
|
|
|
|
object-fit: contain;
|
|
|
|
}
|
|
|
|
</style>
|