import { useState, useRef, useEffect } from "react"; import { PROMPTS } from "../constants"; import GlassContainer from "./GlassContainer"; interface PromptInputProps { onPromptChange: (prompt: string) => void; defaultPrompt?: string; } export default function PromptInput({ onPromptChange, defaultPrompt = PROMPTS.default }: PromptInputProps) { const [prompt, setPrompt] = useState(defaultPrompt); const [showSuggestions, setShowSuggestions] = useState(false); const inputRef = useRef(null); const containerRef = useRef(null); const resizeTextarea = () => { if (inputRef.current) { inputRef.current.style.height = "auto"; const newHeight = Math.min(inputRef.current.scrollHeight, 200); inputRef.current.style.height = `${newHeight}px`; } }; useEffect(() => { onPromptChange(prompt); resizeTextarea(); }, [prompt, onPromptChange]); const handleInputFocus = () => { setShowSuggestions(true); }; const handleInputClick = () => { setShowSuggestions(true); }; const handleInputBlur = (e: React.FocusEvent) => { if (!e.relatedTarget || !containerRef.current?.contains(e.relatedTarget as Node)) { setShowSuggestions(false); } }; const handleSuggestionClick = (suggestion: string) => { setPrompt(suggestion); setShowSuggestions(false); inputRef.current?.focus(); }; const clearInput = () => { setPrompt(""); inputRef.current?.focus(); }; const handleInputChange = (e: React.ChangeEvent) => { setPrompt(e.target.value); }; return (
{/* Suggestions Panel */}

Suggested Prompts

    {PROMPTS.suggestions.map((suggestion, index) => (
  • { e.preventDefault(); }} onClick={() => handleSuggestionClick(suggestion)} onKeyDown={(e) => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); handleSuggestionClick(suggestion); } }} className="py-2 px-3 rounded-lg cursor-pointer flex items-center gap-3 transition-all duration-200 hover:bg-white/20 hover:translate-x-1 hover:shadow-sm focus:bg-white/20 focus:translate-x-1 focus:outline-none" > {suggestion}
  • ))}
{/* Input Container */}