Overlays & feedback / Progress bars
Segmented Slideshow Progress Bars
Row of ten thin 2px light-grey bars right-aligned under the hero; the active one fills black via scaleX.
Rebuilt from thisislandscape.com in the Gallery White Editorial style.
npx shadcn@latest add https://yoink-app.fly.dev/r/gallery-white-editorial/blocks/slideshow-progress-bars.json
Looks exactly like thisislandscape.com: brings its fonts and colours, namespaced so your own theme stays untouched.
npx shadcn@latest add https://yoink-app.fly.dev/r/gallery-white-editorial/mine/slideshow-progress-bars.json
Restyled to your project: uses your shadcn colours, fonts and radius, so it matches the rest of your app. Layout, type sizes and motion stay as designed.
Images3 in this component. Swap any for a library image or one of your own.All images in this style →
Usage
Props: slides (title, caption, image), segments (default 10) and duration in ms per slide. The active bar fills left-to-right via scaleX, then advances to the next bar and slide.
components/slideshow-progress-bars.tsx
"use client"; import { useLayoutEffect, useRef, type CSSProperties, type ElementType, type ReactNode, type RefObject } from "react"; import { useEffect, useState } from "react"; type Slide = { title: string; caption: string; image: string }; export default function SegmentedSlideshowProgress({ slides = [ { title: "Harborline", caption: "Doubling repeat bookings for a regional ferry and coastal travel network.", image: "https://yoink-app.fly.dev/stock/landscape-4.jpg" }, { title: "Altura", caption: "Shaping a calmer identity for a mountain lodge collective.", image: "https://yoink-app.fly.dev/stock/landscape-2.jpg" }, { title: "Kitefield", caption: "Launching a warm, tactile brand for a small-batch roastery.", image: "https://yoink-app.fly.dev/stock/food-1.jpg" }, ], segments = 10, duration = 6000, }: { slides?: Slide[]; segments?: number; duration?: number; }) { const [active, setActive] = useState(0); const [run, setRun] = useState(0); useEffect(() => { const t = setTimeout(() => { setActive((a) => (a + 1) % segments); setRun((r) => r + 1); }, duration); return () => clearTimeout(t); }, [active, duration, segments]); const slide = slides[active % slides.length]; return ( <section className="bg-canvas px-4 pb-8 font-sans text-ink"> <Reveal from="none" duration={1000}> <div className="grid gap-4 md:grid-cols-2"> <div className="relative aspect-square overflow-hidden bg-placeholder"> <img key={"a" + run} src={slide.image} alt={slide.title} width={800} height={800} className="h-full w-full animate-[fadein_600ms_ease-out] object-cover" /> </div> <div className="relative hidden aspect-square overflow-hidden bg-[radial-gradient(60%_50%_at_30%_20%,#f59e0b,transparent),radial-gradient(70%_60%_at_80%_70%,#e11d48,transparent)] bg-[#b91c1c] md:block"> <div className="absolute inset-0 flex items-center justify-center text-5xl font-medium text-[#fcd34d]">{slide.title}</div> </div> </div> <div className="mt-3 flex flex-col gap-4 md:flex-row md:justify-between"> <p className="max-w-xl text-body font-medium text-ink-muted"> <span className="text-ink">{slide.title}</span> {slide.caption} </p> <div className="flex items-start gap-[6px] md:w-1/2 md:justify-end" role="progressbar" aria-label="Slideshow progress" aria-valuemin={0} aria-valuemax={segments} aria-valuenow={active + 1}> {Array.from({ length: segments }).map((_, i) => ( <span key={i} className="relative block h-[2px] w-6 overflow-hidden bg-placeholder"> <span key={i === active ? run : 0} className="absolute inset-0 origin-left bg-ink" style={{ transform: i < active ? "scaleX(1)" : "scaleX(0)", animation: i === active ? `fillbar ${duration}ms linear forwards` : undefined, }} /> </span> ))} </div> </div> </Reveal> <style>{`@keyframes fillbar{from{transform:scaleX(0)}to{transform:scaleX(1)}}@keyframes fadein{from{opacity:0}to{opacity:1}}@media (prefers-reduced-motion:reduce){*{animation-duration:0.01ms!important}}`}</style> </section> ); } // ---- Yoink motion (inlined, no dependencies): Reveal ---- const YK_EASE = "cubic-bezier(0.16, 1, 0.3, 1)"; const useYkLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect; function ykReducedMotion(): boolean { return typeof window !== "undefined" && !!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches; } // "idle": untouched (visible) · "hidden": waiting below the fold · "shown": play the entrance. // Content is only hidden once we know we can show it again (IntersectionObserver exists, motion allowed, // and there is a box to watch), and a safety net reveals anything on screen that is still hidden. type YkRevealState = "idle" | "hidden" | "shown"; function useYkReveal(ref: RefObject<Element | null>, once = true): YkRevealState { const [state, setState] = useState<YkRevealState>("idle"); useYkLayoutEffect(() => { const el = ref.current; if (!el || ykReducedMotion() || typeof IntersectionObserver === "undefined") return; // watch the element's own box, or its children when it has none (display: contents) const boxes = () => (getComputedStyle(el).display === "contents" ? Array.from(el.children) : [el]); const onScreen = (t: Element) => { const r = t.getBoundingClientRect(); return (r.width > 0 || r.height > 0) && r.bottom > 0 && r.right > 0 && r.top < window.innerHeight && r.left < window.innerWidth; }; if (!boxes().some((t) => t.getBoundingClientRect().width > 0 || t.getBoundingClientRect().height > 0)) return; // e.g. hidden at mount: leave it visible let shown = false; const show = (v: boolean) => { if (v !== shown) (shown = v), setState(v ? "shown" : "hidden"); }; setState("hidden"); const inView = new Set<Element>(); const io = new IntersectionObserver((entries) => { for (const e of entries) { if (e.isIntersecting) inView.add(e.target); else inView.delete(e.target); } if (inView.size) { show(true); if (once) io.disconnect(); } else if (!once) show(false); }); const watched = new Set<Element>(); const watch = () => boxes().forEach((t) => !watched.has(t) && (watched.add(t), io.observe(t))); watch(); // safety net: styles that land after mount (display: contents) get watched too, and nothing // stays hidden for more than a moment while it is actually on screen const start = Date.now(); const net = setInterval(() => { if (shown) return once && clearInterval(net); watch(); if (Date.now() - start > 2400 && boxes().some(onScreen)) show(true); }, 600); return () => { io.disconnect(); clearInterval(net); }; }, [once]); return state; } type YkRevealFrom = "up" | "down" | "left" | "right" | "scale" | "blur" | "none"; /** Fades content in as it scrolls into view. */ function Reveal({ children, from = "up", delay = 0, duration = 700, distance = 24, once = true, as = "div", className, style, }: { children?: ReactNode; from?: YkRevealFrom; delay?: number; duration?: number; distance?: number; once?: boolean; as?: ElementType; className?: string; style?: CSSProperties; }) { const Tag = as; const ref = useRef<HTMLElement>(null); const state = useYkReveal(ref, once); const hidden = state === "hidden"; const offset = { up: `translate3d(0, ${distance}px, 0)`, down: `translate3d(0, ${-distance}px, 0)`, left: `translate3d(${-distance}px, 0, 0)`, right: `translate3d(${distance}px, 0, 0)`, scale: "scale(0.94)", blur: `translate3d(0, ${distance / 2}px, 0)`, none: "none", }[from]; const t = `${duration}ms ${YK_EASE} ${delay}ms`; return ( <Tag ref={ref} className={className} style={{ ...style, ...(hidden && { opacity: 0, transform: offset, filter: from === "blur" ? "blur(12px)" : undefined }), ...(state === "shown" && { transition: `opacity ${t}, transform ${t}, filter ${t}` }), }} > {children} </Tag> ); }"use client"; import { useLayoutEffect, useRef, type CSSProperties, type ElementType, type ReactNode, type RefObject } from "react"; import { useEffect, useState } from "react"; type Slide = { title: string; caption: string; image: string }; export default function SegmentedSlideshowProgress({ slides = [ { title: "Harborline", caption: "Doubling repeat bookings for a regional ferry and coastal travel network.", image: "https://yoink-app.fly.dev/stock/landscape-4.jpg" }, { title: "Altura", caption: "Shaping a calmer identity for a mountain lodge collective.", image: "https://yoink-app.fly.dev/stock/landscape-2.jpg" }, { title: "Kitefield", caption: "Launching a warm, tactile brand for a small-batch roastery.", image: "https://yoink-app.fly.dev/stock/food-1.jpg" }, ], segments = 10, duration = 6000, }: { slides?: Slide[]; segments?: number; duration?: number; }) { const [active, setActive] = useState(0); const [run, setRun] = useState(0); useEffect(() => { const t = setTimeout(() => { setActive((a) => (a + 1) % segments); setRun((r) => r + 1); }, duration); return () => clearTimeout(t); }, [active, duration, segments]); const slide = slides[active % slides.length]; return ( <section className="bg-background px-4 pb-8 font-sans text-foreground"> <Reveal from="none" duration={1000}> <div className="grid gap-4 md:grid-cols-2"> <div className="relative aspect-square overflow-hidden bg-foreground"> <img key={"a" + run} src={slide.image} alt={slide.title} width={800} height={800} className="h-full w-full animate-[fadein_600ms_ease-out] object-cover" /> </div> <div className="relative hidden aspect-square overflow-hidden bg-[radial-gradient(60%_50%_at_30%_20%,#f59e0b,transparent),radial-gradient(70%_60%_at_80%_70%,#e11d48,transparent)] bg-[#b91c1c] md:block"> <div className="absolute inset-0 flex items-center justify-center text-5xl font-medium text-[#fcd34d]">{slide.title}</div> </div> </div> <div className="mt-3 flex flex-col gap-4 md:flex-row md:justify-between"> <p className="max-w-xl text-gallery-body font-medium text-muted-foreground"> <span className="text-foreground">{slide.title}</span> {slide.caption} </p> <div className="flex items-start gap-[6px] md:w-1/2 md:justify-end" role="progressbar" aria-label="Slideshow progress" aria-valuemin={0} aria-valuemax={segments} aria-valuenow={active + 1}> {Array.from({ length: segments }).map((_, i) => ( <span key={i} className="relative block h-[2px] w-6 overflow-hidden bg-foreground"> <span key={i === active ? run : 0} className="absolute inset-0 origin-left bg-foreground" style={{ transform: i < active ? "scaleX(1)" : "scaleX(0)", animation: i === active ? `fillbar ${duration}ms linear forwards` : undefined, }} /> </span> ))} </div> </div> </Reveal> <style>{`@keyframes fillbar{from{transform:scaleX(0)}to{transform:scaleX(1)}}@keyframes fadein{from{opacity:0}to{opacity:1}}@media (prefers-reduced-motion:reduce){*{animation-duration:0.01ms!important}}`}</style> </section> ); } // ---- Yoink motion (inlined, no dependencies): Reveal ---- const YK_EASE = "cubic-bezier(0.16, 1, 0.3, 1)"; const useYkLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect; function ykReducedMotion(): boolean { return typeof window !== "undefined" && !!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches; } // "idle": untouched (visible) · "hidden": waiting below the fold · "shown": play the entrance. // Content is only hidden once we know we can show it again (IntersectionObserver exists, motion allowed, // and there is a box to watch), and a safety net reveals anything on screen that is still hidden. type YkRevealState = "idle" | "hidden" | "shown"; function useYkReveal(ref: RefObject<Element | null>, once = true): YkRevealState { const [state, setState] = useState<YkRevealState>("idle"); useYkLayoutEffect(() => { const el = ref.current; if (!el || ykReducedMotion() || typeof IntersectionObserver === "undefined") return; // watch the element's own box, or its children when it has none (display: contents) const boxes = () => (getComputedStyle(el).display === "contents" ? Array.from(el.children) : [el]); const onScreen = (t: Element) => { const r = t.getBoundingClientRect(); return (r.width > 0 || r.height > 0) && r.bottom > 0 && r.right > 0 && r.top < window.innerHeight && r.left < window.innerWidth; }; if (!boxes().some((t) => t.getBoundingClientRect().width > 0 || t.getBoundingClientRect().height > 0)) return; // e.g. hidden at mount: leave it visible let shown = false; const show = (v: boolean) => { if (v !== shown) (shown = v), setState(v ? "shown" : "hidden"); }; setState("hidden"); const inView = new Set<Element>(); const io = new IntersectionObserver((entries) => { for (const e of entries) { if (e.isIntersecting) inView.add(e.target); else inView.delete(e.target); } if (inView.size) { show(true); if (once) io.disconnect(); } else if (!once) show(false); }); const watched = new Set<Element>(); const watch = () => boxes().forEach((t) => !watched.has(t) && (watched.add(t), io.observe(t))); watch(); // safety net: styles that land after mount (display: contents) get watched too, and nothing // stays hidden for more than a moment while it is actually on screen const start = Date.now(); const net = setInterval(() => { if (shown) return once && clearInterval(net); watch(); if (Date.now() - start > 2400 && boxes().some(onScreen)) show(true); }, 600); return () => { io.disconnect(); clearInterval(net); }; }, [once]); return state; } type YkRevealFrom = "up" | "down" | "left" | "right" | "scale" | "blur" | "none"; /** Fades content in as it scrolls into view. */ function Reveal({ children, from = "up", delay = 0, duration = 700, distance = 24, once = true, as = "div", className, style, }: { children?: ReactNode; from?: YkRevealFrom; delay?: number; duration?: number; distance?: number; once?: boolean; as?: ElementType; className?: string; style?: CSSProperties; }) { const Tag = as; const ref = useRef<HTMLElement>(null); const state = useYkReveal(ref, once); const hidden = state === "hidden"; const offset = { up: `translate3d(0, ${distance}px, 0)`, down: `translate3d(0, ${-distance}px, 0)`, left: `translate3d(${-distance}px, 0, 0)`, right: `translate3d(${distance}px, 0, 0)`, scale: "scale(0.94)", blur: `translate3d(0, ${distance / 2}px, 0)`, none: "none", }[from]; const t = `${duration}ms ${YK_EASE} ${delay}ms`; return ( <Tag ref={ref} className={className} style={{ ...style, ...(hidden && { opacity: 0, transform: offset, filter: from === "blur" ? "blur(12px)" : undefined }), ...(state === "shown" && { transition: `opacity ${t}, transform ${t}, filter ${t}` }), }} > {children} </Tag> ); }
Quality checks
Automated, in a real browser · 4d ago- Accessible: not passedElements must meet minimum color contrast ratio thresholds (1 element)
- Responsive: passedRenders at phone (390px), tablet (768px) and desktop width without sideways scrolling.
- Dark mode: passedStill readable when installed in your theme and switched to dark mode.
- Themeable: not passed2 hard-coded colours (bg-[#b91c1c], text-[#fcd34d]). These ignore the theme and break dark mode.
- Animates cleanly: passedIts animation plays and finishes with everything visible, and it stays still for people who turn on reduced motion.