fix ui scroll and add import button on landing
Browse filesFiles changed (2)
533 unmodified lines53453553653753853970 unmodified lines610611612613614615533 unmodified linesconsole.log('[Import] Current username:', username);console.log('[Import] Current repo before import:', currentRepoId);setGeneratedCode(code);setSelectedLanguage(language);70 unmodified lines<div className="min-h-screen animate-in fade-in duration-300"><LandingPageonStart={handleLandingPageStart}isAuthenticated={isAuthenticated}initialLanguage={selectedLanguage}initialModel={selectedModel}533 unmodified lines53453553653753853954054154254354470 unmodified lines615616617618619620621533 unmodified linesconsole.log('[Import] Current username:', username);console.log('[Import] Current repo before import:', currentRepoId);// Hide landing page when importingif (showLandingPage) {setShowLandingPage(false);}setGeneratedCode(code);setSelectedLanguage(language);70 unmodified lines<div className="min-h-screen animate-in fade-in duration-300"><LandingPageonStart={handleLandingPageStart}onImport={handleImport}isAuthenticated={isAuthenticated}initialLanguage={selectedLanguage}initialModel={selectedModel}
15 unmodified lines1617181920212 unmodified lines24252627282916 unmodified lines464748495051525354555687 unmodified lines14414514614714814958 unmodified lines20820921021121221321421521621784 unmodified lines3023033043053063073083093103113123133143153163173183193203213223233243253263273284 unmodified lines33333433533633733833957 unmodified lines39739839940040140242 unmodified lines44544644744844945011 unmodified lines4624634644654664674684692 unmodified lines47247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052115 unmodified linesinterface LandingPageProps {onStart: (prompt: string, language: Language, modelId: string) => void;isAuthenticated: boolean;initialLanguage?: Language;initialModel?: string;2 unmodified linesexport default function LandingPage({onStart,isAuthenticated,initialLanguage = 'html',initialModel = 'zai-org/GLM-4.6',16 unmodified lines// Dropdown statesconst [showLanguageDropdown, setShowLanguageDropdown] = useState(false);const [showModelDropdown, setShowModelDropdown] = useState(false);const languageDropdownRef = useRef<HTMLDivElement>(null);const modelDropdownRef = useRef<HTMLDivElement>(null);// Trending apps stateconst [trendingApps, setTrendingApps] = useState<any[]>([]);// Debug effect for dropdown stateuseEffect(() => {87 unmodified linesif (modelDropdownRef.current && !modelDropdownRef.current.contains(event.target as Node)) {setShowModelDropdown(false);}};document.addEventListener('mousedown', handleClickOutside);58 unmodified linesreturn lang.charAt(0).toUpperCase() + lang.slice(1);};return (<div className="min-h-screen flex flex-col bg-[#000000] overflow-y-auto">{/* Header - Apple style */}<header className="flex items-center justify-between px-6 py-4 backdrop-blur-xl bg-[#000000]/80 border-b border-[#424245]/30 flex-shrink-0"><ahref="https://huggingface.co/spaces/akhaliq/anycoder"target="_blank"84 unmodified lines</header>{/* Main Content - Apple-style centered layout */}<main className="flex-1 flex items-center justify-center px-4 py-12 min-h-0"><div className="w-full max-w-3xl">{/* Apple-style Headline */}<div className="text-center mb-12"><h2 className="text-5xl md:text-6xl lg:text-7xl font-semibold text-white mb-3 tracking-tight leading-[1.05]">Build with AnyCoder</h2><p className="text-lg md:text-xl text-[#86868b] font-normal">Create apps with AI</p></div>{/* Simple prompt form */}<form onSubmit={handleSubmit} className="relative"><div className="relative bg-[#2d2d30] rounded-2xl border border-[#424245] shadow-2xl">{/* Textarea */}<textareavalue={prompt}onChange={(e) => setPrompt(e.target.value)}placeholder="Message AnyCoder"className="w-full px-5 py-4 text-base text-[#f5f5f7] bg-transparent placeholder:text-[#86868b] resize-none focus:outline-none min-h-[56px] font-normal"rows={1}onKeyDown={(e) => {if (e.key === 'Enter' && !e.shiftKey) {4 unmodified lines/>{/* Bottom controls - Apple style */}<div className="flex items-center justify-between px-4 pb-4 gap-3">{/* Compact dropdowns on the left */}<div className="flex items-center gap-2">{/* Language Dropdown */}57 unmodified linesconsole.log('Model button clicked! Models length:', models.length, 'Show:', showModelDropdown);setShowModelDropdown(!showModelDropdown);setShowLanguageDropdown(false);}}className="px-3 py-1.5 bg-[#1d1d1f] text-[#f5f5f7] text-xs border border-[#424245] rounded-full hover:bg-[#2d2d2f] transition-all flex items-center gap-1.5 max-w-[200px] font-medium">42 unmodified lines</div>)}</div></div>{/* Send button on the right - Apple style */}11 unmodified lines</div>{!isAuthenticated && (<div className="mt-6 text-center"><p className="text-sm text-[#86868b]">Sign in to get started</p></div>2 unmodified lines{/* Trending Apps Section */}{trendingApps.length > 0 && (<div className="mt-16"><h3 className="text-2xl font-semibold text-white mb-6 text-center">Top Trending Apps Built with AnyCoder</h3><div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">{trendingApps.map((app) => (<akey={app.id}href={`https://huggingface.co/spaces/${app.id}`}target="_blank"rel="noopener noreferrer"className="group bg-[#1d1d1f] border border-[#424245] rounded-xl p-5 hover:border-white/30 transition-all hover:shadow-xl hover:scale-[1.02]"><div className="flex items-start justify-between mb-3"><div className="flex-1 min-w-0"><h4 className="text-sm font-medium text-[#f5f5f7] truncate group-hover:text-white transition-colors">{app.id.split('/')[1]}</h4><p className="text-xs text-[#86868b] mt-1">by {app.id.split('/')[0]}</p></div><div className="flex items-center gap-2 flex-shrink-0 ml-3"><div className="flex items-center gap-1"><svg className="w-3.5 h-3.5 text-[#86868b]" fill="currentColor" viewBox="0 0 20 20"><path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" /></svg><span className="text-xs text-[#86868b] font-medium">{app.likes}</span></div><div className="flex items-center gap-1"><svg className="w-3.5 h-3.5 text-[#86868b]" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 7h8m0 0v8m0-8l-8 8-4-4-6 6" /></svg><span className="text-xs text-[#86868b] font-medium">{app.trendingScore}</span></div></div></div><div className="flex flex-wrap gap-1.5"><span className="px-2 py-0.5 bg-[#2d2d30] text-[#86868b] text-[10px] rounded-full font-medium">{app.sdk}</span>{app.tags?.slice(0, 2).map((tag: string) =>tag !== 'anycoder' && tag !== app.sdk && tag !== 'region:us' && (<span key={tag} className="px-2 py-0.5 bg-[#2d2d30] text-[#86868b] text-[10px] rounded-full font-medium">{tag}</span>)15 unmodified lines161718192021222 unmodified lines2526272829303116 unmodified lines48495051525354555657585960616263646587 unmodified lines15315415515615715815916016158 unmodified lines22022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927084 unmodified lines3553563573583593603613623633643653663673683693703713723733743753763773783793803814 unmodified lines38638738838939039139257 unmodified lines45045145245345445545642 unmodified lines49950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957011 unmodified lines5825835845855865875885892 unmodified lines59259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964015 unmodified linesinterface LandingPageProps {onStart: (prompt: string, language: Language, modelId: string) => void;onImport?: (code: string, language: Language, importUrl?: string) => void;isAuthenticated: boolean;initialLanguage?: Language;initialModel?: string;2 unmodified linesexport default function LandingPage({onStart,onImport,isAuthenticated,initialLanguage = 'html',initialModel = 'zai-org/GLM-4.6',16 unmodified lines// Dropdown statesconst [showLanguageDropdown, setShowLanguageDropdown] = useState(false);const [showModelDropdown, setShowModelDropdown] = useState(false);const [showImportDialog, setShowImportDialog] = useState(false);const languageDropdownRef = useRef<HTMLDivElement>(null);const modelDropdownRef = useRef<HTMLDivElement>(null);const importDialogRef = useRef<HTMLDivElement>(null);// Trending apps stateconst [trendingApps, setTrendingApps] = useState<any[]>([]);// Import project stateconst [importUrl, setImportUrl] = useState('');const [isImporting, setIsImporting] = useState(false);const [importError, setImportError] = useState('');// Debug effect for dropdown stateuseEffect(() => {87 unmodified linesif (modelDropdownRef.current && !modelDropdownRef.current.contains(event.target as Node)) {setShowModelDropdown(false);}if (importDialogRef.current && !importDialogRef.current.contains(event.target as Node)) {setShowImportDialog(false);}};document.addEventListener('mousedown', handleClickOutside);58 unmodified linesreturn lang.charAt(0).toUpperCase() + lang.slice(1);};const handleImportProject = async () => {if (!importUrl.trim()) {setImportError('Please enter a valid URL');return;}if (!isAuthenticated) {alert('Please sign in with HuggingFace first!');return;}setIsImporting(true);setImportError('');try {const result = await apiClient.importProject(importUrl);if (result.status === 'success') {// Use onImport if available (better UX - directly loads code)// Otherwise fall back to onStart (sends message to generate)if (onImport && result.code) {onImport(result.code, result.language || 'html', importUrl);} else {// Fallback: trigger code generation with import contextconst importMessage = `Imported from ${importUrl}`;onStart(importMessage, result.language || 'html', selectedModel);}setShowImportDialog(false);setImportUrl('');} else {setImportError(result.message || 'Failed to import project');}} catch (error: any) {console.error('Import error:', error);setImportError(error.response?.data?.message || error.message || 'Failed to import project');} finally {setIsImporting(false);}};return (<div className="h-screen flex flex-col bg-[#000000] overflow-hidden">{/* Header - Apple style */}<header className="flex items-center justify-between px-6 py-3 backdrop-blur-xl bg-[#000000]/80 border-b border-[#424245]/30 flex-shrink-0"><ahref="https://huggingface.co/spaces/akhaliq/anycoder"target="_blank"84 unmodified lines</header>{/* Main Content - Apple-style centered layout */}<main className="flex-1 overflow-y-auto px-4 py-6"><div className="w-full max-w-3xl mx-auto flex flex-col items-center justify-center min-h-full">{/* Apple-style Headline */}<div className="text-center mb-8"><h2 className="text-4xl md:text-5xl font-semibold text-white mb-2 tracking-tight leading-tight">Build with AnyCoder</h2><p className="text-base md:text-lg text-[#86868b] font-normal">Create apps with AI</p></div>{/* Simple prompt form */}<form onSubmit={handleSubmit} className="relative w-full mb-8"><div className="relative bg-[#2d2d30] rounded-2xl border border-[#424245] shadow-2xl">{/* Textarea */}<textareavalue={prompt}onChange={(e) => setPrompt(e.target.value)}placeholder="Message AnyCoder"className="w-full px-4 py-3 text-sm text-[#f5f5f7] bg-transparent placeholder:text-[#86868b] resize-none focus:outline-none min-h-[48px] font-normal"rows={1}onKeyDown={(e) => {if (e.key === 'Enter' && !e.shiftKey) {4 unmodified lines/>{/* Bottom controls - Apple style */}<div className="flex items-center justify-between px-3 pb-3 gap-2">{/* Compact dropdowns on the left */}<div className="flex items-center gap-2">{/* Language Dropdown */}57 unmodified linesconsole.log('Model button clicked! Models length:', models.length, 'Show:', showModelDropdown);setShowModelDropdown(!showModelDropdown);setShowLanguageDropdown(false);setShowImportDialog(false);}}className="px-3 py-1.5 bg-[#1d1d1f] text-[#f5f5f7] text-xs border border-[#424245] rounded-full hover:bg-[#2d2d2f] transition-all flex items-center gap-1.5 max-w-[200px] font-medium">42 unmodified lines</div>)}</div>{/* Import Project Button */}<div className="relative" ref={importDialogRef}><buttontype="button"onClick={(e) => {e.stopPropagation();setShowImportDialog(!showImportDialog);setShowLanguageDropdown(false);setShowModelDropdown(false);setImportError('');}}className="px-3 py-1.5 bg-[#1d1d1f] text-[#f5f5f7] text-xs border border-[#424245] rounded-full hover:bg-[#2d2d2f] transition-all flex items-center gap-1.5 font-medium"><svg className="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24" strokeWidth={2.5}><path strokeLinecap="round" strokeLinejoin="round" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" /></svg><span>Import</span></button>{/* Import Dialog */}{showImportDialog && (<divclassName="absolute top-full left-0 mt-2 w-80 bg-[#1d1d1f] border border-[#424245] rounded-xl shadow-2xl overflow-hidden backdrop-blur-xl z-50"onClick={(e) => e.stopPropagation()}><div className="p-4"><h3 className="text-sm font-medium text-[#f5f5f7] mb-3">Import Project</h3><inputtype="text"value={importUrl}onChange={(e) => setImportUrl(e.target.value)}onKeyPress={(e) => e.key === 'Enter' && handleImportProject()}placeholder="https://huggingface.co/spaces/..."className="w-full px-3 py-2 rounded-lg text-xs bg-[#2d2d30] text-[#f5f5f7] border border-[#424245] focus:outline-none focus:border-white/50 font-normal mb-2"disabled={isImporting}/>{importError && (<p className="text-xs text-red-400 mb-2">{importError}</p>)}<div className="flex gap-2"><buttononClick={handleImportProject}disabled={isImporting || !importUrl.trim()}className="flex-1 px-3 py-2 bg-white text-black rounded-lg text-xs hover:bg-[#f5f5f7] disabled:opacity-50 disabled:cursor-not-allowed font-medium">{isImporting ? 'Importing...' : 'Import'}</button><buttononClick={() => {setShowImportDialog(false);setImportUrl('');setImportError('');}}className="px-3 py-2 bg-[#2d2d30] text-[#f5f5f7] rounded-lg text-xs hover:bg-[#3d3d3f] font-medium">Cancel</button></div><p className="text-[10px] text-[#86868b] mt-3">Import from HuggingFace Spaces, Models, or GitHub</p></div></div>)}</div></div>{/* Send button on the right - Apple style */}11 unmodified lines</div>{!isAuthenticated && (<div className="mt-4 text-center"><p className="text-xs text-[#86868b]">Sign in to get started</p></div>2 unmodified lines{/* Trending Apps Section */}{trendingApps.length > 0 && (<div className="mt-8 w-full"><h3 className="text-xl font-semibold text-white mb-4 text-center">Top Trending Apps Built with AnyCoder</h3><div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3">{trendingApps.map((app) => (<akey={app.id}href={`https://huggingface.co/spaces/${app.id}`}target="_blank"rel="noopener noreferrer"className="group bg-[#1d1d1f] border border-[#424245] rounded-xl p-4 hover:border-white/30 transition-all hover:shadow-xl hover:scale-[1.02]"><div className="flex items-start justify-between mb-2"><div className="flex-1 min-w-0"><h4 className="text-xs font-medium text-[#f5f5f7] truncate group-hover:text-white transition-colors">{app.id.split('/')[1]}</h4><p className="text-[10px] text-[#86868b] mt-0.5">by {app.id.split('/')[0]}</p></div><div className="flex items-center gap-1.5 flex-shrink-0 ml-2"><div className="flex items-center gap-0.5"><svg className="w-3 h-3 text-[#86868b]" fill="currentColor" viewBox="0 0 20 20"><path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" /></svg><span className="text-[10px] text-[#86868b] font-medium">{app.likes}</span></div><div className="flex items-center gap-0.5"><svg className="w-3 h-3 text-[#86868b]" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 7h8m0 0v8m0-8l-8 8-4-4-6 6" /></svg><span className="text-[10px] text-[#86868b] font-medium">{app.trendingScore}</span></div></div></div><div className="flex flex-wrap gap-1"><span className="px-1.5 py-0.5 bg-[#2d2d30] text-[#86868b] text-[9px] rounded-full font-medium">{app.sdk}</span>{app.tags?.slice(0, 2).map((tag: string) =>tag !== 'anycoder' && tag !== app.sdk && tag !== 'region:us' && (<span key={tag} className="px-1.5 py-0.5 bg-[#2d2d30] text-[#86868b] text-[9px] rounded-full font-medium">{tag}</span>)
frontend/src/app/page.tsx+6
frontend/src/components/LandingPage.tsx+149-30