From 2774fab98c8645ced402428a0673681d55f95194 Mon Sep 17 00:00:00 2001 From: Alexander Bentkamp Date: Fri, 27 Jan 2023 17:28:32 +0100 Subject: [PATCH] replace mui buttons, move them into bar --- client/src/App.tsx | 8 ------ client/src/app.css | 17 ++++++++++++ client/src/components/Button.tsx | 14 ++++++++++ client/src/components/Level.tsx | 46 ++++++++++++++++--------------- client/src/components/Welcome.tsx | 2 +- 5 files changed, 56 insertions(+), 31 deletions(-) create mode 100644 client/src/components/Button.tsx diff --git a/client/src/App.tsx b/client/src/App.tsx index d6d63ad..d701443 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -19,14 +19,6 @@ function App() { return (
-
-
- {title} -
-
- {subtitle} -
-
diff --git a/client/src/app.css b/client/src/app.css index 531bf5e..bf75faf 100644 --- a/client/src/app.css +++ b/client/src/app.css @@ -34,6 +34,21 @@ code { align-items: center; } +.btn { + text-decoration: none; + color: var(--clr-primary); + background: white; + display: inline-block; + border-radius: 0.2em; + padding: 0.2em .6em; + font-size: 1rem; + margin: 0 .2em; +} + +.btn-disabled { + color: #aaa; +} + /* App Bar */ #root { @@ -61,6 +76,8 @@ code { color: white; font-weight: 500; font-size: 1.3rem; + display: inline-block; + margin: 0 1em; } .app-content { diff --git a/client/src/components/Button.tsx b/client/src/components/Button.tsx new file mode 100644 index 0000000..2035744 --- /dev/null +++ b/client/src/components/Button.tsx @@ -0,0 +1,14 @@ +import * as React from 'react'; +import { Link, LinkProps } from "react-router-dom"; + +export interface ButtonProps extends LinkProps { + disabled?: boolean +} + +export function Button(props: ButtonProps) { + if (props.disabled) { + return {props.children} + } else { + return {props.children} + } +} diff --git a/client/src/components/Level.tsx b/client/src/components/Level.tsx index 49392c0..18b511e 100644 --- a/client/src/components/Level.tsx +++ b/client/src/components/Level.tsx @@ -5,8 +5,8 @@ import '@fontsource/roboto/400.css'; import '@fontsource/roboto/500.css'; import '@fontsource/roboto/700.css'; import { InfoviewApi } from '@leanprover/infoview' -import { Link as RouterLink } from 'react-router-dom'; -import { Box, Button, CircularProgress, FormControlLabel, FormGroup, Switch, IconButton } from '@mui/material'; +import { Link, useParams } from 'react-router-dom'; +import { Box, CircularProgress, FormControlLabel, FormGroup, Switch, IconButton } from '@mui/material'; import MuiDrawer from '@mui/material/Drawer'; import Grid from '@mui/material/Unstable_Grid2'; import LeftPanel from './LeftPanel'; @@ -19,8 +19,8 @@ import { InfoProvider } from 'lean4web/client/src/editor/infoview'; import 'lean4web/client/src/editor/infoview.css' import * as monaco from 'monaco-editor/esm/vs/editor/editor.api.js' import './level.css' +import { Button } from './Button' import { ConnectionContext, useLeanClient } from '../connection'; -import { useParams } from 'react-router-dom'; import { useGetGameInfoQuery, useLoadLevelQuery } from '../state/api'; import { codeEdited, selectCode } from '../state/progress'; import { useAppDispatch } from '../hooks'; @@ -143,13 +143,9 @@ function Level() { const {setTitle, setSubtitle} = React.useContext(SetTitleContext); - useEffect(() => { - setTitle(`World: ${gameInfo.data?.worlds.nodes[worldId].title}`) - }, [gameInfo.data?.worlds.nodes[worldId].title]) - useEffect(() => { if (level?.data?.title) { - setSubtitle(`Level ${levelId}: ${level?.data?.title}`) + setSubtitle(``) } else { setSubtitle(`Level ${levelId}`) } @@ -157,6 +153,26 @@ function Level() { return <>
+
+
+ + + {gameInfo.data?.worlds.nodes[worldId].title && `World: ${gameInfo.data?.worlds.nodes[worldId].title}`} + +
+
+ + {levelId && `Level ${levelId}`}{level?.data?.title && `: ${level?.data?.title}`} + + + +
+ +
@@ -180,20 +196,6 @@ function Level() {
- - - - - - {editorConnection &&
} diff --git a/client/src/components/Welcome.tsx b/client/src/components/Welcome.tsx index a121968..6f36a6f 100644 --- a/client/src/components/Welcome.tsx +++ b/client/src/components/Welcome.tsx @@ -3,7 +3,7 @@ import { useState, useEffect, useRef } from 'react'; import './welcome.css' import cytoscape, { LayoutOptions } from 'cytoscape' import klay from 'cytoscape-klay'; -import { Link as RouterLink, useNavigate } from 'react-router-dom'; +import { useNavigate } from 'react-router-dom'; import { useSelector } from 'react-redux';