From 766d6cf26bcaa4612daa34cceb1c09b4a44ea5e4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com>
Date: Tue, 1 Nov 2022 09:55:38 +0000
Subject: [PATCH] feat: conditional URL methods

---
 examples/web/react/app.tsx                    | 23 ++++++++++++++-----
 examples/web/react/components/title/title.css |  3 ++-
 examples/web/react/components/title/title.tsx | 13 +++++++----
 3 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/examples/web/react/app.tsx b/examples/web/react/app.tsx
index b946904a..e7191f85 100644
--- a/examples/web/react/app.tsx
+++ b/examples/web/react/app.tsx
@@ -85,7 +85,7 @@ export interface Emulator extends ObservableI {
      */
     getDevice(): string;
 
-    getDeviceUrl(): string;
+    getDeviceUrl?(): string;
 
     /**
      * Obtains a semantic version string for the current
@@ -103,7 +103,7 @@ export interface Emulator extends ObservableI {
      * @returns A URL to the page describing the current version
      * of the emulator.
      */
-    getVersionUrl(): string;
+    getVersionUrl?(): string;
 
     /**
      * Obtains the pixel format of the emulator's display
@@ -398,15 +398,26 @@ export const App: FC<AppProps> = ({ emulator, backgrounds = ["264653"] }) => {
                 <Title
                     text={emulator.getName()}
                     version={emulator.getVersion()}
-                    versionUrl={emulator.getVersionUrl()}
+                    versionUrl={
+                        emulator.getVersionUrl
+                            ? emulator.getVersionUrl()
+                            : undefined
+                    }
                     iconSrc={require("../res/thunder.png")}
                 ></Title>
                 <Section>
                     <Paragraph>
                         This is a{" "}
-                        <Link href={emulator.getDeviceUrl()} target="_blank">
-                            {emulator.getDevice()}
-                        </Link>{" "}
+                        {emulator.getDeviceUrl ? (
+                            <Link
+                                href={emulator.getDeviceUrl()}
+                                target="_blank"
+                            >
+                                {emulator.getDevice()}
+                            </Link>
+                        ) : (
+                            emulator.getDevice()
+                        )}{" "}
                         emulator built using the{" "}
                         <Link href="https://www.rust-lang.org" target="_blank">
                             Rust Programming Language
diff --git a/examples/web/react/components/title/title.css b/examples/web/react/components/title/title.css
index b10f9b68..7989a40d 100644
--- a/examples/web/react/components/title/title.css
+++ b/examples/web/react/components/title/title.css
@@ -1,4 +1,5 @@
-.title > .link {
+.title > .link,
+.title > .label {
     margin-left: 14px;
 }
 
diff --git a/examples/web/react/components/title/title.tsx b/examples/web/react/components/title/title.tsx
index c3906175..ac312ce7 100644
--- a/examples/web/react/components/title/title.tsx
+++ b/examples/web/react/components/title/title.tsx
@@ -22,11 +22,14 @@ export const Title: FC<TitleProps> = ({
     return (
         <h1 className={classes()}>
             {text}
-            {version && (
-                <Link href={versionUrl} target="_blank">
-                    {version}
-                </Link>
-            )}
+            {version &&
+                (versionUrl ? (
+                    <Link href={versionUrl} target="_blank">
+                        {version}
+                    </Link>
+                ) : (
+                    <span className="label">{version}</span>
+                ))}
             {iconSrc && <img className="icon" src={iconSrc} alt="icon" />}
         </h1>
     );
-- 
GitLab