|
| 1 | +'use client' |
| 2 | + |
| 3 | +import { Download, FileText, Github, Home, Linkedin, Twitter, Youtube } from 'lucide-react' |
| 4 | +import { useTranslations } from 'next-intl' |
| 5 | +import { AppleIcon, LinuxIcon, WindowsIcon } from '@/components/controls/PlatformIcons' |
| 6 | +import Footer from '@/components/Footer' |
| 7 | +import Header from '@/components/Header' |
| 8 | +import { Breadcrumb } from '@/components/navigation/Breadcrumb' |
| 9 | +import ComparisonTable, { type ComparisonColumn } from '@/components/product/ComparisonTable' |
| 10 | +import { PricingSummaryValue } from '@/components/product/ProductPricing' |
| 11 | +import { withVendorCommunityUrlsForCatalog } from '@/lib/community-urls' |
| 12 | +import { desktopsData, vendorsData } from '@/lib/generated' |
| 13 | +import { getGithubStars } from '@/lib/generated/github-stars' |
| 14 | +import { renderLicense } from '@/lib/license' |
| 15 | +import type { PricingTier } from '@/lib/pricing' |
| 16 | +import type { ManifestDesktop, ManifestVendor } from '@/types/manifests' |
| 17 | + |
| 18 | +const desktops = withVendorCommunityUrlsForCatalog( |
| 19 | + desktopsData as unknown as ManifestDesktop[], |
| 20 | + vendorsData as unknown as ManifestVendor[] |
| 21 | +) |
| 22 | + |
| 23 | +type Props = { |
| 24 | + locale: string |
| 25 | +} |
| 26 | + |
| 27 | +export default function DesktopComparisonPageClient({ locale: _locale }: Props) { |
| 28 | + const tPage = useTranslations('pages.comparison') |
| 29 | + const tShared = useTranslations('shared') |
| 30 | + const columns: ComparisonColumn[] = [ |
| 31 | + { |
| 32 | + key: 'vendor', |
| 33 | + label: tShared('categories.singular.vendor'), |
| 34 | + }, |
| 35 | + { |
| 36 | + key: 'license', |
| 37 | + label: tShared('terms.license'), |
| 38 | + render: (value: unknown, item: Record<string, unknown>) => |
| 39 | + renderLicense(value, item, tShared), |
| 40 | + }, |
| 41 | + { |
| 42 | + key: 'latestVersion', |
| 43 | + label: tShared('terms.version'), |
| 44 | + }, |
| 45 | + { |
| 46 | + key: 'platforms', |
| 47 | + label: tShared('terms.platforms'), |
| 48 | + render: (value: unknown) => { |
| 49 | + const platforms = value as Array<{ os: string }> | string[] |
| 50 | + if (!platforms || platforms.length === 0) return '-' |
| 51 | + |
| 52 | + // Handle both old format (string[]) and new format (Array<{ os: string }>) |
| 53 | + const platformNames = Array.isArray(platforms) |
| 54 | + ? platforms.map(p => (typeof p === 'string' ? p : p.os)) |
| 55 | + : [] |
| 56 | + |
| 57 | + return ( |
| 58 | + <div className="flex gap-1.5 items-center"> |
| 59 | + {platformNames.includes('macOS') && ( |
| 60 | + <span title="macOS"> |
| 61 | + <AppleIcon /> |
| 62 | + </span> |
| 63 | + )} |
| 64 | + {platformNames.includes('Windows') && ( |
| 65 | + <span title="Windows"> |
| 66 | + <WindowsIcon /> |
| 67 | + </span> |
| 68 | + )} |
| 69 | + {platformNames.includes('Linux') && ( |
| 70 | + <span title="Linux"> |
| 71 | + <LinuxIcon /> |
| 72 | + </span> |
| 73 | + )} |
| 74 | + </div> |
| 75 | + ) |
| 76 | + }, |
| 77 | + }, |
| 78 | + { |
| 79 | + key: 'githubStars', |
| 80 | + label: tShared('terms.stars'), |
| 81 | + render: (_: unknown, item: Record<string, unknown>) => { |
| 82 | + const githubUrl = item.githubUrl as string | null | undefined |
| 83 | + const stars = getGithubStars(githubUrl) |
| 84 | + |
| 85 | + if (stars === null || stars === undefined) |
| 86 | + return <span className="text-right block">-</span> |
| 87 | + |
| 88 | + const starsText = `${stars.toFixed(1)}k` |
| 89 | + |
| 90 | + if (githubUrl) { |
| 91 | + return ( |
| 92 | + <a |
| 93 | + href={githubUrl} |
| 94 | + target="_blank" |
| 95 | + rel="noopener" |
| 96 | + className="text-right block hover:text-[var(--color-text-secondary)] transition-colors hover:underline" |
| 97 | + > |
| 98 | + {starsText} |
| 99 | + </a> |
| 100 | + ) |
| 101 | + } |
| 102 | + |
| 103 | + return <span className="text-right block">{starsText}</span> |
| 104 | + }, |
| 105 | + }, |
| 106 | + { |
| 107 | + key: 'links', |
| 108 | + label: tPage('columns.links'), |
| 109 | + render: (_: unknown, item: Record<string, unknown>) => { |
| 110 | + const websiteUrl = item.websiteUrl as string | undefined |
| 111 | + const docsUrl = item.docsUrl as string | undefined |
| 112 | + const resourceUrls = item.resourceUrls as |
| 113 | + | { |
| 114 | + download?: string |
| 115 | + } |
| 116 | + | undefined |
| 117 | + const communityUrls = item.communityUrls as |
| 118 | + | { |
| 119 | + github?: string |
| 120 | + twitter?: string |
| 121 | + linkedin?: string |
| 122 | + youtube?: string |
| 123 | + reddit?: string |
| 124 | + } |
| 125 | + | undefined |
| 126 | + |
| 127 | + return ( |
| 128 | + <div className="flex gap-2 items-center"> |
| 129 | + {websiteUrl ? ( |
| 130 | + <a |
| 131 | + href={websiteUrl} |
| 132 | + target="_blank" |
| 133 | + rel="noopener" |
| 134 | + className="text-[var(--color-text)] hover:text-[var(--color-text-secondary)] transition-colors" |
| 135 | + title={tShared('terms.visitWebsite')} |
| 136 | + > |
| 137 | + <Home className="w-3.5 h-3.5" /> |
| 138 | + </a> |
| 139 | + ) : ( |
| 140 | + <span className="text-[var(--color-text-muted)] opacity-30"> |
| 141 | + <Home className="w-3.5 h-3.5" /> |
| 142 | + </span> |
| 143 | + )} |
| 144 | + {resourceUrls?.download ? ( |
| 145 | + <a |
| 146 | + href={resourceUrls.download} |
| 147 | + target="_blank" |
| 148 | + rel="noopener" |
| 149 | + className="text-[var(--color-text)] hover:text-[var(--color-text-secondary)] transition-colors" |
| 150 | + title={tShared('actions.download')} |
| 151 | + > |
| 152 | + <Download className="w-3.5 h-3.5" /> |
| 153 | + </a> |
| 154 | + ) : ( |
| 155 | + <span className="text-[var(--color-text-muted)] opacity-30"> |
| 156 | + <Download className="w-3.5 h-3.5" /> |
| 157 | + </span> |
| 158 | + )} |
| 159 | + {docsUrl ? ( |
| 160 | + <a |
| 161 | + href={docsUrl} |
| 162 | + target="_blank" |
| 163 | + rel="noopener" |
| 164 | + className="text-[var(--color-text)] hover:text-[var(--color-text-secondary)] transition-colors" |
| 165 | + title={tShared('terms.documentation')} |
| 166 | + > |
| 167 | + <FileText className="w-3.5 h-3.5" /> |
| 168 | + </a> |
| 169 | + ) : ( |
| 170 | + <span className="text-[var(--color-text-muted)] opacity-30"> |
| 171 | + <FileText className="w-3.5 h-3.5" /> |
| 172 | + </span> |
| 173 | + )} |
| 174 | + {communityUrls?.github ? ( |
| 175 | + <a |
| 176 | + href={communityUrls.github} |
| 177 | + target="_blank" |
| 178 | + rel="noopener" |
| 179 | + className="text-[var(--color-text)] hover:text-[var(--color-text-secondary)] transition-colors" |
| 180 | + title={tShared('platforms.github')} |
| 181 | + > |
| 182 | + <Github className="w-3.5 h-3.5" /> |
| 183 | + </a> |
| 184 | + ) : ( |
| 185 | + <span className="text-[var(--color-text-muted)] opacity-30"> |
| 186 | + <Github className="w-3.5 h-3.5" /> |
| 187 | + </span> |
| 188 | + )} |
| 189 | + {communityUrls?.twitter ? ( |
| 190 | + <a |
| 191 | + href={communityUrls.twitter} |
| 192 | + target="_blank" |
| 193 | + rel="noopener" |
| 194 | + className="text-[var(--color-text)] hover:text-[var(--color-text-secondary)] transition-colors" |
| 195 | + title={tShared('platforms.twitter')} |
| 196 | + > |
| 197 | + <Twitter className="w-3.5 h-3.5" /> |
| 198 | + </a> |
| 199 | + ) : ( |
| 200 | + <span className="text-[var(--color-text-muted)] opacity-30"> |
| 201 | + <Twitter className="w-3.5 h-3.5" /> |
| 202 | + </span> |
| 203 | + )} |
| 204 | + {communityUrls?.linkedin ? ( |
| 205 | + <a |
| 206 | + href={communityUrls.linkedin} |
| 207 | + target="_blank" |
| 208 | + rel="noopener" |
| 209 | + className="text-[var(--color-text)] hover:text-[var(--color-text-secondary)] transition-colors" |
| 210 | + title={tShared('platforms.linkedin')} |
| 211 | + > |
| 212 | + <Linkedin className="w-3.5 h-3.5" /> |
| 213 | + </a> |
| 214 | + ) : ( |
| 215 | + <span className="text-[var(--color-text-muted)] opacity-30"> |
| 216 | + <Linkedin className="w-3.5 h-3.5" /> |
| 217 | + </span> |
| 218 | + )} |
| 219 | + {communityUrls?.youtube ? ( |
| 220 | + <a |
| 221 | + href={communityUrls.youtube} |
| 222 | + target="_blank" |
| 223 | + rel="noopener" |
| 224 | + className="text-[var(--color-text)] hover:text-[var(--color-text-secondary)] transition-colors" |
| 225 | + title={tShared('platforms.youtube')} |
| 226 | + > |
| 227 | + <Youtube className="w-3.5 h-3.5" /> |
| 228 | + </a> |
| 229 | + ) : ( |
| 230 | + <span className="text-[var(--color-text-muted)] opacity-30"> |
| 231 | + <Youtube className="w-3.5 h-3.5" /> |
| 232 | + </span> |
| 233 | + )} |
| 234 | + </div> |
| 235 | + ) |
| 236 | + }, |
| 237 | + }, |
| 238 | + { |
| 239 | + key: 'pricing-free', |
| 240 | + label: tPage('columns.freePlan'), |
| 241 | + render: (_: unknown, item: Record<string, unknown>) => { |
| 242 | + const pricing = item.pricing as PricingTier[] |
| 243 | + if (!pricing || pricing.length === 0) return '-' |
| 244 | + const freePlan = pricing.find(p => p.value === 0) |
| 245 | + return freePlan ? '✓' : '-' |
| 246 | + }, |
| 247 | + }, |
| 248 | + { |
| 249 | + key: 'pricing-min', |
| 250 | + label: tPage('columns.startingPrice'), |
| 251 | + render: (_: unknown, item: Record<string, unknown>) => { |
| 252 | + const pricing = item.pricing as PricingTier[] |
| 253 | + return <PricingSummaryValue pricing={pricing} boundary="min" /> |
| 254 | + }, |
| 255 | + }, |
| 256 | + { |
| 257 | + key: 'pricing-max', |
| 258 | + label: tPage('columns.maxPrice'), |
| 259 | + render: (_: unknown, item: Record<string, unknown>) => { |
| 260 | + const pricing = item.pricing as PricingTier[] |
| 261 | + return <PricingSummaryValue pricing={pricing} boundary="max" /> |
| 262 | + }, |
| 263 | + }, |
| 264 | + ] |
| 265 | + |
| 266 | + return ( |
| 267 | + <> |
| 268 | + <Header /> |
| 269 | + |
| 270 | + <Breadcrumb |
| 271 | + items={[ |
| 272 | + { name: tShared('terms.aiCodingStack'), href: '/ai-coding-stack' }, |
| 273 | + { name: tShared('categories.plural.desktops'), href: '/desktops' }, |
| 274 | + { name: tShared('terms.comparison'), href: '/desktops/comparison' }, |
| 275 | + ]} |
| 276 | + /> |
| 277 | + |
| 278 | + {/* Page Header */} |
| 279 | + <section className="pt-[var(--spacing-lg)] pb-[var(--spacing-md)]"> |
| 280 | + <div className="max-w-8xl mx-auto px-[var(--spacing-md)]"> |
| 281 | + <h1 className="text-3xl font-semibold tracking-[-0.03em] mb-[var(--spacing-sm)]"> |
| 282 | + {tPage('desktops.title')} |
| 283 | + </h1> |
| 284 | + <p className="text-base text-[var(--color-text-secondary)] font-light"> |
| 285 | + {tPage('desktops.subtitle')} |
| 286 | + </p> |
| 287 | + </div> |
| 288 | + </section> |
| 289 | + |
| 290 | + {/* Comparison Table */} |
| 291 | + <section className="pb-[var(--spacing-xl)] border-b border-[var(--color-border)]"> |
| 292 | + <div className="max-w-8xl mx-auto px-[var(--spacing-md)]"> |
| 293 | + <ComparisonTable |
| 294 | + items={desktops as unknown as Record<string, unknown>[]} |
| 295 | + columns={columns} |
| 296 | + itemLinkPrefix={`/desktops`} |
| 297 | + nameColumnLabel={tShared('labels.name')} |
| 298 | + caption={tPage('desktops.title')} |
| 299 | + scrollHint={tPage('table.scrollHint')} |
| 300 | + /> |
| 301 | + </div> |
| 302 | + </section> |
| 303 | + |
| 304 | + <Footer /> |
| 305 | + </> |
| 306 | + ) |
| 307 | +} |
0 commit comments