File tree Expand file tree Collapse file tree 2 files changed +70
-0
lines changed
apps/site/components/Downloads/DownloadButton Expand file tree Collapse file tree 2 files changed +70
-0
lines changed Original file line number Diff line number Diff line change 1+ @reference "../../../styles/index.css" ;
2+
3+ .downloadButton {
4+ @apply justify-center;
5+
6+ & .primary {
7+ @apply inline-flex
8+ dark:hidden;
9+ }
10+
11+ & .special {
12+ @apply hidden
13+ dark:inline-flex;
14+ }
15+
16+ svg {
17+ @apply dark:opacity-50;
18+ }
19+ }
Original file line number Diff line number Diff line change 1+ 'use client' ;
2+
3+ import { CloudArrowDownIcon } from '@heroicons/react/24/outline' ;
4+ import classNames from 'classnames' ;
5+ import type { FC , PropsWithChildren } from 'react' ;
6+
7+ import Button from '#site/components/Common/Button' ;
8+ import { useClientContext } from '#site/hooks' ;
9+ import type { NodeRelease } from '#site/types' ;
10+ import { getNodeDownloadUrl } from '#site/util/url' ;
11+ import { getUserPlatform } from '#site/util/userAgent' ;
12+
13+ import styles from './index.module.css' ;
14+
15+ type DownloadButtonProps = { release : NodeRelease } ;
16+
17+ const DownloadButton : FC < PropsWithChildren < DownloadButtonProps > > = ( {
18+ release : { versionWithPrefix : version } ,
19+ children,
20+ } ) => {
21+ const { os, bitness, architecture } = useClientContext ( ) ;
22+
23+ const platform = getUserPlatform ( architecture , bitness ) ;
24+ const downloadLink = getNodeDownloadUrl ( { version, os, platform } ) ;
25+
26+ return (
27+ < >
28+ < Button
29+ kind = "special"
30+ href = { downloadLink }
31+ className = { classNames ( styles . downloadButton , styles . special ) }
32+ >
33+ { children }
34+
35+ < CloudArrowDownIcon />
36+ </ Button >
37+
38+ < Button
39+ kind = "primary"
40+ href = { downloadLink }
41+ className = { classNames ( styles . downloadButton , styles . primary ) }
42+ >
43+ { children }
44+
45+ < CloudArrowDownIcon />
46+ </ Button >
47+ </ >
48+ ) ;
49+ } ;
50+
51+ export default DownloadButton ;
You can’t perform that action at this time.
0 commit comments