From 9c6ed17113a8e810168e2ec230e33c048955e7c7 Mon Sep 17 00:00:00 2001 From: Jon Eugster Date: Fri, 1 Sep 2023 13:04:22 +0200 Subject: [PATCH] coulour introduction texts #100 --- client/src/components/level.tsx | 19 ++++++++++++------- client/src/components/welcome.tsx | 23 +++++++++++++++++++---- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/client/src/components/level.tsx b/client/src/components/level.tsx index 2a7d975e..22c16ca5 100644 --- a/client/src/components/level.tsx +++ b/client/src/components/level.tsx @@ -32,7 +32,7 @@ import { DeletedChatContext, InputModeContext, MobileContext, MonacoEditorContex ProofContext, ProofStep, SelectionContext, WorldLevelIdContext } from './infoview/context' import { DualEditor } from './infoview/main' import { GameHint } from './infoview/rpc_api' -import { DeletedHints, Hints } from './hints' +import { DeletedHints, Hint, Hints } from './hints' import { Impressum } from './privacy_policy' import '@fontsource/roboto/300.css' @@ -388,11 +388,15 @@ function IntroductionPanel({gameInfo, impressum, closeImpressum}) { const gameId = React.useContext(GameIdContext) const {worldId} = useContext(WorldLevelIdContext) - return
+ let text: Array = gameInfo.data?.worlds.nodes[worldId].introduction.split(/\n(\s*\n)+/) + + return
- - {gameInfo.data?.worlds.nodes[worldId].introduction} - + {text?.map((t => + t.trim() ? + + : <> + ))} {impressum ? : null}
@@ -428,9 +432,10 @@ function Introduction() { } return <> -
- {mobile ? + {gameInfo.isLoading ? +
+ : mobile ? : diff --git a/client/src/components/welcome.tsx b/client/src/components/welcome.tsx index bbbd45bc..acc32028 100644 --- a/client/src/components/welcome.tsx +++ b/client/src/components/welcome.tsx @@ -19,6 +19,7 @@ import { WorldTreePanel, downloadFile } from './world_tree' import './welcome.css' import { WelcomeAppBar } from './app_bar' +import { Hint } from './hints' /** The panel showing the game's introduction text */ function IntroductionPanel({introduction}: {introduction: string}) { @@ -26,11 +27,25 @@ function IntroductionPanel({introduction}: {introduction: string}) { const gameId = React.useContext(GameIdContext) const dispatch = useAppDispatch() + // TODO: I left the setup for splitting up the introduction in place, but if it's not needed + // then this can be simplified. + + // let text: Array = introduction.split(/\n(\s*\n)+/) + let text: Array = [introduction] + return
- - {/*

{title}

*/} - {introduction} -
+
+ {text?.map((t => + t.trim() ? + + : <> + ))} +
+ {/* +

{title}

+ {introduction} +
+ */} {mobile &&