-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Interface the release api from Github
- Loading branch information
Showing
10 changed files
with
178 additions
and
56 deletions.
There are no files selected for viewing
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,3 @@ | ||
export function Spacer() { | ||
return <div className="mb-5 mt-5"></div>; | ||
} |
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 |
---|---|---|
@@ -1,44 +1,35 @@ | ||
import type { JsxElement } from "typescript"; | ||
import consts from "../common/consts"; | ||
import icons from "../common/icons"; | ||
import { FooterButton } from "./footerButton"; | ||
import { BigIcon, Icon } from "./icon"; | ||
import { SpinningLogo } from "./spinningLogo"; | ||
import { Modal } from "./modal"; | ||
|
||
export const DonationModal = (exitModal: Function) => ( | ||
<> | ||
<div className="fixed left-1/2 top-1/2 z-50 m-auto -translate-x-1/2 -translate-y-1/2 rounded bg-slate-50 p-5 shadow-xl"> | ||
<div className="flex flex-col items-center self-center"> | ||
<div className="flex w-full flex-row"> | ||
<SpinningLogo className="m-auto h-8 w-8" spinInitially={true} /> | ||
<button | ||
className="absolute right-2 top-2 rounded-full border border-body-700 px-2 text-body-700 hover:border-primary-600 hover:text-primary-600" | ||
onClick={() => exitModal()} | ||
> | ||
X | ||
</button> | ||
</div> | ||
export const DonationModal = (exitModal: Function) => <Modal exitModal={exitModal}>{Donation(exitModal)}</Modal>; | ||
|
||
<div className="m-2">Thanks for downloading FanControl !</div> | ||
|
||
<div className="m-2 flex flex-row space-x-4"> | ||
<FooterButton | ||
iconSvgPath={icons.svgPaths.heart} | ||
href={consts.urls.sponsor} | ||
text="Sponsor" | ||
/> | ||
<FooterButton | ||
iconSvgPath={icons.svgPaths.paypal} | ||
href={consts.urls.donationUrl} | ||
viewBox="0 0 16 16" | ||
text="PayPal" | ||
/> | ||
</div> | ||
function Donation(exitModal: Function) { | ||
return ( | ||
<> | ||
<div className="flex w-full flex-row"> | ||
<SpinningLogo className="m-auto h-8 w-8" spinInitially={true} /> | ||
</div> | ||
</div> | ||
|
||
<div | ||
onClick={() => exitModal()} | ||
className="fixed left-0 top-0 z-40 block h-full w-full bg-black opacity-50 " | ||
></div> | ||
</> | ||
); | ||
<div className="m-2">Thanks for downloading FanControl !</div> | ||
|
||
<div className="m-2 flex flex-row space-x-4"> | ||
<FooterButton | ||
iconSvgPath={icons.svgPaths.heart} | ||
href={consts.urls.sponsor} | ||
text="Sponsor" | ||
/> | ||
<FooterButton | ||
iconSvgPath={icons.svgPaths.paypal} | ||
href={consts.urls.donationUrl} | ||
viewBox="0 0 16 16" | ||
text="PayPal" | ||
/> | ||
</div> | ||
</> | ||
); | ||
} |
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,41 @@ | ||
import consts from "../common/consts"; | ||
import { Spacer } from "./Spacer"; | ||
import { TrackedAnchor, TrackedExternalLink } from "./links"; | ||
import { Modal } from "./modal"; | ||
import { getDownloadUrl } from "./services/versionService"; | ||
|
||
type downloadProps = { | ||
version: number; | ||
exitModal: Function; | ||
onDownload: Function; | ||
}; | ||
|
||
function Download(props: downloadProps) { | ||
const fanControlStr: string = `Fan Control V${props.version}`; | ||
|
||
const portableDownloadNet8 = getDownloadUrl("net_8_0"); | ||
|
||
return ( | ||
<div className="text-left"> | ||
<div className="text-xl font-medium">Portable</div> | ||
<TrackedExternalLink | ||
href={consts.urls.directDownloadUrl} | ||
onClick={() => props.onDownload()} | ||
> | ||
{fanControlStr} .NET Framework 4.8 | ||
</TrackedExternalLink> | ||
<br /> | ||
<TrackedExternalLink | ||
href={portableDownloadNet8} | ||
onClick={() => props.onDownload()} | ||
> | ||
{fanControlStr} .NET 8 | ||
</TrackedExternalLink> | ||
<br /> | ||
</div> | ||
); | ||
} | ||
|
||
export const DownloadModal = (props: downloadProps) => ( | ||
<Modal exitModal={props.exitModal}>{Download(props)}</Modal> | ||
); |
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,30 @@ | ||
import type { ReactNode } from "react"; | ||
|
||
export const Modal = ({ | ||
children: children, | ||
exitModal | ||
}: { | ||
children: ReactNode; | ||
exitModal: Function; | ||
}) => ( | ||
<> | ||
<div className="fixed left-1/2 top-1/2 z-50 m-auto -translate-x-1/2 -translate-y-1/2 rounded bg-slate-50 p-5 shadow-xl"> | ||
{XButton(exitModal)} | ||
<div className="flex flex-col items-center self-center">{children}</div> | ||
</div> | ||
|
||
<div | ||
onClick={() => exitModal()} | ||
className="fixed left-0 top-0 z-40 block h-full w-full bg-black opacity-50 " | ||
></div> | ||
</> | ||
); | ||
function XButton(exitModal: Function) { | ||
return <button | ||
className="absolute right-2 top-2 rounded-full border border-body-700 px-2 text-body-700 hover:border-primary-600 hover:text-primary-600" | ||
onClick={() => exitModal()} | ||
> | ||
X | ||
</button>; | ||
} | ||
|
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export function PageHeader({ text }: { text: string }): JSX.Element { | ||
export function PageHeader({ children: text }: { children: string }): JSX.Element { | ||
return <h1 className="mt-5 text-5xl font-light">{text}</h1>; | ||
} |
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,55 @@ | ||
import consts from "../../common/consts"; | ||
|
||
type VersionInfoJson = { | ||
Number: number; | ||
Message: string; | ||
}; | ||
|
||
type VersionInfo = { | ||
Number: number; | ||
Message: string[]; | ||
}; | ||
|
||
async function getVersion() { | ||
var req = await fetch(consts.urls.versionJsonUrl); | ||
var json = (await req.json()) as VersionInfoJson; | ||
var versionInfo: VersionInfo = { | ||
Number: json.Number, | ||
Message: (json.Message as String).split("\r\n").map((x) => x.trim()) | ||
}; | ||
|
||
return versionInfo; | ||
} | ||
|
||
type Asset = { | ||
name: string; | ||
download_count: number; | ||
browser_download_url: string; | ||
}; | ||
|
||
type LatestRelease = { | ||
assets: Asset[]; | ||
name: string; | ||
tag_name: string; | ||
}; | ||
|
||
async function getLatestRelease() { | ||
const req = await fetch(consts.urls.latestVersionGithubApiUrl); | ||
const json = (await req.json()) as LatestRelease; | ||
return json; | ||
} | ||
|
||
const latestRelease = await getLatestRelease(); | ||
|
||
export function getDownloadUrl(searchStr: string) { | ||
const asset = latestRelease.assets.find((a) => | ||
a.name.toLowerCase().includes(searchStr.toLowerCase()) | ||
); | ||
if (asset) { | ||
return asset.browser_download_url; | ||
} | ||
|
||
return ""; | ||
} | ||
|
||
export const versionInfo = await getVersion(); |
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