File size: 2,027 Bytes
0ad74ed |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
<script lang="ts">
import type { I18nFormatter } from "@gradio/utils";
import { Upload as UploadIcon, ImagePaste } from "@gradio/icons";
import { inject } from "./utils/parse_placeholder";
export let type:
| "video"
| "image"
| "audio"
| "file"
| "csv"
| "clipboard"
| "gallery" = "file";
export let i18n: I18nFormatter;
export let message: string | undefined = undefined;
export let mode: "full" | "short" = "full";
export let hovered = false;
export let placeholder: string | undefined = undefined;
const defs = {
image: "upload_text.drop_image",
video: "upload_text.drop_video",
audio: "upload_text.drop_audio",
file: "upload_text.drop_file",
csv: "upload_text.drop_csv",
gallery: "upload_text.drop_gallery",
clipboard: "upload_text.paste_clipboard"
};
$: [heading, paragraph] = placeholder ? inject(placeholder) : [false, false];
</script>
<div class="wrap">
<span class="icon-wrap" class:hovered>
{#if type === "clipboard"}
<ImagePaste />
{:else}
<UploadIcon />
{/if}
</span>
{#if heading || paragraph}
{#if heading}
<h2>{heading}</h2>
{/if}
{#if paragraph}
<p>{paragraph}</p>
{/if}
{:else}
{i18n(defs[type] || defs.file)}
{#if mode !== "short"}
<span class="or">- {i18n("common.or")} -</span>
{message || i18n("upload_text.click_to_upload")}
{/if}
{/if}
</div>
<style>
h2 {
font-size: var(--text-xl) !important;
}
p,
h2 {
white-space: pre-line;
}
.wrap {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-height: var(--size-60);
color: var(--block-label-text-color);
line-height: var(--line-md);
height: 100%;
padding-top: var(--size-3);
text-align: center;
margin: auto var(--spacing-lg);
}
.or {
color: var(--body-text-color-subdued);
display: flex;
}
.icon-wrap {
width: 30px;
margin-bottom: var(--spacing-lg);
}
@media (--screen-md) {
.wrap {
font-size: var(--text-lg);
}
}
.hovered {
color: var(--color-accent);
}
</style>
|