"use client"; import { useState } from "react"; import Link from "next/link"; import { appConfig } from "@/config/app.config"; 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(appConfig.ai.defaultModel); const [additionalInstructions, setAdditionalInstructions] = useState(""); const [isValidUrl, setIsValidUrl] = useState(false); // Simple URL validation - currently unused but keeping for future use // 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 = appConfig.ai.availableModels.map(model => ({ id: model, name: appConfig.ai.modelDisplayNames[model] || model, })); 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 */}
)}
); }