Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: multi-part download support #536

Open
wants to merge 3 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/components/Alert/Alert.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { ReactNode } from 'react';
import { twMerge } from 'tailwind-merge';

interface AlertProps {
type: 'note' | 'caution' | 'danger';
className?: string;
children: ReactNode;
}

export const Alert = ({ type, className, children }: AlertProps) => {
let borderColor: string;
switch (type) {
default:
case 'note': {
borderColor = 'border-l-cyan';
break;
}
case 'caution': {
borderColor = 'border-l-utility-amber';
break;
}
case 'danger': {
borderColor = 'border-l-red';
break;
}
}

return (
<div className={twMerge('flex flex-col gap-3 p-5 border-l-8 bg-navy text-quasi-white rounded', borderColor, className)}>
{children}
</div>
);
};
51 changes: 29 additions & 22 deletions src/components/Downloads/DownloadLinks.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
import Link from 'next/link';
import Button from '../Button/Button';
import { Alert } from '../Alert/Alert';

interface Version {
name: string;
links: string[];
}

type DownloadProps = {
stableLink?: string,
devLink?: string,
aircraft: string,

note?: string;
versions: Version[];
}

const downloadLinks = ({ stableLink, devLink, aircraft }: DownloadProps) => (
<span className="flex flex-col gap-y-1.5">
const DownloadLinks = ({ versions, note, aircraft }: DownloadProps) => (
<div
className="mt-4 pb-4 flex flex-col border-b border-b-navy"
>
<h3>{aircraft}</h3>
{stableLink && devLink ? (
<>
<span className="flex gap-x-2.5">
<Link href={stableLink}>
<Button>Stable</Button>
</Link>
<Link href={devLink}>
<Button theme="secondary">Development</Button>
</Link>
</span>
</>
) : (
<p>Use our installer to download.</p>
)}
</span>
<div className="flex flex-col gap-4 mt-4">
{note && <Alert type="note">{note}</Alert>}

<div className="grid grid-cols-2 gap-y-4">
{versions.map((version) => (
<ul className="flex flex-col" key={crypto.randomUUID()}>
{version.links.map((link, i) => (
<li key={crypto.randomUUID()}>
<Link className="underline" href={link}>{`${version.name} - Part ${i + 1} of ${version.links.length}`}</Link>
</li>
))}
</ul>
))}
</div>
</div>
</div>
);

export default downloadLinks;
export default DownloadLinks;
34 changes: 30 additions & 4 deletions src/pages/downloads/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,39 @@ const Downloads: NextPage = () => (
<div className="grow">
<h2>Direct Download</h2>
<p className="pb-6">If you prefer a direct download, the following links are available.</p>
<div className="flex flex-col lg:flex-row gap-8">
<div className="flex flex-col gap-8">
<DownloadLinks
aircraft="A32NX"
stableLink="https://github.com/flybywiresim/aircraft/releases/download/assets/stable/A32NX-stable.7z"
devLink="https://github.com/flybywiresim/aircraft/releases/download/assets/master/A32NX-master.7z"
versions={[
{
name: 'Stable',
links: ['https://github.com/flybywiresim/aircraft/releases/download/assets/stable/A32NX-stable.7z'],
},
{
name: 'Development',
links: ['https://github.com/flybywiresim/aircraft/releases/download/assets/master/A32NX-master.7z'],
},
]}
/>

<DownloadLinks
aircraft="A380X"
note="The 8K version must be installed in multiple packages. Download all parts and open the .001 with 7-Zip."
versions={[
{
name: 'Stable (4K)',
links: ['https://github.com/flybywiresim/aircraft/releases/download/assets/stable/A380X-stable-4K.7z'],
},
{
name: 'Stable (8K)',
links: [
'https://github.com/flybywiresim/aircraft/releases/download/assets/stable/A380X-stable-8K.7z.001',
'https://github.com/flybywiresim/aircraft/releases/download/assets/stable/A380X-stable-8K.7z.002',
'https://github.com/flybywiresim/aircraft/releases/download/assets/stable/A380X-stable-8K.7z.003',
],
},
]}
/>
<DownloadLinks aircraft="A380X" stableLink="" devLink="" />
</div>
</div>
</Container>
Expand Down
Loading