{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"ink-overlay-with-numbered-rows-that-draw-their-rules","type":"registry:block","title":"Ink Overlay With Numbered Rows That Draw Their Rules","description":"","dependencies":[],"files":[{"path":"components/we-inc/ink-overlay-with-numbered-rows-that-draw-their-rules.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 paper, overlay ink, text on the ink, rule and number accent, row stagger. */\n  .w7num { --w7num-bg: #f5f2ec; --w7num-ink: #1b1915; --w7num-dark: #171512; --w7num-paper: #f1ece2; --w7num-acc: #c9a46a; --w7num-step: .04s; --w7num-out: .4s; }\n  .w7num { position: relative; height: 600px; overflow: hidden; background: var(--w7num-bg); color: var(--w7num-ink); font-family: ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif; }\n  .w7num *, .w7num *::before, .w7num *::after { box-sizing: border-box; }\n  .w7num-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  .w7num-bar > * { pointer-events: auto; }\n  .w7num-brand { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: .01em; }\n  .w7num-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  .w7num-icon { position: relative; width: 18px; height: 10px; }\n  .w7num-icon i { position: absolute; left: 0; right: 0; height: 2px; background: currentColor; transition: transform .35s ease; }\n  .w7num-icon i:first-child { top: 0; } .w7num-icon i:last-child { bottom: 0; }\n  .w7num-open .w7num-icon i:first-child { transform: translateY(4px) rotate(45deg); }\n  .w7num-open .w7num-icon i:last-child { transform: translateY(-4px) rotate(-45deg); }\n  .w7num a:focus-visible, .w7num-btn:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }\n  .w7num-menu { visibility: hidden; transition: visibility 0s var(--w7num-out, .5s); }\n  .w7num-open .w7num-menu { visibility: visible; transition: visibility 0s; }\n  .w7num-nav ul { margin: 0; padding: 0; list-style: none; }\n  .w7num-nav a { color: inherit; text-decoration: none; }\n\n  .w7num-brand { font-family: ui-serif, Georgia, \"Times New Roman\", serif; font-weight: 400; font-size: 19px; }\n  .w7num-page { display: grid; align-items: center; gap: 32px; height: 100%; padding: 84px clamp(16px, 4vw, 48px) 32px; }\n  @media (min-width: 760px) { .w7num-page { grid-template-columns: 1.2fr 1fr; } }\n  .w7num-eye { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: #6f5a38; }\n  .w7num-title { margin: 14px 0 0; max-width: 13ch; font: 400 clamp(34px, 5.4vw, 66px)/1 ui-serif, Georgia, \"Times New Roman\", serif; letter-spacing: -.02em; }\n  .w7num-text { margin: 18px 0 0; max-width: 40ch; font-size: 16px; line-height: 1.6; color: #575148; }\n  .w7num-books { display: flex; align-items: flex-end; gap: 6px; height: 260px; justify-self: center; }\n  .w7num-books i { width: 34px; border-radius: 2px 2px 0 0; box-shadow: inset -6px 0 0 rgba(0, 0, 0, .12); }\n  .w7num-books i:nth-child(1) { height: 78%; background: #5b3a29; } .w7num-books i:nth-child(2) { height: 92%; background: #23384a; } .w7num-books i:nth-child(3) { height: 70%; background: #8a6a3b; }\n  .w7num-books i:nth-child(4) { height: 100%; background: #2f3f30; } .w7num-books i:nth-child(5) { height: 84%; background: #6d2f2a; } .w7num-books i:nth-child(6) { height: 64%; width: 26px; background: #b7a27c; }\n  @media (max-width: 759px) { .w7num-books { display: none; } }\n  .w7num-open .w7num-bar { color: var(--w7num-paper); }\n  .w7num-menu { position: absolute; z-index: 20; inset: 0; display: flex; align-items: center; padding: 84px clamp(16px, 4vw, 48px) 32px; background: var(--w7num-dark); color: var(--w7num-paper);\n    opacity: 0; transition: opacity var(--w7num-out) ease, visibility 0s var(--w7num-out); }\n  .w7num-open .w7num-menu { opacity: 1; transition: opacity .35s ease, visibility 0s; }\n  .w7num-nav { width: 100%; }\n  .w7num-nav li { position: relative; }\n  /* Each row's rule draws from the left with scaleX, then its words lift out of a mask. */\n  .w7num-nav li::before { content: \"\"; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: #4a443b; transform: scaleX(0); transform-origin: left; transition: transform .2s; }\n  .w7num-open .w7num-nav li::before { transform: none; transition: transform .5s cubic-bezier(.6, 0, .2, 1) calc(.1s + var(--i) * var(--w7num-step)); }\n  .w7num-nav a { display: flex; align-items: baseline; gap: clamp(14px, 3vw, 40px); min-height: 52px; overflow: hidden; padding: 8px 0; }\n  .w7num-nav small, .w7num-nav span { display: inline-block; transform: translateY(110%); transition: transform .2s; }\n  .w7num-open .w7num-nav small, .w7num-open .w7num-nav span { transform: none; transition: transform .45s cubic-bezier(.2, .8, .2, 1) calc(.25s + var(--i) * var(--w7num-step)); }\n  .w7num-nav small { width: 2.2em; font: 500 13px/1 ui-monospace, Menlo, monospace; color: var(--w7num-acc); }\n  .w7num-nav span { font: 400 clamp(28px, 5vw, 58px)/1.05 ui-serif, Georgia, \"Times New Roman\", serif; }\n  .w7num-nav a::after { content: \"\"; position: absolute; left: calc(2.2em + clamp(14px, 3vw, 40px)); right: 0; bottom: 6px; height: 2px; background: var(--w7num-acc); transform: scaleX(0); transform-origin: left; transition: transform .4s cubic-bezier(.2, .8, .2, 1); }\n  .w7num-nav a:focus-visible::after, .w7num-nav a[aria-current=\"page\"]::after { transform: scaleX(.18); }\n  @media (hover: hover) { .w7num-nav a:hover::after { transform: scaleX(.18); } }\n  @media (prefers-reduced-motion: reduce) { .w7num-menu, .w7num-open .w7num-menu, .w7num-nav li::before, .w7num-nav small, .w7num-nav span, .w7num-nav a::after, .w7num-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 InkNumberedRowsMenu() {\n  const ref = useRef<HTMLDivElement>(null);\n\n  useEffect(() => {\n    const root = ref.current;\n    if (!root) return;\n    const btn = root.querySelector<HTMLButtonElement>(\".w7num-btn\")!, word = root.querySelector<HTMLElement>(\".w7num-word\")!;\n    const menu = root.querySelector<HTMLElement>(\".w7num-menu\")!, page = root.querySelector<HTMLElement>(\".w7num-page\")!;\n    let used = false;\n    const isOpen = () => root.classList.contains(\"w7num-open\");\n    const set = (open: boolean, moveFocus: boolean) => {\n      root.classList.toggle(\"w7num-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=\"w7num\">\n      <style>{STYLES}</style>\n      <header className=\"w7num-bar\">\n        <p className=\"w7num-brand\">Hollis &amp; Reed Bindery</p>\n        <button className=\"w7num-btn\" type=\"button\" aria-expanded=\"false\" aria-controls=\"w7num-menu\">\n          <span className=\"w7num-word\">Menu</span><span className=\"w7num-icon\" aria-hidden=\"true\"><i></i><i></i></span>\n        </button>\n      </header>\n      <div className=\"w7num-page\">\n        <div className=\"w7num-copy\">\n          <p className=\"w7num-eye\">Hand bookbinding and repair</p>\n          <h2 className=\"w7num-title\">Old books, sewn back together.</h2>\n          <p className=\"w7num-text\">We rebind family bibles, recipe notebooks and thesis copies in cloth or leather, by hand, at a bench in a converted dairy.</p>\n        </div>\n        <div className=\"w7num-books\" aria-hidden=\"true\"><i></i><i></i><i></i><i></i><i></i><i></i></div>\n      </div>\n      <div className=\"w7num-menu\" id=\"w7num-menu\">\n        <nav className=\"w7num-nav\" aria-label=\"Main\">\n          <ul>\n            <li style={{ \"--i\": 0 } as CSSProperties}><a href=\"#\" aria-current=\"page\"><small>01</small><span>Home</span></a></li>\n            <li style={{ \"--i\": 1 } as CSSProperties}><a href=\"#\"><small>02</small><span>Repairs</span></a></li>\n            <li style={{ \"--i\": 2 } as CSSProperties}><a href=\"#\"><small>03</small><span>New bindings</span></a></li>\n            <li style={{ \"--i\": 3 } as CSSProperties}><a href=\"#\"><small>04</small><span>Workshops</span></a></li>\n            <li style={{ \"--i\": 4 } as CSSProperties}><a href=\"#\"><small>05</small><span>Get a quote</span></a></li>\n          </ul>\n        </nav>\n      </div>\n    </div>\n  );\n}\n"}]}
