From 98ea870a43bf69943ccebf69725d4a191f94e429 Mon Sep 17 00:00:00 2001 From: Jon Eugster Date: Fri, 1 Sep 2023 20:09:49 +0200 Subject: [PATCH] small fixes --- client/src/components/app_bar.tsx | 6 +-- .../src/components/infoview/command_line.tsx | 6 +-- client/src/components/infoview/main.tsx | 16 +++--- client/src/components/level.css | 1 + client/src/components/level.tsx | 7 ++- client/src/components/welcome.css | 53 ------------------- client/src/components/welcome.tsx | 6 ++- client/src/components/world_tree.css | 50 +++++++++++++++++ client/src/components/world_tree.tsx | 10 ++-- 9 files changed, 75 insertions(+), 80 deletions(-) diff --git a/client/src/components/app_bar.tsx b/client/src/components/app_bar.tsx index c45b0b0..781489e 100644 --- a/client/src/components/app_bar.tsx +++ b/client/src/components/app_bar.tsx @@ -83,13 +83,11 @@ export function WelcomeAppBar({gameInfo, toggleImpressum, openEraseMenu, openUpl - - {} - +
- {gameInfo?.title} + {mobile ? '' : gameInfo?.title}
diff --git a/client/src/components/infoview/command_line.tsx b/client/src/components/infoview/command_line.tsx index 100d54b..905c24b 100644 --- a/client/src/components/infoview/command_line.tsx +++ b/client/src/components/infoview/command_line.tsx @@ -64,7 +64,7 @@ config.autoClosingPairs = config.autoClosingPairs.map( monaco.languages.setLanguageConfiguration('lean4cmd', config); /** The input field */ -export function CommandLine({proofPanelRef, hidden}: {proofPanelRef: React.MutableRefObject, hidden?: boolean}) { +export function CommandLine({hidden}: {hidden?: boolean}) { /** Reference to the hidden multi-line editor */ const editor = React.useContext(MonacoEditorContext) @@ -179,11 +179,9 @@ export function CommandLine({proofPanelRef, hidden}: {proofPanelRef: React.Mutab }) // Save the proof to the context setProof(tmpProof) - console.debug('updated proof') - proofPanelRef.current?.lastElementChild?.scrollIntoView() }) }) - }, [editor, rpcSess, uri, model, proofPanelRef]) + }, [editor, rpcSess, uri, model]) // Run the command const runCommand = React.useCallback(() => { diff --git a/client/src/components/infoview/main.tsx b/client/src/components/infoview/main.tsx index f7a2437..2a6f32d 100644 --- a/client/src/components/infoview/main.tsx +++ b/client/src/components/infoview/main.tsx @@ -295,11 +295,6 @@ export function CommandLineInterface(props: { world: string, level: number, data const proofPanelRef = React.useRef(null) - // React.useEffect(() => { - // console.debug('updated proof') - // // proofPanelRef.current?.lastElementChild?.scrollIntoView() //scrollTo(0,0) - // }, [proof]) - /** Delete all proof lines starting from a given line. * Note that the first line (i.e. deleting everything) is `1`! */ @@ -338,6 +333,11 @@ export function CommandLineInterface(props: { world: string, level: number, data } } + // Scroll to the end of the proof if it is updated. + React.useEffect(() => { + proofPanelRef.current?.lastElementChild?.scrollIntoView() //scrollTo(0,0) + }, [proof]) + // Scroll to element if selection changes React.useEffect(() => { if (typeof selectedStep !== 'undefined') { @@ -412,13 +412,13 @@ export function CommandLineInterface(props: { world: string, level: number, data let lastStepErrors = proof.length ? hasInteractiveErrors(proof[proof.length - 1].errors) : false return
-
+
{!proof.length && }
-
+
{proof.length ? <> @@ -483,6 +483,6 @@ export function CommandLineInterface(props: { world: string, level: number, data }
-
} diff --git a/client/src/components/level.css b/client/src/components/level.css index 862b1bf..fd6579f 100644 --- a/client/src/components/level.css +++ b/client/src/components/level.css @@ -26,6 +26,7 @@ .inventory-panel, .exercise-panel, .doc-panel, .introduction-panel { height: 100%; + width: 100%; overflow: auto; position: relative; } diff --git a/client/src/components/level.tsx b/client/src/components/level.tsx index 22c16ca..406f92f 100644 --- a/client/src/components/level.tsx +++ b/client/src/components/level.tsx @@ -392,10 +392,9 @@ function IntroductionPanel({gameInfo, impressum, closeImpressum}) { return
- {text?.map((t => - t.trim() ? - - : <> + {text?.filter(t => t.trim()).map(((t, i) => + ))} {impressum ? : null}
diff --git a/client/src/components/welcome.css b/client/src/components/welcome.css index 84fee15..94e17e3 100644 --- a/client/src/components/welcome.css +++ b/client/src/components/welcome.css @@ -58,59 +58,6 @@ h5, h6 { font-style: italic; } -/***************/ -/* SVG Graphic */ -/***************/ - -svg .world-title-wrapper, svg .level-title-wrapper div { - overflow: visible; -} - -svg .world-title-wrapper div, svg .level-title-wrapper div { - width: 100%; - height: 100%; -} - -svg .world-title-wrapper div, svg .level-title-wrapper div { - display: flex; - align-items:center; - justify-content:center; - overflow: visible; - -} - -svg .world-title, svg .level-title { - color: white; - margin: 0; - padding: 0; - text-align: center; -} - -svg .world-title { - font-weight: 700; -} - -svg .level-title { - font-weight: 400; - opacity: 0; - transition: opacity .3s; -} - -svg .level:hover .level-title { - opacity: 1; -} - -svg .disabled { - cursor: default; -} - -.world-selection { - display: block; - margin-left: auto; - margin-right: auto; - margin-top: 2em; -} - /******************/ /* Privacy Button */ /******************/ diff --git a/client/src/components/welcome.tsx b/client/src/components/welcome.tsx index 36c6f29..1fd637e 100644 --- a/client/src/components/welcome.tsx +++ b/client/src/components/welcome.tsx @@ -35,9 +35,11 @@ function IntroductionPanel({introduction}: {introduction: string}) { return
- {text?.map((t => + {text?.map(((t, i) => t.trim() ? - + : <> ))}
diff --git a/client/src/components/world_tree.css b/client/src/components/world_tree.css index a327076..f343eed 100644 --- a/client/src/components/world_tree.css +++ b/client/src/components/world_tree.css @@ -1,3 +1,53 @@ +svg .world-title-wrapper, svg .level-title-wrapper div { + overflow: visible; +} + +svg .world-title-wrapper div, svg .level-title-wrapper div { + width: 100%; + height: 100%; +} + +svg .world-title-wrapper div, svg .level-title-wrapper div { + display: flex; + align-items:center; + justify-content:center; + overflow: visible; + +} + +svg .world-title, svg .level-title { + color: white; + margin: 0; + padding: 0; + text-align: center; +} + +svg .world-title { + font-weight: 700; +} + +svg .level-title { + font-weight: 400; + opacity: 0; + transition: opacity .3s; +} + +svg .level:hover .level-title { + opacity: 1; +} + +svg .disabled { + cursor: default; +} + +.world-selection { + display: block; + margin-left: auto; + margin-right: auto; + margin-top: 2em; + max-width: 100%; +} + .world-selection-menu { padding: .5em 1em; position: absolute; diff --git a/client/src/components/world_tree.tsx b/client/src/components/world_tree.tsx index 3e54ed8..93043a9 100644 --- a/client/src/components/world_tree.tsx +++ b/client/src/components/world_tree.tsx @@ -268,7 +268,7 @@ export function WorldTreePanel({worlds, worldSize}: let elems = Array.from(document.getElementsByClassName("playable-world")) if (elems.length) { // it seems that the last element is the one furthest up in the tree - // TODO: I think they appear in random order. Check there position and select the lowest one + // TODO: I think they appear in random order. Check their position and select the lowest one // of these positions to scroll to. let elem = elems[0] console.debug(`scrolling to ${elem.textContent}`) @@ -299,7 +299,8 @@ export function WorldTreePanel({worlds, worldSize}: // if the origin world is not completed, mark the target world as non-playable if (!sourceCompleted) {completed[edge[1]][0] = false} svgElements.push( - + ${edge[1]}`} + source={nodes[edge[0]]} target={nodes[edge[1]]} unlocked={sourceCompleted}/> ) } @@ -343,10 +344,9 @@ export function WorldTreePanel({worlds, worldSize}: return
+ className="world-selection" > {svgElements}