2025-09-28 00:58:15 +03:00
|
|
|
import { getRecommendedDownload, RecommendedDownload } from "../download-helper.js";
|
2025-09-26 23:32:09 +03:00
|
|
|
import "./DownloadButton.css";
|
2025-09-27 22:36:26 +03:00
|
|
|
import Button from "./Button.js";
|
2025-09-27 12:41:33 +03:00
|
|
|
import downloadIcon from "../assets/boxicons/bx-arrow-in-down-square-half.svg?raw";
|
2025-09-27 22:16:07 +03:00
|
|
|
import packageJson from "../../../../package.json" with { type: "json" };
|
2025-09-28 00:58:15 +03:00
|
|
|
import { useEffect, useState } from "preact/hooks";
|
2025-09-26 23:28:58 +03:00
|
|
|
|
|
|
|
|
interface DownloadButtonProps {
|
|
|
|
|
big?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function DownloadButton({ big }: DownloadButtonProps) {
|
2025-09-28 00:58:15 +03:00
|
|
|
const [ recommendedDownload, setRecommendedDownload ] = useState<RecommendedDownload | null>();
|
2025-09-30 22:20:10 +03:00
|
|
|
useEffect(() => {
|
|
|
|
|
getRecommendedDownload()?.then(setRecommendedDownload);
|
|
|
|
|
}, []);
|
2025-09-28 00:58:15 +03:00
|
|
|
|
2025-09-28 00:02:41 +03:00
|
|
|
return (recommendedDownload &&
|
2025-09-30 19:45:56 +03:00
|
|
|
<>
|
|
|
|
|
{recommendedDownload.platform !== "linux"
|
|
|
|
|
? (
|
|
|
|
|
<Button
|
|
|
|
|
className={`download-button desktop-only ${big ? "big" : ""}`}
|
|
|
|
|
href={recommendedDownload.url}
|
|
|
|
|
iconSvg={downloadIcon}
|
|
|
|
|
text={<>
|
|
|
|
|
Download now{" "}
|
|
|
|
|
{big
|
|
|
|
|
? <span class="platform">v{packageJson.version} for {recommendedDownload.name}</span>
|
|
|
|
|
: <span class="platform">for {recommendedDownload.name}</span>
|
|
|
|
|
}
|
|
|
|
|
</>}
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
|
|
|
|
<Button
|
|
|
|
|
className={`download-button desktop-only ${big ? "big" : ""}`}
|
|
|
|
|
href="/get-started/"
|
|
|
|
|
iconSvg={downloadIcon}
|
|
|
|
|
text={<>
|
|
|
|
|
Download now{" "}
|
|
|
|
|
{big
|
|
|
|
|
? <span class="platform">v{packageJson.version} for Linux</span>
|
|
|
|
|
: <span class="platform">for Linux</span>
|
|
|
|
|
}
|
|
|
|
|
</>}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{big && (
|
|
|
|
|
<a class="more-download-options desktop-only" href="./get-started/">More platforms & server setup</a>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
2025-09-26 23:28:58 +03:00
|
|
|
)
|
|
|
|
|
}
|