forked from nodejs/nodejs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DownloadButton.tsx
32 lines (24 loc) · 976 Bytes
/
DownloadButton.tsx
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
'use client';
import { CloudArrowDownIcon } from '@heroicons/react/24/outline';
import { useTranslations } from 'next-intl';
import { useContext } from 'react';
import type { FC } from 'react';
import Button from '@/components/Common/Button';
import { ReleaseContext } from '@/providers/releaseProvider';
import { getNodeDownloadUrl } from '@/util/getNodeDownloadUrl';
type DownloadButtonProps = { kind: 'installer' | 'binary' | 'source' };
const DownloadButton: FC<DownloadButtonProps> = ({ kind = 'installer' }) => {
const t = useTranslations();
const { release, os, bitness } = useContext(ReleaseContext);
const version = release.versionWithPrefix;
const url = getNodeDownloadUrl(version, os, bitness, kind);
return (
<div className="mb-2 mt-6">
<Button href={url} disabled={!version}>
<CloudArrowDownIcon />
{t('layouts.download.buttons.prebuilt', { version })}
</Button>
</div>
);
};
export default DownloadButton;