From b88346cdb2ee7bcfc2d5527e515cd0a50e9d1eb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com> Date: Mon, 14 Nov 2022 10:48:07 +0000 Subject: [PATCH] feat: repository link dynamic --- examples/web/gb.ts | 8 ++++++++ examples/web/react/app.tsx | 40 +++++++++++++++++++++++++++----------- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/examples/web/gb.ts b/examples/web/gb.ts index 6f2cf8aa..0f6dc9d4 100644 --- a/examples/web/gb.ts +++ b/examples/web/gb.ts @@ -373,6 +373,14 @@ export class GameboyEmulator extends EmulatorBase implements Emulator { return "https://gitlab.stage.hive.pt/joamag/boytacean/-/blob/master/CHANGELOG.md"; } + get repository(): string | undefined { + return "GitLab"; + } + + get repositoryUrl(): string | undefined { + return "https://gitlab.stage.hive.pt/joamag/boytacean"; + } + get features(): Feature[] { return [ Feature.Debug, diff --git a/examples/web/react/app.tsx b/examples/web/react/app.tsx index 21113e59..89ab434a 100644 --- a/examples/web/react/app.tsx +++ b/examples/web/react/app.tsx @@ -128,7 +128,11 @@ export interface Emulator extends ObservableI { * The URL to the page describing the current version * of the emulator. */ - get versionUrl(): string; + get versionUrl(): string | undefined; + + get repository(): string | undefined; + + get repositoryUrl(): string | undefined; /** * The features available and compatible with the emulator, @@ -264,6 +268,14 @@ export class EmulatorBase extends Observable { return undefined; } + get repository(): string | undefined { + return undefined; + } + + get repositoryUrl(): string | undefined { + return undefined; + } + get features(): Feature[] { return []; } @@ -645,16 +657,22 @@ export const App: FC<AppProps> = ({ </Link> . </Paragraph> - <Paragraph> - You can check the source code of it at{" "} - <Link - href="https://gitlab.stage.hive.pt/joamag/boytacean" - target="_blank" - > - GitLab - </Link> - . - </Paragraph> + {emulator.repository && ( + <Paragraph> + You can check the source code of it at{" "} + {emulator.repositoryUrl ? ( + <Link + href={emulator.repositoryUrl} + target="_blank" + > + {emulator.repository} + </Link> + ) : ( + <>{emulator.repository}</> + )} + . + </Paragraph> + )} <Paragraph> TIP: Drag and Drop ROM files to the Browser to load the ROM. -- GitLab