{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"graphite-split-halves-that-close-over-the-page","type":"registry:block","title":"Graphite Split Halves That Close Over the Page","description":"","dependencies":[],"files":[{"path":"components/we-inc/graphite-split-halves-that-close-over-the-page.tsx","type":"registry:component","content":"import { useEffect, useRef, type CSSProperties } from \"react\";\n\n// Same styles as the plain HTML version; the comment at the top names the values to change.\nconst STYLES = `\n  /* Change these: page colour, upper half, lower half, text colour, accent, slide time. */\n  .w7spl { --w7spl-bg: #e9e7e3; --w7spl-ink: #1f2023; --w7spl-up: #26272b; --w7spl-low: #34363b; --w7spl-pale: #ecebe8; --w7spl-acc: #d4c3a3; --w7spl-speed: .6s; --w7spl-out: .5s; }\n  .w7spl { position: relative; height: 600px; overflow: hidden; background: var(--w7spl-bg); color: var(--w7spl-ink); font-family: ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif; }\n  .w7spl *, .w7spl *::before, .w7spl *::after { box-sizing: border-box; }\n  .w7spl-bar { position: absolute; z-index: 30; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; padding: 14px clamp(16px, 4vw, 48px); pointer-events: none; }\n  .w7spl-bar > * { pointer-events: auto; }\n  .w7spl-brand { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: .01em; }\n  .w7spl-btn { display: inline-flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 18px; border: 1px solid currentColor; border-radius: 999px; background: transparent; color: inherit; font: inherit; font-size: 14px; font-weight: 600; line-height: 1; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; }\n  .w7spl-icon { position: relative; width: 18px; height: 10px; }\n  .w7spl-icon i { position: absolute; left: 0; right: 0; height: 2px; background: currentColor; transition: transform .35s ease; }\n  .w7spl-icon i:first-child { top: 0; } .w7spl-icon i:last-child { bottom: 0; }\n  .w7spl-open .w7spl-icon i:first-child { transform: translateY(4px) rotate(45deg); }\n  .w7spl-open .w7spl-icon i:last-child { transform: translateY(-4px) rotate(-45deg); }\n  .w7spl a:focus-visible, .w7spl-btn:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }\n  .w7spl-menu { visibility: hidden; transition: visibility 0s var(--w7spl-out, .5s); }\n  .w7spl-open .w7spl-menu { visibility: visible; transition: visibility 0s; }\n  .w7spl-nav ul { margin: 0; padding: 0; list-style: none; }\n  .w7spl-nav a { color: inherit; text-decoration: none; }\n\n  .w7spl-page { display: flex; flex-direction: column; justify-content: center; height: 100%; padding: 84px clamp(16px, 4vw, 48px) 32px; }\n  .w7spl-eye { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: #5c5a55; }\n  .w7spl-title { margin: 14px 0 0; max-width: 18ch; font-size: clamp(30px, 5vw, 60px); font-weight: 500; line-height: 1.04; letter-spacing: -.035em; }\n  .w7spl-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; max-width: 560px; margin-top: 28px; }\n  .w7spl-grid i { height: 64px; border: 1px solid #b9b5ad; background: linear-gradient(135deg, transparent 49.5%, #c9c5bd 50%, transparent 50.5%); }\n  .w7spl-text { margin: 24px 0 0; max-width: 46ch; font-size: 15px; line-height: 1.6; color: #4b4a46; }\n  .w7spl-open .w7spl-bar { color: var(--w7spl-pale); }\n  .w7spl-menu { position: absolute; z-index: 20; inset: 0; color: var(--w7spl-pale); }\n  /* Two halves: the upper one comes down, the lower one comes up, and they meet at the middle line. */\n  .w7spl-half { position: absolute; left: 0; right: 0; height: 50%; display: flex; padding: 0 clamp(16px, 4vw, 48px); transition: transform var(--w7spl-out) cubic-bezier(.7, 0, .3, 1); }\n  .w7spl-top { top: 0; align-items: flex-end; padding-bottom: 20px; background: var(--w7spl-up); transform: translateY(-100%); }\n  .w7spl-bot { bottom: 0; align-items: flex-start; padding-top: 22px; background: var(--w7spl-low); transform: translateY(100%); }\n  .w7spl-open .w7spl-half { transform: none; transition: transform var(--w7spl-speed) cubic-bezier(.7, 0, .2, 1); }\n  .w7spl-nav ul { display: flex; flex-wrap: wrap; gap: 0 clamp(16px, 3.5vw, 48px); }\n  .w7spl-nav li { overflow: hidden; }\n  .w7spl-nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 2px; font-size: clamp(30px, 6vw, 72px); font-weight: 500; letter-spacing: -.04em; line-height: 1.1; }\n  .w7spl-nav a span { display: inline-block; transform: translateY(105%); transition: transform .2s; }\n  .w7spl-open .w7spl-nav a span { transform: none; transition: transform .4s cubic-bezier(.2, .8, .2, 1) calc(var(--w7spl-speed) * .5 + var(--i) * .04s); }\n  .w7spl-nav a[aria-current=\"page\"] { color: var(--w7spl-acc); }\n  @media (hover: hover) { .w7spl-nav a:hover { color: var(--w7spl-acc); } }\n  .w7spl-info { display: flex; flex-wrap: wrap; gap: 12px 48px; font-size: 15px; line-height: 1.5; opacity: 0; transform: translateY(-10px); transition: opacity .2s, transform .2s; }\n  .w7spl-open .w7spl-info { opacity: 1; transform: none; transition: opacity .3s, transform .3s; transition-delay: calc(var(--w7spl-speed) * .8); }\n  .w7spl-info p { margin: 0; } .w7spl-k { display: block; margin-bottom: 4px; font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: #b3b0a9; }\n  .w7spl-info a { display: inline-flex; align-items: center; min-height: 40px; color: inherit; }\n  @media (max-width: 600px) { .w7spl-nav ul { flex-direction: column; } .w7spl-nav a { min-height: 40px; } }\n  @media (prefers-reduced-motion: reduce) { .w7spl-half, .w7spl-nav a span, .w7spl-info, .w7spl-icon i { transition: none !important; } }\n`; // end STYLES\n\n// When the demo opens the menu by itself (ms). Set 0 on a real site.\nconst AUTO_OPEN = 500;\n\nexport default function GraphiteSplitHalvesMenu() {\n  const ref = useRef<HTMLDivElement>(null);\n\n  useEffect(() => {\n    const root = ref.current;\n    if (!root) return;\n    const btn = root.querySelector<HTMLButtonElement>(\".w7spl-btn\")!, word = root.querySelector<HTMLElement>(\".w7spl-word\")!;\n    const menu = root.querySelector<HTMLElement>(\".w7spl-menu\")!, page = root.querySelector<HTMLElement>(\".w7spl-page\")!;\n    let used = false;\n    const isOpen = () => root.classList.contains(\"w7spl-open\");\n    const set = (open: boolean, moveFocus: boolean) => {\n      root.classList.toggle(\"w7spl-open\", open);\n      btn.setAttribute(\"aria-expanded\", String(open));\n      word.textContent = open ? \"Close\" : \"Menu\";\n      menu.toggleAttribute(\"inert\", !open);\n      page.toggleAttribute(\"inert\", open); // on a real page, make main and footer inert instead\n      if (moveFocus) (open ? menu.querySelector<HTMLElement>(\"a\")! : btn).focus();\n    };\n    menu.toggleAttribute(\"inert\", true);\n    const touch = () => { used = true; };\n    const onClick = () => { touch(); set(!isOpen(), true); };\n    const onKey = (e: KeyboardEvent) => {\n      if (!isOpen()) return;\n      if (e.key === \"Escape\") { e.preventDefault(); set(false, true); return; }\n      if (e.key !== \"Tab\") return;\n      // focus trap: the button plus everything in the menu\n      const f: HTMLElement[] = [btn, ...Array.from(menu.querySelectorAll<HTMLElement>(\"a[href], button\"))];\n      const i = f.indexOf(document.activeElement as HTMLElement);\n      if (e.shiftKey && i <= 0) { e.preventDefault(); f[f.length - 1].focus(); }\n      else if (!e.shiftKey && i === f.length - 1) { e.preventDefault(); f[0].focus(); }\n    };\n    const onPick = (e: MouseEvent) => {\n      const a = (e.target as HTMLElement).closest(\"a\");\n      if (!a) return;\n      e.preventDefault(); // remove on a real site so the link navigates\n      if (a.closest(\"nav\")) { menu.querySelectorAll(\"[aria-current]\").forEach((x) => x.removeAttribute(\"aria-current\")); a.setAttribute(\"aria-current\", \"page\"); }\n      set(false, true);\n    };\n    btn.addEventListener(\"click\", onClick);\n    root.addEventListener(\"pointerdown\", touch);\n    root.addEventListener(\"focusin\", touch);\n    root.addEventListener(\"keydown\", onKey);\n    menu.addEventListener(\"click\", onPick);\n    const t = AUTO_OPEN ? window.setTimeout(() => { if (!used) set(true, false); }, AUTO_OPEN) : 0;\n    return () => {\n      window.clearTimeout(t);\n      btn.removeEventListener(\"click\", onClick);\n      root.removeEventListener(\"pointerdown\", touch);\n      root.removeEventListener(\"focusin\", touch);\n      root.removeEventListener(\"keydown\", onKey);\n      menu.removeEventListener(\"click\", onPick);\n    };\n  }, []);\n\n  return (\n    <div ref={ref} className=\"w7spl\">\n      <style>{STYLES}</style>\n      <header className=\"w7spl-bar\">\n        <p className=\"w7spl-brand\">Okafor Lane Architects</p>\n        <button className=\"w7spl-btn\" type=\"button\" aria-expanded=\"false\" aria-controls=\"w7spl-menu\">\n          <span className=\"w7spl-word\">Menu</span><span className=\"w7spl-icon\" aria-hidden=\"true\"><i></i><i></i></span>\n        </button>\n      </header>\n      <div className=\"w7spl-page\">\n        <p className=\"w7spl-eye\">Architecture and interiors</p>\n        <h2 className=\"w7spl-title\">Buildings that keep their shape for a long time.</h2>\n        <div className=\"w7spl-grid\" aria-hidden=\"true\"><i></i><i></i><i></i><i></i></div>\n        <p className=\"w7spl-text\">A practice of nine working on homes, small schools and workshop conversions, mostly within a day's drive of the studio.</p>\n      </div>\n      <div className=\"w7spl-menu\" id=\"w7spl-menu\">\n        <div className=\"w7spl-half w7spl-top\">\n          <nav className=\"w7spl-nav\" aria-label=\"Main\">\n            <ul>\n            <li style={{ \"--i\": 0 } as CSSProperties}><a href=\"#\" aria-current=\"page\"><span>Projects</span></a></li>\n            <li style={{ \"--i\": 1 } as CSSProperties}><a href=\"#\"><span>Practice</span></a></li>\n            <li style={{ \"--i\": 2 } as CSSProperties}><a href=\"#\"><span>Journal</span></a></li>\n            <li style={{ \"--i\": 3 } as CSSProperties}><a href=\"#\"><span>Contact</span></a></li>\n            </ul>\n          </nav>\n        </div>\n        <div className=\"w7spl-half w7spl-bot\">\n          <div className=\"w7spl-info\">\n            <p><span className=\"w7spl-k\">Studio</span>4 Tanner Yard, second floor</p>\n            <p><span className=\"w7spl-k\">New work</span><a href=\"#\">Send us a brief</a></p>\n          </div>\n        </div>\n      </div>\n    </div>\n  );\n}\n"}]}
