Spaces:
Running
Running
File size: 2,963 Bytes
e07925b |
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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
<script lang="ts">
import type { GalleryImage, GalleryVideo } from "./types";
export let value: (GalleryImage | GalleryVideo)[] | null;
export let type: "gallery" | "table";
export let selected = false;
</script>
<div
class="container"
class:table={type === "table"}
class:gallery={type === "gallery"}
class:selected
>
{#if value && value.length > 0}
<div class="images-wrapper">
{#each value.slice(0, 3) as item}
{#if "image" in item && item.image}
<div class="image-container">
<img src={item.image.url} alt={item.caption || ""} />
{#if item.caption}
<span class="caption">{item.caption}</span>
{/if}
</div>
{:else if "video" in item && item.video}
<div class="image-container">
<video
src={item.video.url}
controls={false}
muted
preload="metadata"
/>
{#if item.caption}
<span class="caption">{item.caption}</span>
{/if}
</div>
{/if}
{/each}
{#if value.length > 3}
<div class="more-indicator">…</div>
{/if}
</div>
{/if}
</div>
<style>
.container {
border-radius: var(--radius-lg);
overflow: hidden;
}
.container.selected {
border: 2px solid var(--border-color-accent);
}
.images-wrapper {
display: flex;
gap: var(--spacing-sm);
}
.container.table .images-wrapper {
flex-direction: row;
align-items: center;
padding: var(--spacing-sm);
border: 1px solid var(--border-color-primary);
border-radius: var(--radius-lg);
background: var(--background-fill-secondary);
}
.container.gallery .images-wrapper {
flex-direction: row;
gap: 0;
}
.image-container {
position: relative;
flex-shrink: 0;
}
.container.table .image-container {
width: var(--size-12);
height: var(--size-12);
}
.container.gallery .image-container {
width: var(--size-20);
height: var(--size-20);
margin-left: calc(-1 * var(--size-8));
}
.container.gallery .image-container:first-child {
margin-left: 0;
}
.more-indicator {
display: flex;
align-items: center;
justify-content: center;
font-size: var(--text-lg);
font-weight: bold;
color: var(--border-color-primary);
}
.container.table .more-indicator {
width: var(--size-12);
height: var(--size-12);
}
.container.gallery .more-indicator {
width: var(--size-20);
height: var(--size-20);
margin-left: calc(-1 * var(--size-8));
margin-right: calc(-1 * var(--size-6));
}
.image-container img,
.image-container video {
width: 100%;
height: 100%;
object-fit: cover;
border-radius: var(--radius-md);
}
.caption {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.7);
color: white;
padding: var(--spacing-xs);
font-size: var(--text-xs);
text-align: center;
border-radius: 0 0 var(--radius-md) var(--radius-md);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.container.table .caption {
display: none;
}
</style>
|