From bf44b07d00707abbac2e821465666a70314150dd Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Fri, 16 Aug 2024 19:21:58 +0300 Subject: [PATCH] make links in the app more flexible --- rsbuild.config.ts | 1 + src/react/MainMenu.tsx | 31 ++++++++++++++++++++++-------- src/react/MainMenuRenderApp.tsx | 1 + src/react/mainMenu.module.css | 6 ++++++ src/react/mainMenu.module.css.d.ts | 2 ++ 5 files changed, 33 insertions(+), 8 deletions(-) diff --git a/rsbuild.config.ts b/rsbuild.config.ts index 350f2b3a..d72b44ef 100644 --- a/rsbuild.config.ts +++ b/rsbuild.config.ts @@ -63,6 +63,7 @@ export default defineConfig({ // ], define: { 'process.env.BUILD_VERSION': JSON.stringify(!dev ? buildingVersion : 'undefined'), + 'process.env.MAIN_MENU_LINKS': process.env.MAIN_MENU_LINKS, 'process.platform': '"browser"', 'process.env.GITHUB_URL': JSON.stringify(`https://github.com/${process.env.GITHUB_REPOSITORY || `${process.env.VERCEL_GIT_REPO_OWNER}/${process.env.VERCEL_GIT_REPO_SLUG}`}`), diff --git a/src/react/MainMenu.tsx b/src/react/MainMenu.tsx index b9679224..f39bc25e 100644 --- a/src/react/MainMenu.tsx +++ b/src/react/MainMenu.tsx @@ -20,6 +20,7 @@ interface Props { versionStatus?: string versionTitle?: string onVersionClick?: () => void + bottomRightLinks?: string } const httpsRegex = /^https?:\/\// @@ -34,8 +35,11 @@ export default ({ openFileAction, versionStatus, versionTitle, - onVersionClick + onVersionClick, + bottomRightLinks }: Props) => { + const linksParsed = (bottomRightLinks ?? '').split(';').map(l => l.split(':')) as Array<[string, string]> + return (
@@ -108,13 +112,24 @@ export default ({ Prismarine Web Client {versionStatus} - Privacy Policy - +
+ {linksParsed.map(([name, link], i, arr) => { + if (!link.startsWith('http')) link = `https://${link}` + return
+ {name} + + {i < arr.length - 1 && ยท} +
+ })} +
A Minecraft client in the browser!
diff --git a/src/react/MainMenuRenderApp.tsx b/src/react/MainMenuRenderApp.tsx index 98ea0199..acd61803 100644 --- a/src/react/MainMenuRenderApp.tsx +++ b/src/react/MainMenuRenderApp.tsx @@ -99,6 +99,7 @@ export default () => { githubAction={() => openGithub()} optionsAction={() => openOptionsMenu('main')} linksButton={} + bottomRightLinks={process.env.MAIN_MENU_LINKS} openFileAction={e => { if (!!window.showDirectoryPicker && !e.shiftKey) { void openWorldDirectory() diff --git a/src/react/mainMenu.module.css b/src/react/mainMenu.module.css index d4a7e3a5..db072ce1 100644 --- a/src/react/mainMenu.module.css +++ b/src/react/mainMenu.module.css @@ -114,6 +114,12 @@ padding-right: calc(env(safe-area-inset-right) / 2); } +.product-link { + display: flex; + gap: 2; + justify-content: flex-end; +} + @media only screen and (max-height: 420px) { .root { --top-offset: 10px diff --git a/src/react/mainMenu.module.css.d.ts b/src/react/mainMenu.module.css.d.ts index 8cc84b94..c60cf208 100644 --- a/src/react/mainMenu.module.css.d.ts +++ b/src/react/mainMenu.module.css.d.ts @@ -15,8 +15,10 @@ interface CssExports { minecraft: string; 'product-description': string; 'product-info': string; + 'product-link': string; productDescription: string; productInfo: string; + productLink: string; raft: string; root: string; splash: string;