|
| 1 | +import { useState, useEffect } from 'react'; |
| 2 | +import { Link } from 'react-router-dom'; |
| 3 | +import { Navbar, Footer } from '@/components/layout'; |
| 4 | + |
| 5 | +const messages = [ |
| 6 | + 'Initializing documentation system...', |
| 7 | + 'Loading ReifyDB knowledge base...', |
| 8 | + 'Preparing RQL tutorials...', |
| 9 | + 'Documentation coming soon...', |
| 10 | +]; |
| 11 | + |
| 12 | +export function DocsWipTerminal() { |
| 13 | + const [messageIndex, setMessageIndex] = useState(0); |
| 14 | + const [displayText, setDisplayText] = useState(''); |
| 15 | + const [charIndex, setCharIndex] = useState(0); |
| 16 | + const [showCursor, setShowCursor] = useState(true); |
| 17 | + const [phase, setPhase] = useState<'typing' | 'pause' | 'clearing'>('typing'); |
| 18 | + |
| 19 | + // Typing effect |
| 20 | + useEffect(() => { |
| 21 | + const currentMessage = messages[messageIndex]; |
| 22 | + |
| 23 | + if (phase === 'typing') { |
| 24 | + if (charIndex < currentMessage.length) { |
| 25 | + const timeout = setTimeout(() => { |
| 26 | + setDisplayText(currentMessage.substring(0, charIndex + 1)); |
| 27 | + setCharIndex(charIndex + 1); |
| 28 | + }, 60); |
| 29 | + return () => clearTimeout(timeout); |
| 30 | + } else { |
| 31 | + // Finished typing |
| 32 | + if (messageIndex === messages.length - 1) { |
| 33 | + // Stay on the last message |
| 34 | + return; |
| 35 | + } |
| 36 | + const timeout = setTimeout(() => { |
| 37 | + setPhase('clearing'); |
| 38 | + }, 1500); |
| 39 | + return () => clearTimeout(timeout); |
| 40 | + } |
| 41 | + } else if (phase === 'clearing') { |
| 42 | + if (charIndex > 0) { |
| 43 | + const timeout = setTimeout(() => { |
| 44 | + setDisplayText(currentMessage.substring(0, charIndex - 1)); |
| 45 | + setCharIndex(charIndex - 1); |
| 46 | + }, 25); |
| 47 | + return () => clearTimeout(timeout); |
| 48 | + } else { |
| 49 | + setMessageIndex((prev) => prev + 1); |
| 50 | + setPhase('typing'); |
| 51 | + } |
| 52 | + } |
| 53 | + }, [charIndex, phase, messageIndex]); |
| 54 | + |
| 55 | + // Blinking cursor effect |
| 56 | + useEffect(() => { |
| 57 | + const cursorInterval = setInterval(() => { |
| 58 | + setShowCursor((prev) => !prev); |
| 59 | + }, 530); |
| 60 | + return () => clearInterval(cursorInterval); |
| 61 | + }, []); |
| 62 | + |
| 63 | + return ( |
| 64 | + <div className="min-h-screen flex flex-col"> |
| 65 | + <Navbar /> |
| 66 | + |
| 67 | + <main className="flex-1 flex items-center justify-center bg-bg-primary px-6 py-16"> |
| 68 | + <div className="w-full max-w-2xl"> |
| 69 | + {/* Terminal Window */} |
| 70 | + <div className="bg-white border-2 border-border-default rounded-lg overflow-hidden shadow-minimal"> |
| 71 | + {/* macOS Chrome Header */} |
| 72 | + <div className="h-10 sm:h-12 bg-bg-primary border-b-2 border-border-default flex items-center px-3 sm:px-4 gap-2"> |
| 73 | + <div className="flex gap-1.5"> |
| 74 | + <div |
| 75 | + className="w-3 h-3 rounded-full" |
| 76 | + style={{ backgroundColor: 'var(--color-status-error)' }} |
| 77 | + /> |
| 78 | + <div |
| 79 | + className="w-3 h-3 rounded-full" |
| 80 | + style={{ backgroundColor: 'var(--color-accent-yellow)' }} |
| 81 | + /> |
| 82 | + <div |
| 83 | + className="w-3 h-3 rounded-full" |
| 84 | + style={{ backgroundColor: 'var(--color-feature-green)' }} |
| 85 | + /> |
| 86 | + </div> |
| 87 | + <span className="text-xs font-bold tracking-wide ml-2">reifydb@docs</span> |
| 88 | + </div> |
| 89 | + |
| 90 | + {/* Terminal Body */} |
| 91 | + <div className="p-6 sm:p-8 font-mono text-sm sm:text-base leading-relaxed bg-white text-text-primary min-h-[200px]"> |
| 92 | + {/* Previous completed messages */} |
| 93 | + {messages.slice(0, messageIndex).map((msg, idx) => ( |
| 94 | + <div key={idx} className="flex items-center mb-2 text-text-muted"> |
| 95 | + <span style={{ color: 'var(--color-feature-teal)' }}>$</span> |
| 96 | + <span className="ml-2">{msg}</span> |
| 97 | + <span className="ml-2" style={{ color: 'var(--color-feature-green)' }}> |
| 98 | + OK |
| 99 | + </span> |
| 100 | + </div> |
| 101 | + ))} |
| 102 | + |
| 103 | + {/* Current typing line */} |
| 104 | + <div className="flex items-center"> |
| 105 | + <span style={{ color: 'var(--color-feature-teal)' }}>$</span> |
| 106 | + <span className="ml-2">{displayText}</span> |
| 107 | + <span |
| 108 | + className={`ml-0.5 transition-opacity ${showCursor ? 'opacity-100' : 'opacity-0'}`} |
| 109 | + > |
| 110 | + █ |
| 111 | + </span> |
| 112 | + </div> |
| 113 | + </div> |
| 114 | + </div> |
| 115 | + |
| 116 | + {/* Info text below terminal */} |
| 117 | + <div className="mt-8 text-center"> |
| 118 | + <p className="text-text-secondary mb-4"> |
| 119 | + We're actively writing comprehensive documentation for ReifyDB. |
| 120 | + </p> |
| 121 | + <p className="text-text-muted text-sm mb-6"> |
| 122 | + In the meantime, check out our GitHub repository for examples and source code. |
| 123 | + </p> |
| 124 | + |
| 125 | + {/* Action buttons */} |
| 126 | + <div className="flex flex-col sm:flex-row items-center justify-center gap-4"> |
| 127 | + <a |
| 128 | + href="https://github.com/reifydb/reifydb" |
| 129 | + target="_blank" |
| 130 | + rel="noopener noreferrer" |
| 131 | + className="inline-flex items-center gap-2 px-6 py-3 bg-border-default text-white font-bold border-2 border-border-default rounded hover:shadow-minimal-md transition-all" |
| 132 | + > |
| 133 | + View on GitHub |
| 134 | + </a> |
| 135 | + <Link |
| 136 | + to="/" |
| 137 | + className="inline-flex items-center gap-2 px-6 py-3 bg-white text-text-primary font-bold border-2 border-border-default rounded hover:shadow-minimal-md transition-all" |
| 138 | + > |
| 139 | + Back to Home |
| 140 | + </Link> |
| 141 | + </div> |
| 142 | + </div> |
| 143 | + </div> |
| 144 | + </main> |
| 145 | + |
| 146 | + <Footer /> |
| 147 | + </div> |
| 148 | + ); |
| 149 | +} |
0 commit comments