2026-05-23 14:25:28 -07:00
|
|
|
import React, { useState, KeyboardEvent } from 'react';
|
|
|
|
|
|
|
|
|
|
interface Props { disabled?: boolean; placeholder?: string; onSend: (text: string) => void; }
|
|
|
|
|
|
|
|
|
|
export const ChatInput: React.FC<Props> = ({ disabled, placeholder, onSend }) => {
|
|
|
|
|
const [v, setV] = useState('');
|
|
|
|
|
const fire = () => { const t = v.trim(); if (!t || disabled) return; onSend(t); setV(''); };
|
|
|
|
|
const onKey = (e: KeyboardEvent<HTMLTextAreaElement>) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); fire(); } };
|
|
|
|
|
return (
|
|
|
|
|
<div style={{ display: 'flex', gap: 8, padding: '8px 0' }}>
|
|
|
|
|
<textarea value={v} onChange={(e) => setV(e.target.value)} onKeyDown={onKey} rows={2} disabled={disabled}
|
|
|
|
|
placeholder={placeholder || 'Describe what you want...'}
|
2026-07-13 07:30:12 -07:00
|
|
|
className="sitesmith-textarea"
|
2026-05-23 14:25:28 -07:00
|
|
|
style={{
|
|
|
|
|
flex: 1, background: disabled ? '#1f1f24' : '#0f0f17', color: '#e5e7eb',
|
|
|
|
|
border: '1px solid #3f3f46', borderRadius: 6, padding: 10, fontSize: 14, resize: 'none',
|
|
|
|
|
}} />
|
|
|
|
|
<button onClick={fire} disabled={disabled || v.trim() === ''}
|
|
|
|
|
style={{
|
|
|
|
|
background: disabled ? '#27272a' : '#7c3aed', color: '#fff',
|
|
|
|
|
border: 'none', padding: '0 16px', borderRadius: 6,
|
|
|
|
|
cursor: disabled ? 'not-allowed' : 'pointer', fontWeight: 500,
|
|
|
|
|
}}>→</button>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|