Cards & content / Media & mockups
Frosted Desktop Booking Mockup
A grainy full-bleed photo stage with a macOS menu bar and a frosted-glass overlay (backdrop blur 30px, saturate 1.8) holding a Safari window. Inside is a three-column booking UI: host info with duration segmented control, month calendar with a dark selected day and gray available days, and a time-slot list. A round dark floating orb sits at the top-right.
Rebuilt from cal.com in the Warm Paper Calendar style.
Looks exactly like cal.com: brings its fonts and colours, namespaced so your own theme stays untouched.
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
Props: imageSrc, hostName, title, description, url, caption, logos (string array). Click dates, slots and durations to change selection; renders standalone with defaults.
components/floating-browser-booking-mockup.tsx
"use client"; import { useEffect, useLayoutEffect, useRef, type CSSProperties, type ElementType, type ReactNode, type RefObject } from "react"; import { useState } from "react"; export default function FrostedDesktopBookingMockup({ imageSrc = "https://yoink-app.fly.dev/stock/abstract-6.jpg", hostName = "Alex Morgan", title = "Book a Quick Chat", description = "Pick a time that suits you and we will send a calendar invite right away. No back and forth needed.", url = "schedula.app/alex", caption = "Trusted by fast-moving teams for scheduling", logos = ["Northwind", "Altura", "Lumen", "Kitefield", "Brightpath", "Orbital", "Fernhill", "Quill", "Marlow", "Tidewater", "Harbor", "Cobalt"], }: { imageSrc?: string; hostName?: string; title?: string; description?: string; url?: string; caption?: string; logos?: string[]; }) { const [day, setDay] = useState(25); const [slot, setSlot] = useState(0); const [dur, setDur] = useState(0); const slots = ["9:00am", "9:15am", "9:30am", "10:00am", "10:15am"]; const avail = [26, 27, 30, 25]; const cells: (number | null)[] = []; for (let i = 1; i <= 30; i++) cells.push(i); return ( <section className="bg-canvas px-4 py-10 font-sans text-ink"> <div className="relative mx-auto max-w-[1292px] overflow-hidden rounded-xl bg-panel"> <img src={imageSrc} alt="" width={1600} height={1067} className="absolute inset-0 h-full w-full object-cover grayscale" /> <Grain opacity={0.2} /> <div className="relative flex items-center gap-5 bg-canvas/70 px-4 py-1.5 text-caption text-ink-deep backdrop-blur-[30px] backdrop-saturate-[1.8]"> <span className="h-3 w-3 rounded-full bg-ink-deep" /> <span className="font-semibold">Browser</span> <span className="hidden sm:inline">File</span> <span className="hidden sm:inline">Edit</span> <span className="hidden sm:inline">View</span> <span className="ml-auto">Mon 2 Nov 9:55</span> </div> <div className="absolute right-4 top-4 hidden h-14 w-14 rounded-full bg-ink-deep shadow-soft sm:block" aria-hidden="true" /> <div className="relative px-3 py-10 sm:px-12 sm:py-16 md:px-[180px]"> <div className="overflow-hidden rounded-xl bg-canvas shadow-soft"> <div className="flex items-center gap-3 bg-panel px-4 py-2.5"> <span className="h-3 w-3 rounded-full bg-alert" /><span className="h-3 w-3 rounded-full bg-sand" /><span className="h-3 w-3 rounded-full bg-success" /> <div className="mx-auto w-full max-w-xs rounded-md bg-panel-alt px-3 py-1 text-center text-caption text-muted">{url}</div> </div> <div className="grid md:grid-cols-[280px_1fr_204px]"> <div className="animate-appear-up p-5"> <div className="h-6 w-6 rounded-full bg-gradient-to-br from-sand to-ink" /> <p className="mt-3 text-caption text-muted">{hostName}</p> <h3 className="font-display text-h3 text-ink-deep">{title}</h3> <p className="mt-2 text-ui text-muted">{description}</p> <div className="mt-5 inline-flex rounded-lg bg-panel p-1"> {["15m", "30m", "45m", "1h"].map((d, i) => ( <button key={d} onClick={() => setDur(i)} className={`rounded-md px-3 py-1 text-ui transition-colors duration-color-transition focus-visible:outline focus-visible:outline-2 ${dur === i ? "bg-canvas shadow-ring-raised" : "text-muted"}`}>{d}</button> ))} </div> <p className="mt-4 text-ui text-body">Video call</p> <p className="mt-3 text-ui text-body">Europe/London ▾</p> </div> <div className="border-y border-hairline p-5 md:border-x md:border-y-0"> <div className="flex justify-between text-body"><span>November <span className="text-soft">2026</span></span><span className="text-muted">‹ ›</span></div> <div className="mt-4 grid grid-cols-7 gap-y-1 text-center text-caption text-muted"> {["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"].map((d) => <span key={d}>{d}</span>)} {cells.map((c) => { const a = avail.includes(c as number); const sel = day === c; return ( <button key={c} disabled={!a} onClick={() => setDay(c as number)} aria-label={`November ${c}`} className={`mx-auto h-[52px] w-[52px] max-w-full rounded-md text-ui transition-colors duration-color-transition focus-visible:outline focus-visible:outline-2 ${sel ? "bg-ink text-canvas" : a ? "bg-hairline text-ink-deep" : "text-muted"}`}>{c}</button> ); })} </div> </div> <div className="animate-appear-up p-4"> <div className="flex items-center justify-between text-ui"><span>Wed <span className="text-soft">{day}th</span></span><span className="rounded-md bg-panel px-2 py-0.5 text-caption shadow-ring-inset">12h 24h</span></div> <ul className="mt-4 space-y-2"> {slots.map((s, i) => ( <li key={s}><button onClick={() => setSlot(i)} className={`flex w-full items-center justify-center gap-2 rounded-md py-2 text-ui transition-colors duration-color-transition focus-visible:outline focus-visible:outline-2 ${slot === i ? "bg-ink text-canvas" : "bg-canvas shadow-hairline-inset"}`}><span className="h-1.5 w-1.5 rounded-full bg-success" />{s}</button></li> ))} </ul> </div> </div> </div> </div> </div> <Reveal className="mx-auto mt-16 max-w-5xl text-center"> <p className="text-ui text-muted">{caption}</p> <Stagger step={60} className="mt-8 grid grid-cols-2 gap-y-8 sm:grid-cols-3 lg:grid-cols-6"> {logos.map((l, i) => ( <div key={l} className="flex items-center justify-center gap-2 font-display text-lead text-ink-deep"> <span className={`h-5 w-5 bg-ink ${i % 3 === 0 ? "rounded-full" : i % 3 === 1 ? "rounded-sm" : "rotate-45 rounded-sm"}`} aria-hidden="true" />{l} </div> ))} </Stagger> </Reveal> </section> ); } // ---- Yoink motion (inlined, no dependencies): Reveal, Stagger, Grain ---- 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; } // Background and overlay layers sit inside their parent: make sure it can hold them. function ykPrepareParent(el: HTMLElement | null, isolate = false) { const p = el?.parentElement; if (!p) return; const cs = getComputedStyle(p); if (cs.position === "static") p.style.position = "relative"; if (isolate && cs.isolation !== "isolate" && cs.zIndex === "auto") p.style.isolation = "isolate"; } 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> ); } /** Reveals each direct child one after another when the group scrolls into view. */ function Stagger({ children, step = 90, from = "up", distance = 20, duration = 650, delay = 0, once = true, as = "div", className, style, }: { children?: ReactNode; step?: number; from?: "up" | "down" | "left" | "right" | "scale" | "fade"; distance?: number; duration?: number; delay?: number; once?: boolean; as?: ElementType; className?: string; style?: CSSProperties; }) { const Tag = as; const ref = useRef<HTMLElement>(null); const state = useYkReveal(ref, once); useYkLayoutEffect(() => { const items = Array.from(ref.current?.children ?? []) as HTMLElement[]; if (state === "idle") return; 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.92)", fade: "none", }[from]; if (state === "hidden") { for (const el of items) Object.assign(el.style, { transition: "none", opacity: "0", transform: offset }); return; } items.forEach((el, i) => { const t = `${duration}ms ${YK_EASE} ${delay + i * step}ms`; Object.assign(el.style, { transition: `opacity ${t}, transform ${t}`, opacity: "", transform: "" }); }); // hand the children their own transitions back once everything has landed const done = setTimeout(() => items.forEach((el) => (el.style.transition = "")), delay + items.length * step + duration + 50); return () => clearTimeout(done); }, [state]); return ( <Tag ref={ref} className={className} style={style}> {children} </Tag> ); } const YK_GRAIN_CSS = `@keyframes yk-grain{0%{transform:translate(0,0)}25%{transform:translate(-3%,2%)}50%{transform:translate(2%,-3%)}75%{transform:translate(-2%,-1%)}100%{transform:translate(1%,3%)}} @media (prefers-reduced-motion:reduce){[data-yk-grain] *{animation:none!important}}`; const YK_NOISE = `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 1.6 -0.3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`; /** A film-grain texture over a section (adds tactile depth to flat colour or gradients). */ function Grain({ opacity = 0.12, blend = "overlay", animated = false, className, style, }: { opacity?: number; blend?: CSSProperties["mixBlendMode"]; animated?: boolean; className?: string; style?: CSSProperties; }) { const ref = useRef<HTMLDivElement>(null); useYkLayoutEffect(() => ykPrepareParent(ref.current), []); return ( <div ref={ref} aria-hidden="true" data-yk-grain="" className={className} style={{ position: "absolute", inset: 0, overflow: "hidden", pointerEvents: "none", borderRadius: "inherit", opacity, mixBlendMode: blend, ...style }} > {animated && <style>{YK_GRAIN_CSS}</style>} <div style={{ position: "absolute", inset: "-10%", backgroundImage: YK_NOISE, animation: animated ? "yk-grain 0.9s steps(4) infinite" : undefined }} /> </div> ); }"use client"; import { useEffect, useLayoutEffect, useRef, type CSSProperties, type ElementType, type ReactNode, type RefObject } from "react"; import { useState } from "react"; export default function FrostedDesktopBookingMockup({ imageSrc = "https://yoink-app.fly.dev/stock/abstract-6.jpg", hostName = "Alex Morgan", title = "Book a Quick Chat", description = "Pick a time that suits you and we will send a calendar invite right away. No back and forth needed.", url = "schedula.app/alex", caption = "Trusted by fast-moving teams for scheduling", logos = ["Northwind", "Altura", "Lumen", "Kitefield", "Brightpath", "Orbital", "Fernhill", "Quill", "Marlow", "Tidewater", "Harbor", "Cobalt"], }: { imageSrc?: string; hostName?: string; title?: string; description?: string; url?: string; caption?: string; logos?: string[]; }) { const [day, setDay] = useState(25); const [slot, setSlot] = useState(0); const [dur, setDur] = useState(0); const slots = ["9:00am", "9:15am", "9:30am", "10:00am", "10:15am"]; const avail = [26, 27, 30, 25]; const cells: (number | null)[] = []; for (let i = 1; i <= 30; i++) cells.push(i); return ( <section className="bg-background px-4 py-10 font-sans text-foreground"> <div className="relative mx-auto max-w-[1292px] overflow-hidden rounded-2xl bg-card"> <img src={imageSrc} alt="" width={1600} height={1067} className="absolute inset-0 h-full w-full object-cover grayscale" /> <Grain opacity={0.2} /> <div className="relative flex items-center gap-5 bg-background/70 px-4 py-1.5 text-warm-caption text-muted-foreground backdrop-blur-[30px] backdrop-saturate-[1.8]"> <span className="h-3 w-3 rounded-full bg-foreground" /> <span className="font-semibold">Browser</span> <span className="hidden sm:inline">File</span> <span className="hidden sm:inline">Edit</span> <span className="hidden sm:inline">View</span> <span className="ml-auto">Mon 2 Nov 9:55</span> </div> <div className="absolute right-4 top-4 hidden h-14 w-14 rounded-full bg-foreground shadow-warm-soft sm:block" aria-hidden="true" /> <div className="relative px-3 py-10 sm:px-12 sm:py-16 md:px-[180px]"> <div className="overflow-hidden rounded-2xl bg-background shadow-warm-soft"> <div className="flex items-center gap-3 bg-card px-4 py-2.5"> <span className="h-3 w-3 rounded-full bg-warm-alert" /><span className="h-3 w-3 rounded-full bg-foreground" /><span className="h-3 w-3 rounded-full bg-warm-success" /> <div className="mx-auto w-full max-w-xs rounded-lg bg-muted px-3 py-1 text-center text-warm-caption text-muted-foreground">{url}</div> </div> <div className="grid md:grid-cols-[280px_1fr_204px]"> <div className="animate-warm-appear-up p-5"> <div className="h-6 w-6 rounded-full bg-gradient-to-br from-foreground to-foreground" /> <p className="mt-3 text-warm-caption text-muted-foreground">{hostName}</p> <h3 className="font-sans text-warm-h3 text-muted-foreground">{title}</h3> <p className="mt-2 text-warm-ui text-muted-foreground">{description}</p> <div className="mt-5 inline-flex rounded-xl bg-card p-1"> {["15m", "30m", "45m", "1h"].map((d, i) => ( <button key={d} onClick={() => setDur(i)} className={`rounded-lg px-3 py-1 text-warm-ui transition-colors duration-warm-color-transition focus-visible:outline focus-visible:outline-2 ${dur === i ? "bg-background shadow-warm-ring-raised" : "text-muted-foreground"}`}>{d}</button> ))} </div> <p className="mt-4 text-warm-ui text-warm-body">Video call</p> <p className="mt-3 text-warm-ui text-warm-body">Europe/London ▾</p> </div> <div className="border-y border-border p-5 md:border-x md:border-y-0"> <div className="flex justify-between text-warm-body"><span>November <span className="text-muted-foreground">2026</span></span><span className="text-muted-foreground">‹ ›</span></div> <div className="mt-4 grid grid-cols-7 gap-y-1 text-center text-warm-caption text-muted-foreground"> {["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"].map((d) => <span key={d}>{d}</span>)} {cells.map((c) => { const a = avail.includes(c as number); const sel = day === c; return ( <button key={c} disabled={!a} onClick={() => setDay(c as number)} aria-label={`November ${c}`} className={`mx-auto h-[52px] w-[52px] max-w-full rounded-lg text-warm-ui transition-colors duration-warm-color-transition focus-visible:outline focus-visible:outline-2 ${sel ? "bg-foreground text-background" : a ? "bg-border text-muted-foreground" : "text-muted-foreground"}`}>{c}</button> ); })} </div> </div> <div className="animate-warm-appear-up p-4"> <div className="flex items-center justify-between text-warm-ui"><span>Wed <span className="text-muted-foreground">{day}th</span></span><span className="rounded-lg bg-card px-2 py-0.5 text-warm-caption shadow-warm-ring-inset">12h 24h</span></div> <ul className="mt-4 space-y-2"> {slots.map((s, i) => ( <li key={s}><button onClick={() => setSlot(i)} className={`flex w-full items-center justify-center gap-2 rounded-lg py-2 text-warm-ui transition-colors duration-warm-color-transition focus-visible:outline focus-visible:outline-2 ${slot === i ? "bg-foreground text-background" : "bg-background shadow-warm-hairline-inset"}`}><span className="h-1.5 w-1.5 rounded-full bg-warm-success" />{s}</button></li> ))} </ul> </div> </div> </div> </div> </div> <Reveal className="mx-auto mt-16 max-w-5xl text-center"> <p className="text-warm-ui text-muted-foreground">{caption}</p> <Stagger step={60} className="mt-8 grid grid-cols-2 gap-y-8 sm:grid-cols-3 lg:grid-cols-6"> {logos.map((l, i) => ( <div key={l} className="flex items-center justify-center gap-2 font-sans text-warm-lead text-muted-foreground"> <span className={`h-5 w-5 bg-foreground ${i % 3 === 0 ? "rounded-full" : i % 3 === 1 ? "rounded-md" : "rotate-45 rounded-md"}`} aria-hidden="true" />{l} </div> ))} </Stagger> </Reveal> </section> ); } // ---- Yoink motion (inlined, no dependencies): Reveal, Stagger, Grain ---- 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; } // Background and overlay layers sit inside their parent: make sure it can hold them. function ykPrepareParent(el: HTMLElement | null, isolate = false) { const p = el?.parentElement; if (!p) return; const cs = getComputedStyle(p); if (cs.position === "static") p.style.position = "relative"; if (isolate && cs.isolation !== "isolate" && cs.zIndex === "auto") p.style.isolation = "isolate"; } 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> ); } /** Reveals each direct child one after another when the group scrolls into view. */ function Stagger({ children, step = 90, from = "up", distance = 20, duration = 650, delay = 0, once = true, as = "div", className, style, }: { children?: ReactNode; step?: number; from?: "up" | "down" | "left" | "right" | "scale" | "fade"; distance?: number; duration?: number; delay?: number; once?: boolean; as?: ElementType; className?: string; style?: CSSProperties; }) { const Tag = as; const ref = useRef<HTMLElement>(null); const state = useYkReveal(ref, once); useYkLayoutEffect(() => { const items = Array.from(ref.current?.children ?? []) as HTMLElement[]; if (state === "idle") return; 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.92)", fade: "none", }[from]; if (state === "hidden") { for (const el of items) Object.assign(el.style, { transition: "none", opacity: "0", transform: offset }); return; } items.forEach((el, i) => { const t = `${duration}ms ${YK_EASE} ${delay + i * step}ms`; Object.assign(el.style, { transition: `opacity ${t}, transform ${t}`, opacity: "", transform: "" }); }); // hand the children their own transitions back once everything has landed const done = setTimeout(() => items.forEach((el) => (el.style.transition = "")), delay + items.length * step + duration + 50); return () => clearTimeout(done); }, [state]); return ( <Tag ref={ref} className={className} style={style}> {children} </Tag> ); } const YK_GRAIN_CSS = `@keyframes yk-grain{0%{transform:translate(0,0)}25%{transform:translate(-3%,2%)}50%{transform:translate(2%,-3%)}75%{transform:translate(-2%,-1%)}100%{transform:translate(1%,3%)}} @media (prefers-reduced-motion:reduce){[data-yk-grain] *{animation:none!important}}`; const YK_NOISE = `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 1.6 -0.3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`; /** A film-grain texture over a section (adds tactile depth to flat colour or gradients). */ function Grain({ opacity = 0.12, blend = "overlay", animated = false, className, style, }: { opacity?: number; blend?: CSSProperties["mixBlendMode"]; animated?: boolean; className?: string; style?: CSSProperties; }) { const ref = useRef<HTMLDivElement>(null); useYkLayoutEffect(() => ykPrepareParent(ref.current), []); return ( <div ref={ref} aria-hidden="true" data-yk-grain="" className={className} style={{ position: "absolute", inset: 0, overflow: "hidden", pointerEvents: "none", borderRadius: "inherit", opacity, mixBlendMode: blend, ...style }} > {animated && <style>{YK_GRAIN_CSS}</style>} <div style={{ position: "absolute", inset: "-10%", backgroundImage: YK_NOISE, animation: animated ? "yk-grain 0.9s steps(4) infinite" : undefined }} /> </div> ); }
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: passedStill readable when installed in your theme and switched to dark mode.
- 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.