'use client' import { useState, useRef } from 'react' import { Upload, Link as LinkIcon, Sparkles, X, Image as ImageIcon } from 'lucide-react' import { AppIcon } from './AppIcon' import { cn } from '@/lib/utils' interface IconPickerProps { value: string onChange: (val: string) => void appName: string } const PRESET_EMOJIS = [ '📱', '🚀', '🛍️', '💳', '⚡', '🛡️', '🤖', '📦', '🎮', '📊', '🎧', '💬', '🌐', '🔒', '🍔', '🚗', '✈️', '📈', '🎨', '🎵', '🏥', '🏢', '⚙️', '🔑' ] export function IconPicker({ value, onChange, appName }: IconPickerProps) { const [activeTab, setActiveTab] = useState<'presets' | 'url' | 'upload'>('presets') const [urlInput, setUrlInput] = useState(value?.startsWith('http') ? value : '') const fileInputRef = useRef(null) function handleEmojiSelect(emoji: string) { onChange(emoji) } function handleUrlChange(url: string) { setUrlInput(url) onChange(url) } function handleFileUpload(e: React.ChangeEvent) { const file = e.target.files?.[0] if (!file) return // Limit size to 1.5MB if (file.size > 1.5 * 1024 * 1024) { alert('İkon boyutu 1.5MB\'dan küçük olmalıdır.') return } const reader = new FileReader() reader.onload = () => { if (typeof reader.result === 'string') { onChange(reader.result) } } reader.readAsDataURL(file) } function handleClear() { onChange('') setUrlInput('') if (fileInputRef.current) { fileInputRef.current.value = '' } } return (
{value && ( )}
{/* Live Preview & Tabs Header */}
Önizleme
{/* Mode Switcher */}
{/* Tab 1: Presets */} {activeTab === 'presets' && (
{PRESET_EMOJIS.map((emoji) => ( ))}
)} {/* Tab 2: Upload */} {activeTab === 'upload' && (
)} {/* Tab 3: URL */} {activeTab === 'url' && (
https:// handleUrlChange(e.target.value)} placeholder="ornek.com/logo.png" className="flex-1 bg-transparent px-3 py-2 text-white text-xs font-mono placeholder-slate-500 focus:outline-none" />

CDN veya harici doğrudan görsel linki yapıştırın.

)}
) }