@@ -225,52 +225,58 @@ export function Slideshow({ slides, playOnInit = true, interval = 5000, classNam
225225 resetAutoplay ( ) ;
226226 } }
227227 >
228- < div className = "relative overflow-hidden" >
229- { /* White Bar - Current Index Indicator / Progress Bar */ }
230- < div
231- className = { clsx (
232- 'absolute h-0.5 bg-[var(--slideshow-pagination,hsl(var(--background)))]' ,
233- 'opacity-0 fill-mode-forwards' ,
234- isPlaying ? 'running' : 'paused' ,
235- index === selectedIndex
236- ? 'opacity-100 ease-linear animate-in slide-in-from-left'
237- : 'ease-out animate-out fade-out' ,
238- ) }
239- key = { `progress-${ playCount } ` } // Force the animation to restart when pressing "Play", to match animation with embla's autoplay timer
240- style = { {
241- animationDuration : index === selectedIndex ? `${ interval } ms` : '200ms' ,
242- width : `${ 150 / slides . length } px` ,
243- } }
244- />
245- { /* Grey Bar BG */ }
246- < div
247- className = "h-0.5 bg-[var(--slideshow-pagination,hsl(var(--background)))] opacity-30"
248- style = { { width : `${ 150 / slides . length } px` } }
249- />
250- </ div >
228+ { slides . length > 1 && (
229+ < div className = "relative overflow-hidden" >
230+ { /* White Bar - Current Index Indicator / Progress Bar */ }
231+ < div
232+ className = { clsx (
233+ 'absolute h-0.5 bg-[var(--slideshow-pagination,hsl(var(--background)))]' ,
234+ 'opacity-0 fill-mode-forwards' ,
235+ isPlaying ? 'running' : 'paused' ,
236+ index === selectedIndex
237+ ? 'opacity-100 ease-linear animate-in slide-in-from-left'
238+ : 'ease-out animate-out fade-out' ,
239+ ) }
240+ key = { `progress-${ playCount } ` } // Force the animation to restart when pressing "Play", to match animation with embla's autoplay timer
241+ style = { {
242+ animationDuration : index === selectedIndex ? `${ interval } ms` : '200ms' ,
243+ width : `${ 150 / slides . length } px` ,
244+ } }
245+ />
246+ { /* Grey Bar BG */ }
247+ < div
248+ className = "h-0.5 bg-[var(--slideshow-pagination,hsl(var(--background)))] opacity-30"
249+ style = { { width : `${ 150 / slides . length } px` } }
250+ />
251+ </ div >
252+ ) }
251253 </ button >
252254 ) ;
253255 } ) }
254256
255257 { /* Carousel Count - "01/03" */ }
256- < span className = "ml-auto mr-3 mt-px font-[family-name:var(--slideshow-number-font-family,var(--font-family-mono))] text-sm text-[var(--slideshow-number,hsl(var(--background)))]" >
257- { selectedIndex + 1 < 10 ? `0${ selectedIndex + 1 } ` : selectedIndex + 1 } /
258- { slides . length < 10 ? `0${ slides . length } ` : slides . length }
259- </ span >
258+ { slides . length > 1 && (
259+ < span className = "ml-auto mr-3 mt-px font-[family-name:var(--slideshow-number-font-family,var(--font-family-mono))] text-sm text-[var(--slideshow-number,hsl(var(--background)))]" >
260+ { selectedIndex + 1 < 10 ? `0${ selectedIndex + 1 } ` : selectedIndex + 1 } /
261+ { slides . length < 10 ? `0${ slides . length } ` : slides . length }
262+ </ span >
263+ ) }
260264
261265 { /* Stop / Start Button */ }
262- < button
263- aria-label = { isPlaying ? 'Pause' : 'Play' }
264- className = "flex h-7 w-7 items-center justify-center rounded-lg border border-[var(--slideshow-play-border,hsl(var(--contrast-300)/50%))] text-[var(--slideshow-play-text,hsl(var(--background)))] ring-[var(--slideshow-focus)] transition-opacity duration-300 hover:border-[var(--slideshow-play-border-hover,hsl(var(--contrast-300)/80%))] focus-visible:outline-0 focus-visible:ring-2"
265- onClick = { toggleAutoplay }
266- type = "button"
267- >
268- { isPlaying ? (
269- < Pause className = "pointer-events-none" size = { 16 } strokeWidth = { 1.5 } />
270- ) : (
271- < Play className = "pointer-events-none" size = { 16 } strokeWidth = { 1.5 } />
272- ) }
273- </ button >
266+ { slides . length > 1 && (
267+ < button
268+ aria-label = { isPlaying ? 'Pause' : 'Play' }
269+ className = "flex h-7 w-7 items-center justify-center rounded-lg border border-[var(--slideshow-play-border,hsl(var(--contrast-300)/50%))] text-[var(--slideshow-play-text,hsl(var(--background)))] ring-[var(--slideshow-focus)] transition-opacity duration-300 hover:border-[var(--slideshow-play-border-hover,hsl(var(--contrast-300)/80%))] focus-visible:outline-0 focus-visible:ring-2"
270+ onClick = { toggleAutoplay }
271+ type = "button"
272+ >
273+ { isPlaying ? (
274+ < Pause className = "pointer-events-none" size = { 16 } strokeWidth = { 1.5 } />
275+ ) : (
276+ < Play className = "pointer-events-none" size = { 16 } strokeWidth = { 1.5 } />
277+ ) }
278+ </ button >
279+ ) }
274280 </ div >
275281 </ section >
276282 ) ;
0 commit comments