hc99's picture
Add files using upload-large-folder tool
2b06d1d verified
raw
history blame
1.17 kB
<script lang="ts">
import { playable } from "../shared";
import { onMount } from "svelte";
export let type: "gallery" | "table";
export let selected = false;
export let value: string;
export let samples_dir: string;
let video: HTMLVideoElement;
async function init(): Promise<void> {
video.muted = true;
video.playsInline = true;
video.controls = false;
video.setAttribute("muted", "");
await video.play();
video.pause();
}
onMount(() => {
init();
});
</script>
{#if playable()}
<video
muted
playsinline
bind:this={video}
class:table={type === "table"}
class:gallery={type === "gallery"}
class:selected
on:mouseover={video.play}
on:mouseout={video.pause}
src={samples_dir + value}
/>
{:else}
<div>{value}</div>
{/if}
<style>
video {
flex: none;
border: 2px solid var(--border-color-primary);
border-radius: var(--radius-lg);
max-width: none;
}
video:hover,
video.selected {
border-color: var(--border-color-accent);
}
.table {
margin: 0 auto;
width: var(--size-20);
height: var(--size-20);
object-fit: cover;
}
.gallery {
max-height: var(--size-20);
object-fit: cover;
}
</style>