Page sections / Feature sections
Centered Product Quartet
Centered light heading with an underlined 'Shop All' link, then four columns on foam background. Each has a jar render, an outlined mono product-code pill, a light product name, a bold benefit line and a dark pill 'Shop Now' button.
Rebuilt from seed.com in the Verdant Lab Editorial style.
Looks exactly like seed.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: heading, subheading, shopAllLabel, shopAllHref, ctaLabel and products (array of {code, name, benefit, href, tone: dark|olive|frost|mist, label}). Renders standalone with defaults; jars are drawn in CSS and scale on hover, buttons invert on hover.
components/product-quartet-row.tsx
"use client"; import { useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type ElementType, type ReactNode, type RefObject } from "react"; type Product = { code: string; name: string; benefit: string; href?: string; tone: "dark" | "olive" | "frost" | "mist"; label?: string }; const DEFAULT_PRODUCTS: Product[] = [ { code: "AL-01", name: "Daily Greens", benefit: "Supports steady digestion", tone: "dark" }, { code: "AL-02", name: "Daily Minerals", benefit: "Helps cover daily needs", tone: "olive" }, { code: "AL-03", name: "Focus + Drive", benefit: "Sharpens afternoon clarity", tone: "frost", label: "#e6ec8a" }, { code: "AL-04", name: "Calm + Rest", benefit: "Encourages deeper evenings", tone: "mist", label: "#bcd9e6" }, ]; const bodies: Record<Product["tone"], string> = { dark: "from-[#2f3d33] to-[#0f1a12]", olive: "from-[#8a9a5a] to-[#4d5c2b]", frost: "from-[#f1f1ec] to-[#c3c6bf]", mist: "from-[#eef1f0] to-[#b9c0c0]", }; function Jar({ p }: { p: Product }) { return ( <div className="relative h-[208px] w-[208px] transition-transform duration-ui-hover ease-ui-hover group-hover:scale-105"> <div className="absolute left-1/2 top-[22px] h-[34px] w-[120px] -translate-x-1/2 rounded-t-md bg-gradient-to-b from-[#56655a] to-[#27352b]" /> <div className={`absolute left-1/2 top-[52px] h-[104px] w-[120px] -translate-x-1/2 rounded-b-xl bg-gradient-to-b ${bodies[p.tone]} shadow-[0_14px_20px_-12px_rgba(0,0,0,0.35)]`}> <span className="absolute left-1/2 top-[10px] -translate-x-1/2 text-[8px] text-canvas/80">Alder</span> <span className="absolute left-1/2 top-[36px] h-2.5 w-2.5 -translate-x-1/2 rounded-full bg-ink/90 ring-2 ring-canvas/60" /> <span className="absolute inset-x-3 bottom-5 h-2 rounded-sm" style={{ background: p.label ?? "rgba(255,255,255,0.18)" }} /> </div> </div> ); } export default function CenteredProductQuartet({ heading = "Everyday wellness starts here.", subheading = "Carefully tested blends made for your routine and your gut.", shopAllLabel = "Shop All", shopAllHref = "#", products = DEFAULT_PRODUCTS, ctaLabel = "Shop Now", }: { heading?: string; subheading?: string; shopAllLabel?: string; shopAllHref?: string; products?: Product[]; ctaLabel?: string; }) { return ( <section className="bg-surface-foam px-6 py-20 font-sans text-ink"> <Reveal className="mx-auto max-w-3xl text-center"> <h2 className="text-h2 font-light">{heading}</h2> <p className="mt-3 text-body font-medium"> {subheading}{" "} <a href={shopAllHref} className="underline underline-offset-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-ink">{shopAllLabel}</a> </p> </Reveal> <Stagger className="mx-auto mt-14 grid max-w-[1320px] gap-12 sm:grid-cols-2 lg:grid-cols-4"> {products.map((p) => ( <article key={p.code} className="group flex flex-col items-center text-center"> <Jar p={p} /> <span className="mt-8 rounded-pill border border-ink px-2.5 py-px font-mono text-caption">{p.code}</span> <h3 className="mt-2 text-h3 font-light">{p.name}</h3> <p className="mt-3 text-label font-bold">{p.benefit}</p> <a href={p.href ?? "#"} className="mt-6 inline-flex h-12 items-center rounded-pill border border-ink bg-ink px-6 text-body text-canvas transition-all duration-ui-hover ease-ui-hover hover:bg-canvas hover:text-ink focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ink"> {ctaLabel} </a> </article> ))} </Stagger> </section> ); } // ---- Yoink motion (inlined, no dependencies): Reveal, Stagger ---- 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> ); } /** 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> ); }"use client"; import { useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type ElementType, type ReactNode, type RefObject } from "react"; type Product = { code: string; name: string; benefit: string; href?: string; tone: "dark" | "olive" | "frost" | "mist"; label?: string }; const DEFAULT_PRODUCTS: Product[] = [ { code: "AL-01", name: "Daily Greens", benefit: "Supports steady digestion", tone: "dark" }, { code: "AL-02", name: "Daily Minerals", benefit: "Helps cover daily needs", tone: "olive" }, { code: "AL-03", name: "Focus + Drive", benefit: "Sharpens afternoon clarity", tone: "frost", label: "#e6ec8a" }, { code: "AL-04", name: "Calm + Rest", benefit: "Encourages deeper evenings", tone: "mist", label: "#bcd9e6" }, ]; const bodies: Record<Product["tone"], string> = { dark: "from-[#2f3d33] to-[#0f1a12]", olive: "from-[#8a9a5a] to-[#4d5c2b]", frost: "from-[#f1f1ec] to-[#c3c6bf]", mist: "from-[#eef1f0] to-[#b9c0c0]", }; function Jar({ p }: { p: Product }) { return ( <div className="relative h-[208px] w-[208px] transition-transform duration-verdant-ui-hover ease-verdant-ui-hover group-hover:scale-105"> <div className="absolute left-1/2 top-[22px] h-[34px] w-[120px] -translate-x-1/2 rounded-t-md bg-gradient-to-b from-[#56655a] to-[#27352b]" /> <div className={`absolute left-1/2 top-[52px] h-[104px] w-[120px] -translate-x-1/2 rounded-b-xl bg-gradient-to-b ${bodies[p.tone]} shadow-[0_14px_20px_-12px_rgba(0,0,0,0.35)]`}> <span className="absolute left-1/2 top-[10px] -translate-x-1/2 text-[8px] text-background/80">Alder</span> <span className="absolute left-1/2 top-[36px] h-2.5 w-2.5 -translate-x-1/2 rounded-full bg-foreground/90 ring-2 ring-background/60" /> <span className="absolute inset-x-3 bottom-5 h-2 rounded-sm" style={{ background: p.label ?? "rgba(255,255,255,0.18)" }} /> </div> </div> ); } export default function CenteredProductQuartet({ heading = "Everyday wellness starts here.", subheading = "Carefully tested blends made for your routine and your gut.", shopAllLabel = "Shop All", shopAllHref = "#", products = DEFAULT_PRODUCTS, ctaLabel = "Shop Now", }: { heading?: string; subheading?: string; shopAllLabel?: string; shopAllHref?: string; products?: Product[]; ctaLabel?: string; }) { return ( <section className="bg-muted px-6 py-20 font-sans text-foreground"> <Reveal className="mx-auto max-w-3xl text-center"> <h2 className="text-verdant-h2 font-light">{heading}</h2> <p className="mt-3 text-verdant-body font-medium"> {subheading}{" "} <a href={shopAllHref} className="underline underline-offset-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-foreground">{shopAllLabel}</a> </p> </Reveal> <Stagger className="mx-auto mt-14 grid max-w-[1320px] gap-12 sm:grid-cols-2 lg:grid-cols-4"> {products.map((p) => ( <article key={p.code} className="group flex flex-col items-center text-center"> <Jar p={p} /> <span className="mt-8 rounded-full border border-foreground px-2.5 py-px font-mono text-verdant-caption">{p.code}</span> <h3 className="mt-2 text-verdant-h3 font-light">{p.name}</h3> <p className="mt-3 text-verdant-label font-bold">{p.benefit}</p> <a href={p.href ?? "#"} className="mt-6 inline-flex h-12 items-center rounded-full border border-foreground bg-primary px-6 text-verdant-body text-primary-foreground transition-all duration-verdant-ui-hover ease-verdant-ui-hover hover:bg-background hover:text-primary-foreground focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-foreground"> {ctaLabel} </a> </article> ))} </Stagger> </section> ); } // ---- Yoink motion (inlined, no dependencies): Reveal, Stagger ---- 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> ); } /** 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> ); }
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: not passed2 hard-coded colours (from-[#56655a], to-[#27352b]). 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.