@r2digisolutions/components 0.25.7 → 0.25.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,8 @@
7
7
 
8
8
  export interface GalleryImage {
9
9
  id: string;
10
- src: string;
10
+ src: string; // grid / preview (thumb)
11
+ fullSrc?: string; // lightbox main image (full). Defaults to src
11
12
  alt: string;
12
13
  caption?: string;
13
14
  }
@@ -40,11 +41,13 @@
40
41
  let open = $state(false);
41
42
  let index = $state(0);
42
43
  let failed = $state<Record<string, boolean>>({});
44
+ let usedFallback = $state<Record<string, boolean>>({});
43
45
 
44
46
  const lightboxImages = $derived(
45
47
  images.map(
46
48
  (img): LightboxImage => ({
47
- src: img.src,
49
+ src: img.fullSrc ?? img.src,
50
+ thumbSrc: img.fullSrc ? img.src : undefined,
48
51
  alt: img.alt,
49
52
  caption: img.caption
50
53
  })
@@ -83,6 +86,18 @@
83
86
  failed = { ...failed, [id]: true };
84
87
  }
85
88
 
89
+ function onImgError(img: GalleryImage) {
90
+ if (img.fullSrc && !usedFallback[img.id]) {
91
+ usedFallback = { ...usedFallback, [img.id]: true };
92
+ return;
93
+ }
94
+ markFailed(img.id);
95
+ }
96
+
97
+ function tileSrc(img: GalleryImage) {
98
+ return usedFallback[img.id] && img.fullSrc ? img.fullSrc : img.src;
99
+ }
100
+
86
101
  const heroGridClass = $derived.by(() => {
87
102
  const n = heroVisible.length;
88
103
  if (n <= 1) return 'grid-cols-1';
@@ -115,12 +130,12 @@
115
130
  </div>
116
131
  {:else}
117
132
  <img
118
- src={img.src}
133
+ src={tileSrc(img)}
119
134
  alt={img.alt}
120
- loading="eager"
135
+ loading="lazy"
121
136
  decoding="async"
122
137
  class="h-full w-full object-cover transition duration-300 group-hover:scale-[1.03]"
123
- onerror={() => markFailed(img.id)}
138
+ onerror={() => onImgError(img)}
124
139
  />
125
140
  {/if}
126
141
 
@@ -158,12 +173,12 @@
158
173
  </div>
159
174
  {:else}
160
175
  <img
161
- src={img.src}
176
+ src={tileSrc(img)}
162
177
  alt={img.alt}
163
- loading="eager"
178
+ loading="lazy"
164
179
  decoding="async"
165
180
  class="h-full w-full object-cover transition duration-300 group-hover:scale-[1.03]"
166
- onerror={() => markFailed(img.id)}
181
+ onerror={() => onImgError(img)}
167
182
  />
168
183
  {/if}
169
184
  <div
@@ -232,13 +247,13 @@
232
247
  </div>
233
248
  {:else}
234
249
  <img
235
- src={img.src}
250
+ src={tileSrc(img)}
236
251
  alt={img.alt}
237
- loading="eager"
252
+ loading="lazy"
238
253
  decoding="async"
239
254
  class="w-full object-cover transition duration-300 group-hover:scale-[1.02]"
240
255
  style:aspect-ratio={i % 3 === 0 ? '4/5' : i % 3 === 1 ? '1/1' : '5/4'}
241
- onerror={() => markFailed(img.id)}
256
+ onerror={() => onImgError(img)}
242
257
  />
243
258
  {/if}
244
259
  <span
@@ -2,6 +2,7 @@ import type { Snippet } from 'svelte';
2
2
  export interface GalleryImage {
3
3
  id: string;
4
4
  src: string;
5
+ fullSrc?: string;
5
6
  alt: string;
6
7
  caption?: string;
7
8
  }
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
2
  export interface LightboxImage {
3
3
  src: string;
4
+ thumbSrc?: string; // filmstrip; defaults to src
4
5
  alt?: string;
5
6
  caption?: string;
6
7
  }
@@ -565,7 +566,7 @@
565
566
  ]}
566
567
  >
567
568
  <img
568
- src={img.src}
569
+ src={img.thumbSrc ?? img.src}
569
570
  alt=""
570
571
  class="h-14 w-[4.5rem] object-cover sm:h-16 sm:w-24"
571
572
  draggable="false"
@@ -1,5 +1,6 @@
1
1
  export interface LightboxImage {
2
2
  src: string;
3
+ thumbSrc?: string;
3
4
  alt?: string;
4
5
  caption?: string;
5
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@r2digisolutions/components",
3
- "version": "0.25.7",
3
+ "version": "0.25.8",
4
4
  "private": false,
5
5
  "description": "R2DigiSolutions Svelte 5 component library — Atomic Design, Tailwind 4, Light/Dark mode",
6
6
  "license": "MIT",