{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"terminal-command-css-typewriter-with-output-lines","type":"registry:component","title":"Terminal Command Typewriter","description":"","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/terminal-command-css-typewriter-with-output-lines.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\nimport { useReducedMotion } from \"framer-motion\";\n\n// The command (28 characters, so steps(28) and --ttw-n: 28) and the lines it prints.\nconst COMMAND = \"shop deploy --env production\";\nconst OUTPUT = [\n  { cls: \"ttw-dim\", text: \"  Building 18 pages and 42 images\" },\n  { cls: \"ttw-dim\", text: \"  Compressing photos for phones\" },\n  { cls: \"ttw-dim\", text: \"  Checking every link on the site\" },\n  { cls: \"ttw-ok\", text: \"  Live at fernandfig.shop\" },\n];\n\nexport default function TerminalCommandTypewriter() {\n  const rootRef = useRef<HTMLElement>(null);\n  const [paused, setPaused] = useState(false);\n  const reduce = useReducedMotion();\n\n  useEffect(() => {\n    const el = rootRef.current;\n    if (!el || typeof IntersectionObserver === \"undefined\") return;\n    const io = new IntersectionObserver(([entry]) => setPaused(!entry.isIntersecting));\n    io.observe(el);\n    return () => io.disconnect();\n  }, []);\n\n  return (\n    <section ref={rootRef} data-paused={paused ? \"true\" : \"false\"} data-still={reduce ? \"true\" : \"false\"} className=\"ttw-root\" style={{ [\"--ttw-n\" as string]: COMMAND.length, [\"--ttw-cycle\" as string]: \"9s\" }}>\n      <style>{`\n    .ttw-root { background: #e9ecef; padding: 80px 16px; font-family: ui-sans-serif, system-ui, sans-serif; }\n    .ttw-root * { box-sizing: border-box; }\n    .ttw-win { max-width: 40rem; margin: 0 auto; border-radius: 14px; background: #1b1e22; box-shadow: 0 1px 0 rgba(255,255,255,0.06) inset, 0 30px 60px -30px rgba(15,20,25,0.55), 0 12px 24px -12px rgba(15,20,25,0.35); overflow: hidden; }\n    .ttw-bar { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; background: #24282d; border-bottom: 1px solid #30353b; }\n    .ttw-dot { width: 11px; height: 11px; border-radius: 50%; background: #4a5058; }\n    .ttw-title { flex: 1; text-align: center; margin-right: 46px; font-size: 12px; color: #a3abb4; }\n    .ttw-body { padding: 22px 16px 26px; font-family: ui-monospace, \"SF Mono\", Menlo, Consolas, monospace; font-size: clamp(11px, 2.9vw, 15.5px); line-height: 1.75; color: #e4e4df; white-space: nowrap; }\n    .ttw-p { color: #93c3a3; }\n    .ttw-dim { color: #a3abb4; }\n    .ttw-ok { color: #93c3a3; }\n    .ttw-cmd { display: inline-block; overflow: hidden; vertical-align: bottom; width: calc(var(--ttw-n) * 1ch); animation: ttw-type var(--ttw-cycle) infinite; animation-delay: -2.2s; }\n    .ttw-caret { display: inline-block; width: 0.6ch; height: 1.15em; vertical-align: -0.2em; background: #e4e4df; animation: ttw-blink 1s steps(1) infinite; }\n    .ttw-out { opacity: 0; animation: var(--ttw-cycle) infinite; animation-delay: -2.2s; }\n    .ttw-o1 { animation-name: ttw-o1; } .ttw-o2 { animation-name: ttw-o2; } .ttw-o3 { animation-name: ttw-o3; } .ttw-o4 { animation-name: ttw-o4; }\n    @keyframes ttw-type { 0% { width: 0; animation-timing-function: steps(28, end); } 22%, 94% { width: calc(var(--ttw-n) * 1ch); } 95%, 100% { width: 0; } }\n    @keyframes ttw-o1 { 0%, 27% { opacity: 0; } 28%, 93% { opacity: 1; } 95%, 100% { opacity: 0; } }\n    @keyframes ttw-o2 { 0%, 35% { opacity: 0; } 36%, 93% { opacity: 1; } 95%, 100% { opacity: 0; } }\n    @keyframes ttw-o3 { 0%, 45% { opacity: 0; } 46%, 93% { opacity: 1; } 95%, 100% { opacity: 0; } }\n    @keyframes ttw-o4 { 0%, 55% { opacity: 0; } 56.5%, 93% { opacity: 1; } 95%, 100% { opacity: 0; } }\n    @keyframes ttw-blink { 0%, 55% { opacity: 1; } 56%, 100% { opacity: 0; } }\n    .ttw-root[data-paused=\"true\"] .ttw-cmd, .ttw-root[data-paused=\"true\"] .ttw-out, .ttw-root[data-paused=\"true\"] .ttw-caret { animation-play-state: paused; }\n    .ttw-copy { max-width: 40rem; margin: 22px auto 0; text-align: center; font-size: 15px; color: #475569; }\n        .ttw-root[data-still=\"true\"] .ttw-cmd, .ttw-root[data-still=\"true\"] .ttw-caret { animation: none; }\n        .ttw-root[data-still=\"true\"] .ttw-out { animation: none; opacity: 1; }\n        @media (prefers-reduced-motion: reduce) { .ttw-cmd, .ttw-caret { animation: none; } .ttw-out { animation: none; opacity: 1; } }\n      `}</style>\n      <h2 className=\"sr-only\">Deploying the Fern and Fig shop</h2>\n      <p className=\"sr-only\">Command: {COMMAND}. Output: {OUTPUT.map((l) => l.text.trim()).join(\". \")}.</p>\n      <div className=\"ttw-win\" aria-hidden=\"true\">\n        <div className=\"ttw-bar\">\n          <span className=\"ttw-dot\" />\n          <span className=\"ttw-dot\" />\n          <span className=\"ttw-dot\" />\n          <span className=\"ttw-title\">fern-and-fig: zsh</span>\n        </div>\n        <div className=\"ttw-body\">\n          <div>\n            <span className=\"ttw-p\">~/fern-and-fig $ </span>\n            <span className=\"ttw-cmd\">{COMMAND}</span>\n            <span className=\"ttw-caret\" />\n          </div>\n          {OUTPUT.map((l, k) => (\n            <div key={k} className={`ttw-out ttw-o${k + 1} ${l.cls}`}>{k === OUTPUT.length - 1 ? \"✓\" : \"›\"}{l.text}</div>\n          ))}\n        </div>\n      </div>\n      <p className=\"ttw-copy\">Pure CSS: the command types with steps(), and each line of output fades in on its own beat.</p>\n    </section>\n  );\n}\n"}]}
