Cards & content / Code blocks

Code + Live Booking Preview Panel

A gray-bordered rounded container with a monospace header label and copy icon. A split view shows a light code pane with green strings and an orange highlighted call on the left, and on the right a weekly availability grid (open, hatched busy, gray booked, a dark selected slot) plus a timestamped event log with colored dots and a green 'confirmed' badge.

Rebuilt from cal.com/pricing in the Warm Paper Calendar style.

npx shadcn@latest add https://justyoink.it/r/warm-paper-calendar/blocks/code-and-booking-preview-panel.json

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

Usage

Props: label, title, subtitle, attendee (all optional strings). The selected slot and event log rows animate in (6px rise, 400ms) once scrolled into view, with logs delayed ~1s.

components/code-and-booking-preview-panel.tsx
"use client";

import { useLayoutEffect, type CSSProperties, type ElementType, type ReactNode, type RefObject } from "react";
import { useEffect, useRef, useState } from "react";

type Slot = "open" | "busy" | "booked" | "sel";

const DAYS = ["Mon 9", "Tue 10", "Wed 11", "Thu 12", "Fri 13"];
const TIMES = ["09:00", "10:00", "11:00", "13:00", "14:00", "15:00"];
const GRID: Slot[][] = [
  ["busy", "open", "booked", "open", "open"],
  ["open", "sel", "open", "busy", "open"],
  ["open", "open", "busy", "open", "open"],
  ["booked", "open", "open", "booked", "open"],
  ["open", "busy", "open", "booked", "open"],
  ["open", "busy", "open", "open", "busy"],
];

export default function CodeBookingPreviewPanel({
  label = "api.bookings.create()",
  title = "Intro call with Maya Ortiz",
  subtitle = "30 minutes, 10 minute buffer",
  attendee = "Jo",
}: {
  label?: string;
  title?: string;
  subtitle?: string;
  attendee?: string;
}) {
  const ref = useRef<HTMLDivElement>(null);
  const [shown, setShown] = useState(false);
  useEffect(() => {
    const el = ref.current;
    if (!el) return;
    const io = new IntersectionObserver(([e]) => {
      if (e.isIntersecting) {
        setShown(true);
        io.disconnect();
      }
    });
    io.observe(el);
    return () => io.disconnect();
  }, []);

  const anim = (delay: number) =>
    `transition-all duration-[400ms] ease-linear motion-reduce:transition-none ${shown ? "translate-y-0 opacity-100" : "translate-y-[6px] opacity-0"}`;
  const cell: Record<Slot, string> = {
    open: "bg-canvas border border-hairline",
    busy: "bg-hatch-busy border border-hairline-strong",
    booked: "bg-hairline border border-hairline",
    sel: "bg-ink-deep text-canvas",
  };
  const str = "text-success";

  return (
    <section className="bg-canvas px-4 py-10 font-sans text-body">
      <Reveal from="up">
        <div ref={ref} className="mx-auto max-w-[1290px] rounded-xl bg-panel p-1 shadow-ring-inset ring-1 ring-hairline">
          <div className="flex items-center justify-between px-4 py-2.5">
            <span className="font-mono text-caption text-muted">{label}</span>
            <button aria-label="Copy code" className="rounded-sm p-1 text-muted hover:text-ink focus-visible:outline focus-visible:outline-2 duration-color-transition">
              <svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.3"><rect x="5" y="5" width="8" height="8" rx="1.5" /><path d="M3 10V4a1 1 0 0 1 1-1h6" /></svg>
            </button>
          </div>
          <div className="grid overflow-hidden rounded-lg bg-canvas ring-1 ring-hairline lg:grid-cols-[1.0fr_1.15fr]">
            <pre className="overflow-x-auto bg-panel-alt p-5 font-mono text-[12px] leading-[22px] text-ink lg:min-h-[450px]"><code>{`const result = await `}<span className="rounded-sm bg-alert/15 text-alert">api.bookings.create</span>{`({
  event_type: eventTypeId,
  start: `}<span className={str}>"2026-03-10T14:00:00Z"</span>{`,
  attendee: {
    uid: `}<span className={str}>"user_42"</span>{`,
    name: `}<span className={str}>"Jo Park"</span>{`,
    email: `}<span className={str}>"jo@example.com"</span>{`,
    time_zone: `}<span className={str}>"Europe/Berlin"</span>{`,
  },
});
if (result.error?.code === `}<span className={str}>"slot_taken"</span>{`) {
  `}<span className="text-muted">{`// Someone was faster: reload the times.`}</span>{`
}`}</code></pre>
            <div className="p-5 lg:border-l lg:border-hairline">
              <div className="flex items-start justify-between gap-3">
                <div>
                  <h3 className="text-lead text-ink-deep">{title}</h3>
                  <p className="text-ui text-muted">{subtitle}</p>
                </div>
                <span className="rounded-pill bg-success/10 px-2.5 py-1 text-caption text-success">confirmed</span>
              </div>
              <div className="mt-5 grid grid-cols-[48px_repeat(5,1fr)] gap-x-1.5 gap-y-1.5 text-caption text-muted">
                <span />
                {DAYS.map((d) => (<span key={d} className="pb-2 text-center">{d}</span>))}
                {GRID.map((row, r) => (
                  <div key={r} className="contents">
                    <span className="self-center font-mono text-[10px]">{TIMES[r]}</span>
                    {row.map((s, c) => (
                      <div key={c} className={`flex h-7 items-center justify-center rounded-md text-[11px] ${cell[s]} ${s === "sel" ? anim(0) : ""}`}>
                        {s === "sel" ? attendee : null}
                      </div>
                    ))}
                  </div>
                ))}
              </div>
              <div className="mt-3 flex gap-4 text-caption text-muted">
                <span className="flex items-center gap-1.5"><i className="h-2.5 w-2.5 rounded-pill border border-hairline" />Open</span>
                <span className="flex items-center gap-1.5"><i className="h-2.5 w-2.5 rounded-pill bg-hatch-busy border border-hairline-strong" />Busy on calendar</span>
                <span className="flex items-center gap-1.5"><i className="h-2.5 w-2.5 rounded-pill bg-hairline-strong" />Booked</span>
              </div>
              <ul className="mt-6 text-caption">
                <li style={{ transitionDelay: shown ? "1040ms" : "0ms" }} className={`grid grid-cols-[1fr_auto] gap-y-1 border-b border-hairline pb-3 ${anim(1)}`}>
                  <span className="flex items-center gap-2 font-mono text-ink"><i className="h-1.5 w-1.5 rounded-pill bg-success" />confirmed</span>
                  <span className="font-mono text-muted">09:41:02</span>
                  <span className="pl-3.5 text-muted">Calendar invitations to Jo and Maya</span>
                </li>
                <li style={{ transitionDelay: shown ? "1240ms" : "0ms" }} className={`grid grid-cols-[1fr_auto] pt-3 ${anim(2)}`}>
                  <span className="flex items-center gap-2 font-mono text-ink"><i className="h-1.5 w-1.5 rounded-pill bg-alert" />booking.confirmed</span>
                  <span className="font-mono text-muted">09:41:02</span>
                </li>
              </ul>
            </div>
          </div>
        </div>
      </Reveal>
    </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 · 5d ago
—

More from Warm Paper Calendar

The whole style →

Floating Pill Navigation Bar

Headers & nav bars

Hub-and-Spoke Integration Diagram

Animated graphics

Customer Story Accordion

Accordions

Inline-Chip Headline Hero

Heroes

Frosted Desktop Booking Mockup

Media & mockups

Monochrome Logo Grid

Logo clouds