feat(website): reorder platforms to always get the recommended one in center

This commit is contained in:
Elian Doran 2025-09-30 21:18:52 +03:00
parent e860b7aa32
commit ce0763f03d
No known key found for this signature in database

View File

@ -38,7 +38,8 @@ export default function DownloadPage() {
</div>
<div className="grid-3-cols download-desktop">
{Object.entries(downloadMatrix.desktop).map(entry => (
{reorderPlatforms(Object.entries(downloadMatrix.desktop), userPlatform ?? "")
.map(entry => (
<DownloadCard app="desktop" arch={currentArch} entry={entry} isRecommended={userPlatform === entry[0]} />
))}
</div>
@ -126,3 +127,13 @@ export function DownloadCard({ app, arch, entry: [ platform, entry ], isRecommen
</Card>
)
}
function reorderPlatforms(entries: [string, DownloadMatrixEntry][], platformToCenter: Platform | "") {
const entryToCenter = entries.find(x => x[0] === platformToCenter);
if (!entryToCenter) return entries;
const others = entries.filter(x => x !== entryToCenter);
const mid = Math.floor(others.length / 2);
others.splice(mid, 0, entryToCenter);
return others;
}