Cards & content / Code blocks

Split Diff Code Viewer

Mono code panel with file path header, line numbers, syntax-coloured tokens and red/green tinted changed lines with left rule, in side-by-side diff. Overlaps a grouped issue list (In Review, In Progress, Todo) with status icons that fades out at the bottom.

Rebuilt from linear.app in the Obsidian Precision style.

npx shadcn@latest add https://yoink-app.fly.dev/r/obsidian-precision-5cbef2/blocks/diff-code-window.json

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

Usage

Props: heading, body, linkLabel, filePath, branchLabel – all have defaults so it renders standalone. Code lines and issue groups are static data arrays at the top of the file; edit them to change content.

components/diff-code-window.tsx
"use client";

import { useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type ElementType, type ReactNode, type RefObject } from "react";
type Props = {
  heading?: string;
  body?: string;
  linkLabel?: string;
  filePath?: string;
  branchLabel?: string;
};

const groups = [
  { name: "Needs approval", count: 2, color: "text-success", items: [
    ["APP-1204", "Add retry logic to upload queue"],
    ["APP-1198", "Display offline notice in header"],
  ]},
  { name: "Active", count: 3, color: "text-warning", items: [
    ["APP-1175", "Cache profile photos locally"],
    ["APP-1181", "Smooth out scroll jank on feed"],
    ["APP-1190", "Fix timezone drift in reminders"],
  ]},
  { name: "Backlog", count: 3, color: "text-quaternary", items: [
    ["APP-1230", "Trim bundle size of settings page"],
    ["APP-1233", "Add keyboard shortcuts overlay"],
    ["APP-1241", "Document release checklist"],
  ]},
];

type Tok = [string, string?];
const k = "text-[#e58fe0]", s = "text-[#f0d878]", f = "text-[#7cc7c0]", t = "text-[#8aa8ff]";
const lines: { n: string; kind?: "del" | "add"; toks: Tok[]; r?: Tok[] }[] = [
  { n: "01", toks: [["import ", k], ["React "], ["from ", k], ["'react'", s]] },
  { n: "02", toks: [["import ", k], ["{ Text, Spinner } "], ["from ", k], ["'ui-kit'", s]] },
  { n: "03", kind: "del", toks: [["import ", k], ["{ useCart } "], ["from ", k], ["'@hooks/useCart'", s]], r: [["import ", k], ["{ useCart, Status } "], ["from ", k]] },
  { n: "04", toks: [["import ", k], ["{ Basket } "], ["from ", k], ["'@ui/Basket'", s]] },
  { n: "05", toks: [] },
  { n: "06", toks: [["export const ", k], ["CartView ", f], ["= () => {"]] },
  { n: "07", kind: "del", toks: [["  const ", k], ["{ items, loading } = "], ["useCart", f], ["()"]] },
  { n: "08", toks: [] },
  { n: "09", kind: "del", toks: [["  if ", k], ["(loading) {"]] },
  { n: "10", toks: [["    return ", k], ["<"], ["Spinner ", t], ["size="], ["\"large\"", s], [" />"]] },
  { n: "11", toks: [["  }"]] },
  { n: "12", toks: [] },
  { n: "13", toks: [["  return ", k], ["("]] },
  { n: "14", toks: [["    <Text>", t]] },
  { n: "15", kind: "del", toks: [["      <"], ["Basket ", t], ["data={items} />"]] },
  { n: "16", toks: [["    </Text>", t]] },
  { n: "17", toks: [["  )"]] },
  { n: "18", toks: [["}"]] },
];

function Code({ add }: { add?: boolean }) {
  return (
    <div className="min-w-[520px] py-5 font-mono text-[13px] leading-6">
      {lines.map((l) => {
        const changed = !!l.kind;
        const tint = changed ? (add ? "bg-success/10 border-success" : "bg-danger/10 border-danger") : "border-transparent";
        return (
          <div key={l.n} className={`flex border-l-2 pl-8 ${tint}`}>
            <span className={`w-9 shrink-0 select-none ${changed ? (add ? "text-success" : "text-danger") : "text-quaternary"}`}>{l.n}</span>
            <span className="whitespace-pre text-primary">
              {(add && l.r ? l.r : l.toks).map((x, i) => (
                <span key={i} className={x[1]}>{x[0]}</span>
              ))}
            </span>
          </div>
        );
      })}
    </div>
  );
}

export default function SplitDiffCodeViewer({
  heading = "Plan, inspect,\nand release",
  body = "Give reviewers sharp diffs, shared context, and fewer scattered threads. Keep changes flowing while the bar stays high.",
  linkLabel = "Explore more",
  filePath = "shopfront-app/src/views/Cart/CartView.tsx",
  branchLabel = "Preview",
}: Props) {
  return (
    <section className="relative overflow-hidden bg-canvas px-6 py-24 font-sans text-primary md:px-20">
      <div className="grid gap-10 md:grid-cols-2">
        <h2 className="whitespace-pre-line text-h1 tracking-[-0.03em]">{heading}</h2>
        <div>
          <p className="text-lead text-secondary">{body}</p>
          <a href="#" className="mt-10 inline-block text-ui text-tertiary duration-link-color hover:text-primary focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent-indigo">{linkLabel} →</a>
        </div>
      </div>

      <Reveal className="relative mt-24 h-[580px]">
        <div className="absolute left-0 top-6 h-[540px] w-[78%] overflow-hidden rounded-xl border border-hairline bg-surface p-4 [mask-image:linear-gradient(to_bottom,black_60%,transparent)]">
          {groups.map((g) => (
            <div key={g.name} className="mb-3">
              <div className="flex items-center gap-2 py-2 text-ui text-primary">
                <span className="text-[9px] text-quaternary">▾</span>
                <span className={`inline-block h-3 w-3 rounded-full border-2 ${g.color}`} />
                {g.name} <span className="text-tertiary">{g.count}</span>
              </div>
              {g.items.map(([id, title]) => (
                <div key={id} className="flex items-center gap-3 py-2 pl-5 text-ui">
                  <span className="font-mono text-tertiary">{id}</span>
                  <span className={`inline-block h-3 w-3 shrink-0 rounded-full border-2 ${g.color}`} />
                  <span className="truncate text-secondary">{title}</span>
                </div>
              ))}
            </div>
          ))}
        </div>

        <div className="absolute right-0 top-0 h-[560px] w-[88%] overflow-hidden rounded-xl border border-hairline bg-canvas shadow-high md:w-[72%]">
          <div className="absolute inset-0 bg-corner-glow opacity-40" />
          <div className="relative flex h-14 items-center justify-between border-b border-hairline px-8">
            <span className="truncate font-mono text-ui text-tertiary">{filePath}</span>
            <span className="text-micro text-tertiary">{branchLabel} ⇅</span>
          </div>
          <div className="relative grid grid-cols-2 overflow-hidden">
            <div className="overflow-hidden border-r border-hairline"><Code /></div>
            <div className="overflow-hidden opacity-50"><Code add /></div>
          </div>
          <div className="pointer-events-none absolute inset-x-0 bottom-0 h-32 bg-gradient-to-t from-canvas to-transparent" />
        </div>
      </Reveal>

      <div className="mt-16 grid gap-8 md:grid-cols-2">
        <span className="text-ui text-tertiary">Highlights</span>
        <div className="grid grid-cols-2 gap-8 text-ui text-secondary">
          <ul className="space-y-2"><li>Tasks +</li><li>Walkthroughs +</li><li>Compare +</li></ul>
          <ul className="space-y-2 border-l border-hairline pl-8"><li>Automations +</li><li>Sprints +</li><li>Launches +</li></ul>
        </div>
      </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 Obsidian Precision

The whole style →

Bold Colour Testimonial Cards

Testimonials

Mono Uppercase Feature Tab List with Document Preview

Tab bars

Nested Initiatives Table

Tables

Quarterly Roadmap Board

Cards

Blur-In Word Hero with Floating App Window

Heroes

Frosted Hairline Header

Headers & nav bars