mirror of
https://github.com/zadam/trilium.git
synced 2025-10-19 22:58:52 +02:00
feat(website): reorder platforms to always get the recommended one in center
This commit is contained in:
parent
e860b7aa32
commit
ce0763f03d
@ -38,7 +38,8 @@ export default function DownloadPage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="grid-3-cols download-desktop">
|
<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]} />
|
<DownloadCard app="desktop" arch={currentArch} entry={entry} isRecommended={userPlatform === entry[0]} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@ -126,3 +127,13 @@ export function DownloadCard({ app, arch, entry: [ platform, entry ], isRecommen
|
|||||||
</Card>
|
</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;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user