"use client"; import { useState } from "react"; import Globe from "@/components/app/(home)/sections/hero-input/_svg/Globe"; import HeroInputSubmitButton from "@/components/app/(home)/sections/hero-input/Button/Button"; interface SidebarInputProps { onSubmit: (url: string, style: string, model: string, instructions?: string) => void; disabled?: boolean; } export default function SidebarInput({ onSubmit, disabled = false }: SidebarInputProps) { const [url, setUrl] = useState(""); const [selectedStyle, setSelectedStyle] = useState("1"); const [selectedModel, setSelectedModel] = useState("moonshotai/kimi-k2-instruct-0905"); const [additionalInstructions, setAdditionalInstructions] = useState(""); const [isValidUrl, setIsValidUrl] = useState(false); // Simple URL validation const validateUrl = (urlString: string) => { if (!urlString) return false; const urlPattern = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/; return urlPattern.test(urlString.toLowerCase()); }; const styles = [ { id: "1", name: "Glassmorphism", description: "Frosted glass effect" }, { id: "2", name: "Neumorphism", description: "Soft 3D shadows" }, { id: "3", name: "Brutalism", description: "Bold and raw" }, { id: "4", name: "Minimalist", description: "Clean and simple" }, { id: "5", name: "Dark Mode", description: "Dark theme design" }, { id: "6", name: "Gradient Rich", description: "Vibrant gradients" }, { id: "7", name: "3D Depth", description: "Dimensional layers" }, { id: "8", name: "Retro Wave", description: "80s inspired" }, ]; const models = [ { id: "moonshotai/kimi-k2-instruct-0905", name: "Kimi K2 0905 on Groq" }, { id: "openai/gpt-5", name: "GPT-5" }, { id: "anthropic/claude-sonnet-4-20250514", name: "Sonnet 4" }, { id: "google/gemini-2.0-flash-exp", name: "Gemini 2.0" }, ]; const handleSubmit = (e?: React.FormEvent) => { if (e) e.preventDefault(); if (!url.trim() || disabled) return; onSubmit(url.trim(), selectedStyle, selectedModel, additionalInstructions || undefined); // Reset form setUrl(""); setAdditionalInstructions(""); setIsValidUrl(false); }; return (
{/* link to home page with button */}
{/* Options Section - Show when valid URL */} {isValidUrl && (
{/* Style Selector */}
{styles.map((style) => ( ))}
{/* Model Selector */}
{/* Additional Instructions */}
setAdditionalInstructions(e.target.value)} disabled={disabled} className="w-full px-3 py-2 text-xs text-gray-700 bg-gray-50 rounded border border-gray-200 focus:border-orange-500 focus:outline-none focus:ring-1 focus:ring-orange-500 placeholder:text-gray-400" placeholder="e.g., make it more colorful, add animations..." />
{/* Submit Button */}
)}
); }