Spaces:
Sleeping
Sleeping
File size: 9,810 Bytes
ab6cc2c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | import { 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>
)
} |