-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Download the asset for current operation system directly (#22)
* Render downloads as dropdown button and auto detect system * Create a provider for release asset * Make download links adaptive * Use carousel from shadcn * Use nextui accordion for FAQ
- Loading branch information
Showing
12 changed files
with
1,983 additions
and
164 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use client' | ||
|
||
import { useRelease } from "@/lib/release-provider" | ||
import { Button, ButtonProps } from "@nextui-org/button" | ||
import { Link, LinkProps } from "@nextui-org/link" | ||
|
||
const DownloadLink = ({ children, ...props }: ButtonProps & LinkProps) => { | ||
const release = useRelease() | ||
const systems = release.systems | ||
const defaultSystem = release.current ?? systems[0] | ||
const href = defaultSystem.href || release.url | ||
|
||
return ( | ||
<Button | ||
as={Link} | ||
href={href} | ||
{...props} | ||
> | ||
{children} | ||
</Button> | ||
) | ||
} | ||
|
||
export default DownloadLink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
'use client'; | ||
|
||
// Ref: https://github.com/janhq/docs/blob/main/src/components/DropdownDownload/index.tsx#L114 | ||
import { Button, ButtonGroup } from "@nextui-org/button"; | ||
import { Dropdown, DropdownItem, DropdownMenu, DropdownTrigger } from "@nextui-org/dropdown"; | ||
|
||
import { useRelease } from '@/lib/release-provider'; | ||
import { Link } from '@nextui-org/link'; | ||
import { ChevronDownIcon } from './icons/ChevronDownIcon'; | ||
|
||
|
||
const DropdownDownload = () => { | ||
const release = useRelease() | ||
const systems = release.systems | ||
const defaultSystem = release.current ?? systems[0] | ||
|
||
return ( | ||
<ButtonGroup variant="flat"> | ||
<Button | ||
href={defaultSystem.href || release.url} | ||
as={Link} | ||
color="primary" | ||
variant="solid" | ||
size='lg' | ||
startContent={ | ||
<defaultSystem.logo className='w-6' /> | ||
} | ||
// showAnchorIcon | ||
> | ||
{defaultSystem.name} | ||
</Button> | ||
<Dropdown placement="bottom-end"> | ||
<DropdownTrigger> | ||
<Button isIconOnly color='primary' variant='solid' size='lg' aria-label="Download options"> | ||
<ChevronDownIcon /> | ||
</Button> | ||
</DropdownTrigger> | ||
<DropdownMenu | ||
// disallowEmptySelection | ||
aria-label="Download options" | ||
// selectionMode="single" | ||
color="primary" | ||
variant="solid" | ||
> | ||
{systems.map((system) => ( | ||
<DropdownItem | ||
key={system.name} | ||
startContent={<system.logo className="w-6" />} | ||
textValue={system.name} | ||
> | ||
<Link color='foreground' href={system.href || ''}> | ||
{system.name} | ||
</Link> | ||
</DropdownItem> | ||
))} | ||
</DropdownMenu> | ||
</Dropdown> | ||
</ButtonGroup> | ||
) | ||
} | ||
|
||
export default DropdownDownload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React, { SVGProps } from "react"; | ||
|
||
type Props = SVGProps<SVGSVGElement> & { | ||
size?: number, | ||
filled?: boolean, | ||
label?: string, | ||
} | ||
|
||
export const ChevronDownIcon = ({ | ||
fill = 'currentColor', | ||
filled, | ||
size, | ||
height, | ||
width, | ||
label, | ||
...props | ||
}: Props) => ( | ||
<svg | ||
width={size || width || 24} | ||
height={size || height || 24} | ||
viewBox="0 0 24 24" | ||
fill={filled ? fill : 'none'} | ||
xmlns="http://www.w3.org/2000/svg" | ||
{...props} | ||
> | ||
<path d="M17.9188 8.17969H11.6888H6.07877C5.11877 8.17969 4.63877 9.33969 5.31877 10.0197L10.4988 15.1997C11.3288 16.0297 12.6788 16.0297 13.5088 15.1997L15.4788 13.2297L18.6888 10.0197C19.3588 9.33969 18.8788 8.17969 17.9188 8.17969Z" stroke={fill} /> | ||
</svg> | ||
); |
Oops, something went wrong.