Spaces:
Sleeping
Sleeping
Upload components/DownloadSection.jsx with huggingface_hub
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263import { useState } from 'react'import { Download, FileText, Archive, FileCode, ChevronRight, Check, Loader, AlertCircle, BookOpen, Zap, Box } from 'lucide-react'
const downloads = [ { id: 1, name: 'Developer Handbook', description: 'Complete guide to using daKItech tools, best practices, and advanced configuration.', filename: 'dakitech-handbook.pdf', size: '4.2 MB', type: 'PDF', icon: BookOpen, color: 'text-rose-400', bgColor: 'bg-rose-500/10', borderColor: 'border-rose-500/20', version: 'v2.4', lastUpdated: 'Sept 2024', badge: 'Recommended' }, { id: 2, name: 'CLI Binary (Linux)', description: 'Standalone x86_64 Linux binary for the daKItech CLI toolkit. Zero dependencies.', filename: 'dakitech-cli-linux-amd64.tar.gz', size: '12.8 MB', type: 'TAR.GZ', icon: Archive, color: 'text-yellow-400', bgColor: 'bg-yellow-500/10', borderColor: 'border-yellow-500/20', version: 'v2.4.1', lastUpdated: '2 days ago', badge: null }, { id: 3, name: 'CLI Binary (macOS)', description: 'Universal macOS binary for Intel and Apple Silicon chips. Notarized and signed.', filename: 'dakitech-cli-macos-universal.tar.gz', size: '15.3 MB', type: 'TAR.GZ', icon: Archive, color: 'text-yellow-400', bgColor: 'bg-yellow-500/10', borderColor: 'border-yellow-500/20', version: 'v2.4.1', lastUpdated: '2 days ago', badge: null }, { id: 4, name: 'Source Code', description: 'Full source code archive of the latest stable release. Includes all packages and tooling.', filename: 'dakitech-dev-v2.4.1.zip', size: '8.6 MB', type: 'ZIP', icon: FileCode, color: 'text-blue-400', bgColor: 'bg-blue-500/10', borderColor: 'border-blue-500/20', version: 'v2.4.1', lastUpdated: '2 days ago', badge: null }, { id: 5, name: 'Docker Image', description: 'Pre-built Docker image with all dependencies configured. Ready to run out of the box.', filename: 'dakitech-dev:latest', size: '142 MB', type: 'Docker', icon: Box, color: 'text-sky-400', bgColor: 'bg-sky-500/10', borderColor: 'border-sky-500/20', version: 'latest', lastUpdated: '1 day ago', badge: 'New' }, { id: 6, name: 'VS Code Extension', description: 'Official extension for Visual Studio Code with syntax highlighting and IntelliSense.', filename: 'dakitech-vscode.vsix', size: '1.8 MB', type: 'VSIX', icon: Zap, color: 'text-emerald-400', bgColor: 'bg-emerald-500/10', borderColor: 'border-emerald-500/20', version: 'v1.2.0', lastUpdated: '1 week ago', badge: null }]
export default function DownloadSection() { const [downloading, setDownloading] = useState(null) const [completed, setCompleted] = useState({}) const [error, setError] = useState(null)
const handleDownload = async (file) => { setDownloading(file.id) setError(null)
try { const response = await fetch(`/api/download?file=${encodeURIComponent(file.filename)}`)
if (!response.ok) { throw new Error(`Download failed: ${response.statusText}`) }
const blob = await response.blob() const url = window.URL.createObjectURL(blob) const a = document.createElement('a') a.href = url a.download = file.filename document.body.appendChild(a) a.click() window.URL.revokeObjectURL(url) document.body.removeChild(a)
setCompleted((prev) => ({ ...prev, [file.id]: true })) setTimeout(() => { setCompleted((prev) => { const next = { ...prev } delete next[file.id] return next }) }, 3000) } catch (err) { setError(`Failed to download ${file.name}. Please try again.`) } finally { setDownloading(null) } }
return ( <section id="downloads" className="relative py-24"> <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"> <div className="mb-12"> <span className="inline-flex items-center gap-2 text-xs font-mono text-primary-400 uppercase tracking-widest mb-3"> <Download className="w-3.5 h-3.5" /> Downloads </span> <h2 className="text-3xl sm:text-4xl font-bold text-white tracking-tight"> Get Started </h2> <p className="mt-2 text-slate-400 max-w-xl"> Download the latest releases, documentation, and tooling to power your development workflow. </p> </div>
{error && ( <div className="mb-6 flex items-center gap-3 p-4 rounded-xl bg-rose-500/10 border border-rose-500/20 text-rose-300 animate-fade-in"> <AlertCircle className="w-5 h-5 shrink-0" /> <span className="text-sm">{error}</span> </div> )}
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-5"> {downloads.map((item) => { const IconComponent = item.icon const isDownloading = downloading === item.id const isCompleted = completed[item.id]
return ( <div key={item.id} className="group glass rounded-2xl p-6 transition-all duration-300 card-glow hover:-translate-y-1 relative" > {item.badge && ( <span className="absolute top-4 right-4 px-2 py-0.5 text-[10px] font-mono font-semibold text-white bg-primary-500 rounded-full"> {item.badge} </span> )}
<div className="flex items-start gap-4 mb-4"> <div className={`w-12 h-12 rounded-xl flex items-center justify-center shrink-0 ${item.bgColor} border ${item.borderColor}`}> <IconComponent className={`w-6 h-6 ${item.color}`} /> </div> <div className="flex-1 min-w-0"> <h3 className="text-base font-semibold text-white truncate pr-8">{item.name}</h3> <div className="flex items-center gap-2 mt-1"> <span className="text-xs font-mono text-slate-400">{item.type}</span> <span className="w-px h-3 bg-slate-700" /> <span className="text-xs font-mono text-slate-500">{item.size}</span> </div> </div> </div>
<p className="text-sm text-slate-400 leading-relaxed mb-5"> {item.description} </p>
<div className="flex items-center justify-between mb-5"> <div className="flex items-center gap-2"> <span className="text-xs font-mono text-slate-500">v{item.version}</span> <span className="w-px h-3 bg-slate-700" /> <span className="text-xs text-slate-500">{item.lastUpdated}</span> </div> </div>
<button onClick={() => handleDownload(item)} disabled={isDownloading} className={`w-full flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-medium transition-all ${ isCompleted ? 'bg-emerald-500/20 text-emerald-400 border border-emerald-500/30' : isDownloading ? 'bg-slate-800/50 text-slate-400 border border-slate-700/30 cursor-wait' : 'bg-slate-800/50 hover:bg-primary-500/20 text-slate-300 hover:text-primary-400 border border-slate-700/30 hover:border-primary-500/30' }`} > {isCompleted ? ( <> <Check className="w-4 h-4" /> Downloaded </> ) : isDownloading ? ( <> <Loader className="w-4 h-4 animate-spin" /> Downloading... </> ) : ( <> <Download className="w-4 h-4" /> Download <ChevronRight className="w-3.5 h-3.5 group-hover:translate-x-0.5 transition-transform" /> </> )} </button> </div> ) })} </div>
<div className="mt-12 p-6 rounded-2xl bg-gradient-to-r from-primary-500/10 to-sky-500/10 border border-primary-500/20"> <div className="flex flex-col sm:flex-row items-start sm:items-center gap-4"> <div className="w-10 h-10 rounded-xl bg-primary-500/20 flex items-center justify-center shrink-0"> <FileText className="w-5 h-5 text-primary-400" /> </div> <div className="flex-1"> <h4 className="text-sm font-semibold text-white">Installation Guide</h4> <p className="text-sm text-slate-400 mt-1"> Follow our step-by-step installation guide to get daKItech running on your local machine in under 5 minutes. </p> </div> <a href="https://github.com/Maj3sTiCDD83/daKItech-dev#installation" target="_blank" rel="noopener noreferrer" className="shrink-0 flex items-center gap-2 px-5 py-2.5 bg-primary-500 hover:bg-primary-400 text-white text-sm font-medium rounded-xl transition-colors shadow-lg shadow-primary-500/20" > Read Guide <ChevronRight className="w-4 h-4" /> </a> </div> </div> </div> </section> )}components/DownloadSection.jsxAdded+263