Spaces:
Paused
Paused
File size: 898 Bytes
785ee56 |
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 |
<script lang="ts">
import type { Data } from "../../app";
export let data: Data | Array<Data>;
const isBlob = (message: string | Blob): message is Blob => {
return message instanceof Blob;
};
</script>
<!-- if its an array recursively render for each children of the array -->
{#if Array.isArray(data)}
{#each data as el}
<svelte:self data={el} />
<div class="divider" />
{/each}
{:else if !!data && isBlob(data)}
{#if data.type.startsWith("image")}
<div class="mx-auto border-2 border-neutral-focus w-full">
<img class="p-1 w-fit" alt="generated" src={URL.createObjectURL(data)} />
</div>
{:else if data.type.startsWith("audio")}
<audio controls src={URL.createObjectURL(data)} />
{:else}
<p class="text-mono text-light w-full">blob type unknown</p>
{/if}
{:else if !!data}
<p class="text-mono mx-auto text-light w-full">{data}</p>
{/if}
|