From 201321dad0d15798478b4b33cdea9cc15395dcb1 Mon Sep 17 00:00:00 2001 From: Sacha Weatherstone Date: Tue, 7 Dec 2021 22:47:01 +1100 Subject: [PATCH] Add Firmware Page --- website/docusaurus.config.js | 5 ++ .../firmware/_components/FirmwareCard.tsx | 60 +++++++++++++ website/src/pages/firmware/index.tsx | 88 +++++++++---------- 3 files changed, 107 insertions(+), 46 deletions(-) create mode 100644 website/src/pages/firmware/_components/FirmwareCard.tsx diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index 188b3c8f..8158e848 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -32,6 +32,11 @@ const config = { srcDark: "img/meshtastic-design/logo/svg/Mesh_Logo_White.svg", }, items: [ + { + label: "Firmware", + to: "firmware", + activeBasePath: "firmware", + }, { label: "Showcase", to: "showcase", diff --git a/website/src/pages/firmware/_components/FirmwareCard.tsx b/website/src/pages/firmware/_components/FirmwareCard.tsx new file mode 100644 index 00000000..75f84adc --- /dev/null +++ b/website/src/pages/firmware/_components/FirmwareCard.tsx @@ -0,0 +1,60 @@ +import React from 'react'; + +import { Endpoints } from '@octokit/types'; + +export interface FirmwareCardProps { + variant: string; + description: string; + firmware: Endpoints["GET /repos/{owner}/{repo}/releases"]["response"]["data"]; +} + +export const FirmwareCard = ({ + variant, + description, + firmware, +}: FirmwareCardProps): JSX.Element => { + return ( +
+
+

{variant}

+ {firmware?.length && ( + {firmware[0].name} + )} +
+
+

{description}

+
+
+ {firmware?.length ? ( + <> + + Download + +
+

Older versions

+ {firmware.slice(1, 6).map((release) => { + return ( +
+ + {release.name} + +
+ ); + })} +
+ + ) : ( + + )} +
+
+ ); +}; diff --git a/website/src/pages/firmware/index.tsx b/website/src/pages/firmware/index.tsx index 65ddb2c6..a4a87e33 100644 --- a/website/src/pages/firmware/index.tsx +++ b/website/src/pages/firmware/index.tsx @@ -1,8 +1,33 @@ import React from 'react'; +import { Octokit } from '@octokit/rest'; +import { Endpoints } from '@octokit/types'; import Layout from '@theme/Layout'; +import { FirmwareCard } from './_components/FirmwareCard'; + const Firmware = (): JSX.Element => { + const gh = new Octokit(); + + const [releases, setReleases] = + React.useState< + Endpoints["GET /repos/{owner}/{repo}/releases"]["response"] + >(); + + gh.repos + .listReleases({ + owner: "meshtastic", + repo: "meshtastic-device", + }) + .then((response) => { + if (response.data) { + setReleases(response); + } + }); + + const beta = releases?.data.filter((release) => release.prerelease === false); + + const alpha = releases?.data.filter((release) => release.prerelease === true); return ( { >
- {/* */} -
-

Stable

-
    { }} > {/* */} -
    -
    -

    Beta

    -
    -
    -

    Tested feature set. For those who want stability.

    -
    -
    - -
    -
    - - {/* */} - {/* */} -
    -
    -

    Alpha

    -
    -
    -

    - Upcomming changes for testing. For those who want new - features. -

    -
    -
    - -
    -
    + + {/* */} {/* */} @@ -75,10 +68,13 @@ const Firmware = (): JSX.Element => { things.

-
- +
+ + Download +