Two-Column Feature Media Grid
Headline under a hairline rule, then 2×2 grid of 3:2 rounded media tiles (glass rings, powder-blue UI snippets, chat dots) with title and muted description below; play buttons overlay video tiles.
Rebuilt from mercury.com in the Twilight Ledger style.
npx shadcn@latest add https://justyoink.it/r/twilight-ledger-0e1ecf/blocks/feature-media-grid.json
Looks exactly like mercury.com: brings its fonts and colours, namespaced so your own theme stays untouched.
npx shadcn@latest add https://justyoink.it/r/twilight-ledger-0e1ecf/mine/feature-media-grid.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.
Usage
Pass `heading` and a `tiles` array of {title, body, kind} where kind is rings, flow, form or chat. Light UI tiles show a play/pause button that toggles a 500ms blur crossfade.
components/feature-media-grid.tsx
"use client"; import { useEffect, useLayoutEffect, useRef, type CSSProperties, type ElementType, type ReactNode, type RefObject } from "react"; import { useState } from "react"; type Tile = { title: string; body: string; kind: "rings" | "flow" | "form" | "chat" }; const DEFAULT_TILES: Tile[] = [ { title: "Clear overview", body: "See every balance and every movement of funds together in one calm, simple summary.", kind: "rings" }, { title: "Smart routines", body: "Cut repetitive tasks with scheduled moves, review steps, and automatic labeling of activity.", kind: "flow" }, { title: "Access control", body: "Set spending caps, permission levels, and per-person rules for everyone on your team.", kind: "form" }, { title: "Support", body: "Real people on chat for every customer, plus a named contact for eligible plans.", kind: "chat" }, ]; function Play({ playing, onClick }: { playing: boolean; onClick: () => void }) { return ( <button type="button" onClick={onClick} aria-label={playing ? "Pause animation" : "Play animation"} className="absolute bottom-3 left-3 z-10 flex h-10 w-10 items-center justify-center rounded-pill border border-hairline bg-glass-fill text-ink-dark backdrop-blur focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent" > <svg width="14" height="14" viewBox="0 0 14 14" fill="currentColor" aria-hidden="true"> {playing ? <path d="M3 2h3v10H3zM8 2h3v10H8z" /> : <path d="M3 1.5v11l9-5.5z" />} </svg> </button> ); } function Media({ kind }: { kind: Tile["kind"] }) { const [playing, setPlaying] = useState(true); const light = kind === "flow" || kind === "form"; return ( <div className={`group/asset relative aspect-[3/2] overflow-hidden rounded-lg ${light ? "bg-powder-blue" : "bg-surface"}`}> <div className={`absolute inset-0 transition-[filter,opacity] duration-500 ease-linear ${playing ? "opacity-100 blur-0" : "opacity-60 blur-[4px]"}`}> {kind === "rings" && ( <div className="absolute inset-0 bg-[radial-gradient(70%_60%_at_50%_50%,#5b6270,#3a3c48)]"> {[28, 50, 72].map((l, i) => ( <div key={l} className="absolute top-1/2 h-[78%] aspect-square -translate-x-1/2 -translate-y-1/2 rounded-full border border-ink/30 bg-ink/10 blur-[1px] shadow-glow-soft" style={{ left: `${l}%`, opacity: i === 1 ? 1 : 0.6 }} /> ))} </div> )} {kind === "flow" && ( <div className="absolute inset-0 p-6 text-ink-dark"> <div className="w-40 rounded-lg bg-white p-4 shadow-card-lift"><p className="text-label">Team / Budget</p><p className="text-caption text-ink-dark-muted">$1,204,550.00</p></div> <div className="absolute left-[30%] top-[45%] w-full space-y-4"> {["Top up reserve to $50,000", "Sweep surplus into savings"].map((t) => ( <div key={t} className="flex items-center gap-3 rounded-lg bg-white p-4 shadow-card-lift"> <span className="h-7 w-7 rounded-md bg-canvas" /> <div><p className="text-label">{t}</p><p className="text-caption text-ink-dark-muted">Runs weekly</p></div> </div> ))} </div> </div> )} {kind === "form" && ( <div className="absolute left-1/2 top-[6%] w-[66%] -translate-x-1/2 rounded-xl bg-white p-5 text-ink-dark shadow-card-lift"> <p className="text-h3">Jordan Ellis</p> <p className="mt-4 text-caption text-ink-dark-muted">Role</p> <div className="mt-1 rounded-md border border-ink-dark-muted/30 px-2 py-1.5 text-caption">Admin</div> <ul className="mt-4 space-y-2 text-caption text-ink-dark-muted"><li>Send payments</li><li>View balances</li><li>Invite members</li></ul> </div> )} {kind === "chat" && ( <div className="absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,#454957,#363945)]"> {[110, 68, 36].map((s) => ( <div key={s} className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full border border-ink/25" style={{ width: `${s * 1.1}%`, aspectRatio: "1", boxShadow: "inset 0 0 30px rgba(255,255,255,0.12)" }} /> ))} <div className="absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 gap-2"> {[0, 1, 2].map((d) => <span key={d} className="h-2 w-2 rounded-pill bg-ink" />)} </div> </div> )} </div> {light && <Play playing={playing} onClick={() => setPlaying((p) => !p)} />} </div> ); } export default function TwoColumnFeatureMediaGrid({ heading = "Manage operations with confidence", tiles = DEFAULT_TILES }: { heading?: string; tiles?: Tile[] }) { return ( <section className="bg-canvas px-5 py-16 text-ink md:px-10"> <div className="mx-auto max-w-[1024px]"> <div className="border-t border-hairline pt-6"> <h2 className="text-h2 font-display">{heading}</h2> </div> <div className="mt-12 grid gap-x-8 gap-y-10 md:grid-cols-2"> {tiles.map((t, i) => ( <Reveal key={t.title} from="up" delay={150 + (i % 2) * 60} duration={670}> <Media kind={t.kind} /> <h3 className="mt-4 text-label">{t.title}</h3> <p className="text-body text-ink-muted">{t.body}</p> </Reveal> ))} </div> </div> </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 { useEffect, useLayoutEffect, useRef, type CSSProperties, type ElementType, type ReactNode, type RefObject } from "react"; import { useState } from "react"; type Tile = { title: string; body: string; kind: "rings" | "flow" | "form" | "chat" }; const DEFAULT_TILES: Tile[] = [ { title: "Clear overview", body: "See every balance and every movement of funds together in one calm, simple summary.", kind: "rings" }, { title: "Smart routines", body: "Cut repetitive tasks with scheduled moves, review steps, and automatic labeling of activity.", kind: "flow" }, { title: "Access control", body: "Set spending caps, permission levels, and per-person rules for everyone on your team.", kind: "form" }, { title: "Support", body: "Real people on chat for every customer, plus a named contact for eligible plans.", kind: "chat" }, ]; function Play({ playing, onClick }: { playing: boolean; onClick: () => void }) { return ( <button type="button" onClick={onClick} aria-label={playing ? "Pause animation" : "Play animation"} className="absolute bottom-3 left-3 z-10 flex h-10 w-10 items-center justify-center rounded-full border border-border bg-secondary text-muted-foreground backdrop-blur focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary" > <svg width="14" height="14" viewBox="0 0 14 14" fill="currentColor" aria-hidden="true"> {playing ? <path d="M3 2h3v10H3zM8 2h3v10H8z" /> : <path d="M3 1.5v11l9-5.5z" />} </svg> </button> ); } function Media({ kind }: { kind: Tile["kind"] }) { const [playing, setPlaying] = useState(true); const light = kind === "flow" || kind === "form"; return ( <div className={`group/asset relative aspect-[3/2] overflow-hidden rounded-2xl ${light ? "bg-foreground" : "bg-card"}`}> <div className={`absolute inset-0 transition-[filter,opacity] duration-500 ease-linear ${playing ? "opacity-100 blur-0" : "opacity-60 blur-[4px]"}`}> {kind === "rings" && ( <div className="absolute inset-0 bg-[radial-gradient(70%_60%_at_50%_50%,#5b6270,#3a3c48)]"> {[28, 50, 72].map((l, i) => ( <div key={l} className="absolute top-1/2 h-[78%] aspect-square -translate-x-1/2 -translate-y-1/2 rounded-full border border-foreground/30 bg-foreground/10 blur-[1px] shadow-twilight-glow-soft" style={{ left: `${l}%`, opacity: i === 1 ? 1 : 0.6 }} /> ))} </div> )} {kind === "flow" && ( <div className="absolute inset-0 p-6 text-muted-foreground"> <div className="w-40 rounded-2xl bg-foreground p-4 shadow-twilight-card-lift"><p className="text-twilight-label">Team / Budget</p><p className="text-twilight-caption text-muted-foreground">$1,204,550.00</p></div> <div className="absolute left-[30%] top-[45%] w-full space-y-4"> {["Top up reserve to $50,000", "Sweep surplus into savings"].map((t) => ( <div key={t} className="flex items-center gap-3 rounded-2xl bg-foreground p-4 shadow-twilight-card-lift"> <span className="h-7 w-7 rounded-lg bg-background" /> <div><p className="text-twilight-label">{t}</p><p className="text-twilight-caption text-muted-foreground">Runs weekly</p></div> </div> ))} </div> </div> )} {kind === "form" && ( <div className="absolute left-1/2 top-[6%] w-[66%] -translate-x-1/2 rounded-2xl bg-foreground p-5 text-background shadow-twilight-card-lift"> <p className="text-twilight-h3">Jordan Ellis</p> <p className="mt-4 text-twilight-caption text-muted-foreground">Role</p> <div className="mt-1 rounded-lg border border-muted-foreground/30 px-2 py-1.5 text-twilight-caption">Admin</div> <ul className="mt-4 space-y-2 text-twilight-caption text-muted-foreground"><li>Send payments</li><li>View balances</li><li>Invite members</li></ul> </div> )} {kind === "chat" && ( <div className="absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,#454957,#363945)]"> {[110, 68, 36].map((s) => ( <div key={s} className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full border border-foreground/25" style={{ width: `${s * 1.1}%`, aspectRatio: "1", boxShadow: "inset 0 0 30px rgba(255,255,255,0.12)" }} /> ))} <div className="absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 gap-2"> {[0, 1, 2].map((d) => <span key={d} className="h-2 w-2 rounded-full bg-foreground" />)} </div> </div> )} </div> {light && <Play playing={playing} onClick={() => setPlaying((p) => !p)} />} </div> ); } export default function TwoColumnFeatureMediaGrid({ heading = "Manage operations with confidence", tiles = DEFAULT_TILES }: { heading?: string; tiles?: Tile[] }) { return ( <section className="bg-background px-5 py-16 text-foreground md:px-10"> <div className="mx-auto max-w-[1024px]"> <div className="border-t border-border pt-6"> <h2 className="text-twilight-h2 font-sans">{heading}</h2> </div> <div className="mt-12 grid gap-x-8 gap-y-10 md:grid-cols-2"> {tiles.map((t, i) => ( <Reveal key={t.title} from="up" delay={150 + (i % 2) * 60} duration={670}> <Media kind={t.kind} /> <h3 className="mt-4 text-twilight-label">{t.title}</h3> <p className="text-twilight-body text-muted-foreground">{t.body}</p> </Reveal> ))} </div> </div> </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: passedNo serious accessibility problems (axe-core): readable contrast, labelled buttons and images.
- Responsive: passedRenders at phone (390px), tablet (768px) and desktop width without sideways scrolling.
- Dark mode: not passedElements must meet minimum color contrast ratio thresholds (10 elements)
- Themeable: passedUses design tokens rather than hard-coded colours, so it follows your theme cleanly.
- Animates cleanly: passedIts animation plays and finishes with everything visible, and it stays still for people who turn on reduced motion.