({ className }: IDEDemoProps)
| 175 | const EXPAND_TERMINAL_DELAY = 500 |
| 176 | |
| 177 | export function IDEDemo({ className }: IDEDemoProps) { |
| 178 | const [showIDE, setShowIDE] = useState(false) |
| 179 | const [showOriginalTerminal, setShowOriginalTerminal] = useState(true) |
| 180 | const [expandTerminal, setExpandTerminal] = useState(false) |
| 181 | |
| 182 | const [terminalLines, setTerminalLines] = useState<string[]>([]) |
| 183 | const [typingText, setTypingText] = useState('') |
| 184 | const [isTyping, setIsTyping] = useState(false) |
| 185 | const [isMobile, setIsMobile] = useState(false) |
| 186 | const editorRef = useRef<HTMLDivElement>(null) |
| 187 | |
| 188 | useEffect(() => { |
| 189 | const checkMobile = () => { |
| 190 | setIsMobile(window.innerWidth < 768) |
| 191 | } |
| 192 | |
| 193 | checkMobile() |
| 194 | |
| 195 | window.addEventListener('resize', checkMobile) |
| 196 | return () => window.removeEventListener('resize', checkMobile) |
| 197 | }, []) |
| 198 | |
| 199 | useEffect(() => { |
| 200 | const timeoutIds: NodeJS.Timeout[] = [] |
| 201 | |
| 202 | // Step 1: Show the IDE |
| 203 | const timer1 = setTimeout(() => { |
| 204 | setShowIDE(true) |
| 205 | }, SHOW_IDE_DELAY) |
| 206 | timeoutIds.push(timer1) |
| 207 | |
| 208 | // Step 2: Hide the original terminal |
| 209 | const timer2 = setTimeout(() => { |
| 210 | setShowOriginalTerminal(false) |
| 211 | }, SHOW_IDE_DELAY + HIDE_TERMINAL_DELAY) |
| 212 | timeoutIds.push(timer2) |
| 213 | |
| 214 | // Step 3: Expand the terminal |
| 215 | const timer3 = setTimeout( |
| 216 | () => { |
| 217 | setExpandTerminal(true) |
| 218 | }, |
| 219 | SHOW_IDE_DELAY + HIDE_TERMINAL_DELAY + EXPAND_TERMINAL_DELAY, |
| 220 | ) |
| 221 | timeoutIds.push(timer3) |
| 222 | |
| 223 | // Cleanup all timeouts on component unmount |
| 224 | return () => { |
| 225 | timeoutIds.forEach((id) => clearTimeout(id)) |
| 226 | } |
| 227 | }, []) |
| 228 | |
| 229 | useEffect(() => { |
| 230 | if (!showIDE) return |
| 231 | |
| 232 | const messages = [ |
| 233 | 'Codebuff will read and write files in "/Users/me/projects/your-next-app". Type "help" for commands.', |
| 234 | 'Welcome back! What would you like to do?', |
nothing calls this directly
no test coverage detected