'use client'; import { forwardRef, HTMLAttributes } from 'react'; export interface TerminalMessageProps extends HTMLAttributes { /** Message content */ children: string; /** Prompt text */ prompt?: string; /** Message type */ type?: 'system' | 'info' | 'warning' | 'error' | 'success'; /** Show blinking cursor */ showCursor?: boolean; /** Typing animation */ typing?: boolean; /** Typing speed in ms per character */ typingSpeed?: number; } const typeStyles = { system: { color: 'text-green-500', prefix: '' }, info: { color: 'text-sky-500', prefix: '[INFO] ' }, warning: { color: 'text-amber-500', prefix: '[WARN] ' }, error: { color: 'text-red-500', prefix: '[ERROR] ' }, success: { color: 'text-green-500', prefix: '[OK] ' }, }; export const TerminalMessage = forwardRef( ( { children, prompt = '>', type = 'system', showCursor = false, typing = false, typingSpeed = 50, className = '', ...props }, ref ) => { const styles = typeStyles[type]; return (
{prompt} {type !== 'system' && styles.prefix}{children} {showCursor && ( )}
); } ); TerminalMessage.displayName = 'TerminalMessage'; export default TerminalMessage;