adf0d17497
publish / version_or_publish (push) Has been cancelled
storybook-build / changes (push) Has been cancelled
storybook-build / :storybook-build (push) Has been cancelled
Sync Gradio Skills to Hugging Face / sync-skills (push) Has been cancelled
functional / changes (push) Has been cancelled
functional / build-frontend (push) Has been cancelled
functional / functional-test-SSR=false (push) Has been cancelled
functional / functional-reload (push) Has been cancelled
js / changes (push) Has been cancelled
js / js-test (push) Has been cancelled
docs-build / changes (push) Has been cancelled
docs-build / docs-build (push) Has been cancelled
docs-build / website-build (push) Has been cancelled
functional / functional-test-SSR=true (push) Has been cancelled
hygiene / hygiene-test (push) Has been cancelled
python / changes (push) Has been cancelled
python / build (push) Has been cancelled
python / test-ubuntu-latest-flaky (push) Has been cancelled
python / test-ubuntu-latest-not-flaky (push) Has been cancelled
python / test-windows-latest-flaky (push) Has been cancelled
python / test-windows-latest-not-flaky (push) Has been cancelled
62 lines
1.4 KiB
Svelte
62 lines
1.4 KiB
Svelte
<script lang="ts">
|
|
import {
|
|
BlockLabel,
|
|
Empty,
|
|
IconButton,
|
|
IconButtonWrapper,
|
|
DownloadLink
|
|
} from "@gradio/atoms";
|
|
import { Download } from "@gradio/icons";
|
|
|
|
import { Image as ImageIcon } from "@gradio/icons";
|
|
import { type FileData } from "@gradio/client";
|
|
import type { I18nFormatter } from "@gradio/utils";
|
|
|
|
export let value: null | FileData;
|
|
export let label: string | undefined = undefined;
|
|
export let show_label: boolean;
|
|
export let show_download_button = true;
|
|
export let selectable = false;
|
|
export let i18n: I18nFormatter;
|
|
</script>
|
|
|
|
<BlockLabel
|
|
{show_label}
|
|
Icon={ImageIcon}
|
|
label={label || i18n("image.image")}
|
|
/>
|
|
{#if value === null || !value.url}
|
|
<Empty unpadded_box={true} size="large"><ImageIcon /></Empty>
|
|
{:else}
|
|
<IconButtonWrapper>
|
|
{#if show_download_button}
|
|
<DownloadLink href={value.url} download={value.orig_name || "image"}>
|
|
<IconButton Icon={Download} label={i18n("common.download")} />
|
|
</DownloadLink>
|
|
{/if}
|
|
</IconButtonWrapper>
|
|
<button>
|
|
<div class:selectable class="image-container">
|
|
<img src={value.url} alt="" loading="lazy" />
|
|
</div>
|
|
</button>
|
|
{/if}
|
|
|
|
<style>
|
|
.image-container {
|
|
height: 100%;
|
|
}
|
|
.image-container :global(img),
|
|
button {
|
|
width: var(--size-full);
|
|
height: var(--size-full);
|
|
object-fit: scale-down;
|
|
display: block;
|
|
border-radius: var(--radius-lg);
|
|
}
|
|
|
|
.selectable {
|
|
cursor: crosshair;
|
|
}
|
|
</style>
|