Cards & content / Cards

Ghosted Diagram Feature Cards

Two side-by-side hairline cards with a small 'Learn about…' chevron link top-left, a faded line-art diagram (execution-time chips and idle bars; spending-limit bars with LIMIT tag) in the upper area and bold title plus muted description at the bottom.

Rebuilt from vercel.com/pricing in the Monochrome Precision style.

npx shadcn@latest add https://justyoink.it/r/monochrome-precision/blocks/illustrated-cost-cards.json

Looks exactly like vercel.com: brings its fonts and colours, namespaced so your own theme stays untouched.

Usage

Pass `left` and `right` objects ({link, title, description, href}) to change copy; renders standalone with defaults. Diagrams are inline SVG faded with masks, and card borders darken on hover over 150ms.

components/illustrated-cost-cards.tsx
"use client";

import { useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type ElementType, type ReactNode, type RefObject } from "react";
type Card = { link: string; title: string; description: string; href?: string };

type Props = {
  left?: Card;
  right?: Card;
};

const Chevron = () => (
  <svg width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true" className="shrink-0">
    <path d="M4.5 2.5 8 6l-3.5 3.5" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round" />
  </svg>
);

function TimeDiagram() {
  const chips = [
    { x: 20, y: 80, t: "3s" },
    { x: 158, y: 106, t: "2s" },
    { x: 330, y: 132, t: "1.5s" },
    { x: 430, y: 158, t: "" },
  ];
  const bars = [
    { x: 90, h: 200, w: 70 },
    { x: 215, h: 230, w: 120 },
    { x: 370, h: 190, w: 60 },
  ];
  return (
    <svg viewBox="0 0 451 278" className="absolute right-0 top-0 h-[278px] w-[451px] max-w-none text-ink opacity-60" aria-hidden="true" style={{ maskImage: "linear-gradient(to bottom, black 30%, transparent 85%)", WebkitMaskImage: "linear-gradient(to bottom, black 30%, transparent 85%)" }}>
      {[0, 1, 2, 3, 4, 5, 6].map((i) => (
        <line key={i} x1="60" x2="451" y1={10 + i * 30} y2={10 + i * 30} stroke="var(--color-hairline)" />
      ))}
      {bars.map((b, i) => (
        <g key={i}>
          <rect x={b.x} y={-10} width={b.w} height={b.h} fill="var(--color-surface-muted)" opacity="0.7" />
          <text x={b.x + b.w / 2} y={118} textAnchor="middle" fontSize="11" fill="var(--color-tertiary)" className="font-mono">idle</text>
        </g>
      ))}
      {chips.map((c, i) => (
        <g key={i}>
          <rect x={c.x} y={c.y - 14} width={c.t.length > 2 ? 42 : 52} height={26} rx="6" fill="var(--color-surface)" stroke="var(--color-hairline-strong)" />
          <text x={c.x + (c.t.length > 2 ? 21 : 26)} y={c.y + 3} textAnchor="middle" fontSize="11" fill="currentColor" className="font-mono">{c.t}</text>
        </g>
      ))}
    </svg>
  );
}

function SpendDiagram() {
  const bars = [
    { x: 20, y: 130, h: 70 },
    { x: 76, y: 70, h: 130 },
    { x: 130, y: 55, h: 145 },
    { x: 184, y: 40, h: 160 },
    { x: 238, y: 20, h: 230 },
    { x: 292, y: 20, h: 230 },
  ];
  return (
    <svg viewBox="0 0 434 263" className="absolute right-0 top-0 h-[263px] w-[434px] max-w-none text-ink" aria-hidden="true">
      {[0, 1, 2, 3].map((i) => (
        <line key={i} x1="0" x2="434" y1={90 + i * 40} y2={90 + i * 40} stroke="var(--color-hairline)" opacity="0.7" />
      ))}
      {bars.map((b, i) => (
        <rect key={i} x={b.x + 60} y={b.y} width="42" height={b.h} rx="6" fill="var(--color-surface)" stroke="var(--color-hairline)" opacity={i < 4 ? 0.35 + i * 0.12 : 1} />
      ))}
      <line x1="250" x2="390" y1="28" y2="28" stroke="currentColor" />
      <rect x="250" y="17" width="50" height="20" rx="3" fill="var(--color-surface)" stroke="currentColor" />
      <text x="275" y="31" textAnchor="middle" fontSize="11" fill="currentColor" className="font-mono">LIMIT</text>
    </svg>
  );
}

export default function GhostedDiagramFeatureCards({
  left = { link: "Learn about Elastic Runtime", title: "Zero idle, zero waste", description: "Pay only for active run time, never for resources sitting unused.", href: "#" },
  right = { link: "Learn about Budget Guard", title: "Stay inside budget", description: "Pick a cap, receive alerts, and we'll pause usage before you overspend.", href: "#" },
}: Props) {
  const cards = [
    { c: left, d: <TimeDiagram /> },
    { c: right, d: <SpendDiagram /> },
  ];
  return (
    <section className="bg-canvas px-4 py-10 font-sans sm:px-6">
      <div className="mx-auto grid max-w-[1392px] gap-5 md:grid-cols-2">
        {cards.map(({ c, d }, i) => (
          <Reveal key={i} delay={i * 100}>
            <article className="group relative h-[340px] overflow-hidden rounded-[4px] border border-hairline bg-surface transition-colors duration-150 hover:border-hairline-strong">
              <div className="pointer-events-none absolute inset-0">{d}</div>
              <a href={c.href} className="absolute left-8 top-8 z-10 inline-flex items-center gap-2 text-ui text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-blue">
                {c.link}
                <Chevron />
              </a>
              <div className="absolute bottom-8 left-8 right-8 z-10">
                <h3 className="text-h3 tracking-[-0.02em] text-ink">{c.title}</h3>
                <p className="mt-3 max-w-[240px] text-body text-secondary">{c.description}</p>
              </div>
            </article>
          </Reveal>
        ))}
      </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
—

More from Monochrome Precision

The whole style →

Ink and Ghost Button Pair

Buttons

Dashed Orbit Integration Ring

Animated graphics

Customer Story Index List

Lists

Centered Quote with Meta Row

Testimonials

Hairline Navigation Bar

Headers & nav bars

Floating Triangle Hero with Logo Strip

Heroes