Cards & content / Code blocks

Code and Email Preview IDE

macOS-style window with traffic-light dots, device and theme toggle segmented controls, a file list sidebar (active file in blue), a numbered mono code pane and a right-hand light email preview with cyan glow orb, bold greeting and a bright blue CTA button.

Rebuilt from resend.com in the Obsidian Serif Glow style.

npx shadcn@latest add https://justyoink.it/r/obsidian-serif-glow/blocks/ide-preview-split-window.json

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

Usage

Pass `files` (name, code lines, title, body, cta) to customize; no props needed. Click files to swap code and email, and use the segmented toggles for mobile width and light paper preview.

components/ide-preview-split-window.tsx
"use client";

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

type FileItem = { name: string; code: string[]; title: string; body: string; cta: string };

const defaultFiles: FileItem[] = [
  { name: "user-welcome.tsx", title: "Welcome to Northwind, friend!", body: "We're glad to have you onboard. Take a look around and reach out if you need anything at all.", cta: "Get Started", code: ["import {", "  Body,", "  Button,", "  Container,", "  Heading,", "  Html,", "  Text,", "} from 'mail-kit';", "", "const Welcome = ({", "  name = 'Sam',", "}: Props) => {", "  return (", "    <Html>", "      <Body className=\"bg-white\">", "        <Heading>Welcome</Heading>", "        <Button href={url}>", "          Get Started", "        </Button>", "      </Body>", "    </Html>", "  );", "};"] },
  { name: "reset-password.tsx", title: "Reset your password", body: "Someone asked to reset the password for your account. Use the button below to choose a new one.", cta: "Reset password", code: ["import { Html, Button, Text } from 'mail-kit';", "", "export const Reset = ({ link }) => (", "  <Html>", "    <Text>Reset your password</Text>", "    <Button href={link}>", "      Reset password", "    </Button>", "  </Html>", ");"] },
  { name: "user-invite.tsx", title: "You're invited to a team", body: "A teammate invited you to collaborate on a shared workspace. Accept the invitation to join.", cta: "Accept invite", code: ["import { Html, Button, Heading } from 'mail-kit';", "", "export const Invite = ({ team }) => (", "  <Html>", "    <Heading>Join {team}</Heading>", "    <Button>Accept invite</Button>", "  </Html>", ");"] },
  { name: "weekly-digest.tsx", title: "Your week in review", body: "Here is a quick summary of what happened across your projects over the past seven days.", cta: "View digest", code: ["import { Html, Section, Text } from 'mail-kit';", "", "export const Digest = ({ items }) => (", "  <Html>", "    <Section>", "      {items.map(i => (", "        <Text key={i.id}>{i.title}</Text>", "      ))}", "    </Section>", "  </Html>", ");"] },
];

export default function CodeEmailPreviewIDE({ files = defaultFiles }: { files?: FileItem[] }) {
  const [active, setActive] = useState(0);
  const [mobile, setMobile] = useState(false);
  const [light, setLight] = useState(false);
  const f = files[active];
  const seg = (on: boolean) => `grid h-6 w-7 place-items-center rounded-md text-[11px] focus-visible:outline focus-visible:outline-1 focus-visible:outline-accent-blue ${on ? "bg-surface-high text-primary" : "text-muted hover:text-primary"}`;

  return (
    <section className="bg-background px-4 py-16">
      <Reveal>
        <div className="mx-auto max-w-6xl overflow-hidden rounded-[28px] border border-hairline bg-background">
          <div className="flex items-center justify-between border-b border-hairline px-4 py-3">
            <div className="flex gap-2" aria-hidden="true">
              <span className="h-2.5 w-2.5 rounded-full bg-state-danger" />
              <span className="h-2.5 w-2.5 rounded-full bg-state-warning" />
              <span className="h-2.5 w-2.5 rounded-full bg-accent-green" />
            </div>
            <div className="flex gap-2">
              <div className="flex rounded-lg border border-hairline p-0.5">
                <button aria-label="Desktop preview" onClick={() => setMobile(false)} className={seg(!mobile)}>▭</button>
                <button aria-label="Mobile preview" onClick={() => setMobile(true)} className={seg(mobile)}>▯</button>
              </div>
              <div className="flex rounded-lg border border-hairline p-0.5">
                <button aria-label="Dark preview" onClick={() => setLight(false)} className={seg(!light)}>☾</button>
                <button aria-label="Light preview" onClick={() => setLight(true)} className={seg(light)}>☀</button>
              </div>
            </div>
          </div>
          <div className="grid md:grid-cols-[200px_1fr_1fr] md:h-[650px]">
            <ul className="flex gap-1 overflow-x-auto border-b border-hairline p-3 md:block md:space-y-1 md:border-b-0 md:border-r">
              {files.map((x, i) => (
                <li key={x.name}>
                  <button onClick={() => setActive(i)} className={`flex w-full items-center gap-2 whitespace-nowrap rounded-md px-2 py-2 text-ui transition-colors duration-hover-color focus-visible:outline focus-visible:outline-1 focus-visible:outline-accent-blue ${i === active ? "text-accent-blue" : "text-secondary hover:text-primary"}`}>
                    <span className="grid h-4 w-4 place-items-center rounded-sm bg-surface-high font-mono text-[8px] text-primary">TS</span>
                    {x.name}
                  </button>
                </li>
              ))}
            </ul>
            <div className="max-h-[420px] overflow-hidden p-5 md:max-h-none">
              <pre key={active} className="animate-hero-text-slide-up-fade font-mono text-[12px] leading-4 text-secondary">
                {f.code.map((l, i) => (
                  <div key={i} className="flex"><span className="w-7 shrink-0 select-none text-muted">{i + 1}</span><code className="whitespace-pre">{l}</code></div>
                ))}
              </pre>
            </div>
            <div className="relative flex justify-center overflow-hidden p-6">
              <div className="pointer-events-none absolute inset-x-0 top-0 h-64 bg-[radial-gradient(100%_60%_at_50%_0%,rgba(0,163,255,0.14),transparent)]" />
              <div className={`relative w-full ${mobile ? "max-w-[300px]" : "max-w-[420px]"} rounded-lg p-6 text-center transition-all duration-300 ${light ? "bg-paper text-[#111]" : "bg-transparent text-primary"}`}>
                <div className="mx-auto mb-6 mt-4 grid h-20 w-20 place-items-center rounded-full bg-gradient-to-br from-accent-blue to-accent-cyan shadow-glow-blue">
                  <span className="h-5 w-5 rounded-full bg-white/80" />
                </div>
                <h3 className="text-xl font-medium">{f.title}</h3>
                <div className="mt-8 text-left text-sm leading-6">
                  <p>Hello Sam,</p>
                  <p className="mt-3">{f.body}</p>
                </div>
                <button className="mt-6 rounded-md bg-accent-blue px-5 py-2.5 text-sm font-semibold text-white">{f.cta}</button>
                <p className="mt-8 text-left text-sm">Cheers,<br />The Northwind Team</p>
              </div>
            </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 Obsidian Serif Glow

The whole style →

Blue Glass Agent Config Card

Forms

Hairline Use-Case Grid

Feature sections

Serif Hero with Dark 3D Object

Heroes

Monochrome Logo Cloud

Logo clouds

Language Picker and Code Window

Code blocks

Glossy Icon Section Header

Feature sections