init
initalize repo Co-authored-by: Patrick Massot PatrickMassot@users.noreply.github.com
This commit is contained in:
co-authored by
Patrick Massot PatrickMassot@users.noreply.github.com
commit
7563730292
Binary file not shown.
|
After Width: | Height: | Size: 3.8 KiB |
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Lean 4 Game</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<noscript>
|
||||
You need to enable JavaScript to run this app.
|
||||
</noscript>
|
||||
<script src="../dist/bundle.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 9.4 KiB |
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"short_name": "React App",
|
||||
"name": "Create React App Sample",
|
||||
"icons": [
|
||||
{
|
||||
"src": "favicon.ico",
|
||||
"sizes": "64x64 32x32 24x24 16x16",
|
||||
"type": "image/x-icon"
|
||||
},
|
||||
{
|
||||
"src": "logo192.png",
|
||||
"type": "image/png",
|
||||
"sizes": "192x192"
|
||||
},
|
||||
{
|
||||
"src": "logo512.png",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
],
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "#000000",
|
||||
"background_color": "#ffffff"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
# https://www.robotstxt.org/robotstxt.html
|
||||
User-agent: *
|
||||
Disallow:
|
||||
@@ -0,0 +1,73 @@
|
||||
import React, { useState } from 'react';
|
||||
import { MathJaxContext } from "better-react-mathjax";
|
||||
|
||||
import useWebSocket from 'react-use-websocket';
|
||||
|
||||
import '@fontsource/roboto/300.css';
|
||||
import '@fontsource/roboto/400.css';
|
||||
import '@fontsource/roboto/500.css';
|
||||
import '@fontsource/roboto/700.css';
|
||||
|
||||
import { AppBar, CssBaseline, Toolbar, Typography } from '@mui/material';
|
||||
|
||||
import Welcome from './components/Welcome';
|
||||
import Level from './components/Level';
|
||||
import GoodBye from './components/GoodBye';
|
||||
|
||||
function App() {
|
||||
const [title, setTitle] = useState("")
|
||||
const [conclusion, setConclusion] = useState("")
|
||||
const [levelTitle, setLevelTitle] = useState("")
|
||||
const [nbLevels, setNbLevels] = useState(0)
|
||||
const [curLevel, setCurLevel] = useState(0)
|
||||
const [finished, setFinished] = useState(false)
|
||||
|
||||
const socketUrl = 'ws://' + window.location.hostname + ':8765'
|
||||
const { sendJsonMessage, lastMessage, lastJsonMessage } = useWebSocket(socketUrl)
|
||||
|
||||
const mathJaxConfig = {
|
||||
loader: {
|
||||
load: ['input/tex-base', 'output/svg']
|
||||
},
|
||||
tex: {
|
||||
inlineMath: [['$', '$'], ['\\(', '\\)']]
|
||||
},
|
||||
svg: {
|
||||
fontCache: 'global'
|
||||
}
|
||||
}
|
||||
|
||||
function startGame() {
|
||||
setCurLevel(1)
|
||||
}
|
||||
|
||||
let mainComponent;
|
||||
if (finished) {
|
||||
mainComponent = <GoodBye message={conclusion} />
|
||||
} else if (curLevel > 0) {
|
||||
mainComponent = <Level sendJsonMessage={sendJsonMessage} lastMessage={lastMessage} lastJsonMessage={lastJsonMessage} nbLevels={nbLevels} level={curLevel} setCurLevel={setCurLevel} setLevelTitle={setLevelTitle} setFinished={setFinished}/>
|
||||
} else {
|
||||
mainComponent = <Welcome sendJsonMessage={sendJsonMessage} lastMessage={lastMessage} lastJsonMessage={lastJsonMessage} setNbLevels={setNbLevels} setTitle={setTitle} startGame={startGame} setConclusion={setConclusion}/>
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="App">
|
||||
<MathJaxContext config={mathJaxConfig}>
|
||||
<CssBaseline />
|
||||
<AppBar position="sticky" sx={{ zIndex: (theme) => theme.zIndex.drawer + 1 }}>
|
||||
<Toolbar sx={{ justifyContent: "space-between" }}>
|
||||
<Typography variant="h6" noWrap component="div">
|
||||
{title}
|
||||
</Typography>
|
||||
<Typography variant="h6" noWrap component="div">
|
||||
{levelTitle}
|
||||
</Typography>
|
||||
</Toolbar>
|
||||
</AppBar>
|
||||
{mainComponent}
|
||||
</MathJaxContext>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default App
|
||||
@@ -0,0 +1,8 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import App from './App';
|
||||
|
||||
test('renders learn react link', () => {
|
||||
render(<App />);
|
||||
const linkElement = screen.getByText(/learn react/i);
|
||||
expect(linkElement).toBeInTheDocument();
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
import React from 'react';
|
||||
import '@fontsource/roboto/300.css';
|
||||
import '@fontsource/roboto/400.css';
|
||||
import '@fontsource/roboto/500.css';
|
||||
import '@fontsource/roboto/700.css';
|
||||
|
||||
import { Box, Typography, Grid } from '@mui/material';
|
||||
|
||||
|
||||
function GoodBye({ message }) {
|
||||
return (<Grid container
|
||||
direction="row"
|
||||
justifyContent="center"
|
||||
alignItems="center">
|
||||
<Grid item xs={12} sm={6}>
|
||||
<Box sx={{ m: 3 }}>
|
||||
<Typography variant="body1" component="div">{message}</Typography>
|
||||
</Box>
|
||||
</Grid>
|
||||
</Grid>)
|
||||
}
|
||||
|
||||
export default GoodBye
|
||||
@@ -0,0 +1,62 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import '@fontsource/roboto/300.css';
|
||||
import '@fontsource/roboto/400.css';
|
||||
import '@fontsource/roboto/500.css';
|
||||
import '@fontsource/roboto/700.css';
|
||||
|
||||
import { Typography, Button, Paper, TextField, List, ListItem } from '@mui/material';
|
||||
|
||||
|
||||
function InputZone({ index, history, messageOpen, setMessageOpen, completed, sendTactic, nbLevels, loadNextLevel, errors, lastTactic, undo, finishGame }) {
|
||||
const [curInput, setCurInput] = useState("")
|
||||
|
||||
const inputRef = React.createRef()
|
||||
const nextRef = React.createRef()
|
||||
|
||||
function handleCurInputChange(evt) { setCurInput(evt.target.value) }
|
||||
|
||||
function showPrevMessage() { setMessageOpen(true) }
|
||||
|
||||
useEffect(() => {
|
||||
if (!messageOpen && !completed) inputRef.current.focus()
|
||||
if (!messageOpen && completed && index < nbLevels) nextRef.current.focus()
|
||||
if (!messageOpen && completed && index === nbLevels) finishGame()
|
||||
}, [messageOpen, inputRef, nextRef, completed, finishGame, index, nbLevels])
|
||||
|
||||
async function submitForm(evt) {
|
||||
evt.preventDefault(); // prevent app reloading on form submission
|
||||
await sendTactic(curInput)
|
||||
setCurInput("");
|
||||
}
|
||||
|
||||
return (
|
||||
<Paper sx={{
|
||||
height: "100%", pt: 1, pl: 3, pr: 3, pb: 1,
|
||||
justifyContent: "space-between", alignItems: "center", textAlign: "center"
|
||||
}}
|
||||
elevation={5}>
|
||||
<Typography variant="h5">Invocation zone</Typography>
|
||||
<List dense={true}>
|
||||
{history.map((item, idx) => <ListItem key={idx}>{item}</ListItem>)}
|
||||
</List>
|
||||
<form onSubmit={submitForm}>
|
||||
<TextField
|
||||
id="outlined-input"
|
||||
label="Invocation"
|
||||
autoFocus={true}
|
||||
inputRef={inputRef}
|
||||
value={curInput}
|
||||
onChange={handleCurInputChange}
|
||||
/>
|
||||
<br />
|
||||
<Button type="submit" variant="contained" sx={{ mt: 2 }} disabled={errors.length > 0 || completed || curInput.trim() === ""} disableFocusRipple>Cast spell</Button>
|
||||
<br />
|
||||
<Button variant="text" onClick={undo} sx={{ ml: 3, mt: 2, mb: 2 }} disabled={lastTactic === "" ? true : false || completed}>Undo</Button>
|
||||
{!messageOpen && <Button variant="text" onClick={showPrevMessage} sx={{ ml: 3, mt: 2, mb: 2 }}>See previous message</Button>}
|
||||
<br />
|
||||
{completed && index < nbLevels && <Button variant="contained" ref={nextRef} onClick={loadNextLevel} sx={{ ml: 3, mt: 2, mb: 2 }} disableFocusRipple>Go to Next Level</Button>}
|
||||
</form>
|
||||
</Paper>)
|
||||
}
|
||||
|
||||
export default InputZone
|
||||
@@ -0,0 +1,82 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import { MathJax } from "better-react-mathjax";
|
||||
import '@fontsource/roboto/300.css';
|
||||
import '@fontsource/roboto/400.css';
|
||||
import '@fontsource/roboto/500.css';
|
||||
import '@fontsource/roboto/700.css';
|
||||
|
||||
import { Paper, Box, Typography, Accordion, AccordionSummary, AccordionDetails, Tabs, Tab } from '@mui/material';
|
||||
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
||||
|
||||
|
||||
function TacticDoc(props) {
|
||||
return (
|
||||
<Accordion>
|
||||
<AccordionSummary expandIcon={<ExpandMoreIcon />}>
|
||||
<Typography>{props.tactic.name}</Typography>
|
||||
</AccordionSummary>
|
||||
<AccordionDetails>
|
||||
<MathJax>
|
||||
<ReactMarkdown>{props.tactic.content}</ReactMarkdown>
|
||||
</MathJax>
|
||||
</AccordionDetails>
|
||||
</Accordion>)
|
||||
}
|
||||
|
||||
function LemmaDoc({ lemma }) {
|
||||
return (
|
||||
<Accordion>
|
||||
<AccordionSummary expandIcon={<ExpandMoreIcon />}>
|
||||
<Typography>{lemma.userName}</Typography>
|
||||
</AccordionSummary>
|
||||
<AccordionDetails>
|
||||
<MathJax>
|
||||
<ReactMarkdown>{lemma.content}</ReactMarkdown>
|
||||
</MathJax>
|
||||
</AccordionDetails>
|
||||
</Accordion>)
|
||||
}
|
||||
|
||||
function LemmaDocs({ lemmas }) {
|
||||
const [categories, setCategories] = useState(new Map())
|
||||
const [curCategory, setCurCategory] = useState("")
|
||||
|
||||
useEffect(() => {
|
||||
const cats = new Map()
|
||||
lemmas.forEach(function (item) {
|
||||
const category = item.category
|
||||
cats.set(category, (cats.get(category) || []).concat([item]))
|
||||
});
|
||||
setCategories(cats)
|
||||
setCurCategory(cats.keys().next().value)
|
||||
}, [lemmas]);
|
||||
|
||||
return (
|
||||
<Paper sx={{ px: 2, py: 1, mt: 2 }}>
|
||||
<Typography variant="h5">Inventory</Typography>
|
||||
<Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
|
||||
<Tabs
|
||||
value={curCategory}
|
||||
aria-label="Categories" variant="scrollable" scrollButtons="auto">
|
||||
{(Array.from(categories)).map(([category, _]) => <Tab value={category} label={category} key={category} wrapped />)}
|
||||
</Tabs>
|
||||
</Box>
|
||||
{curCategory && categories.get(curCategory).map((lemma) => <LemmaDoc lemma={lemma} key={lemma.name} />)}
|
||||
</Paper>
|
||||
)
|
||||
}
|
||||
|
||||
function LeftPanel({ spells, inventory }) {
|
||||
return (
|
||||
<Box>
|
||||
{spells.length > 0 &&
|
||||
<Paper sx={{ px: 2, py: 1 }}>
|
||||
<Typography variant="h5" sx={{ mb: 2 }}>Spell book</Typography>
|
||||
{spells.map((spell) => <TacticDoc key={spell.name} tactic={spell} />)}
|
||||
</Paper>}
|
||||
{inventory.length > 0 && <LemmaDocs lemmas={inventory} />}
|
||||
</Box>)
|
||||
}
|
||||
|
||||
export default LeftPanel;
|
||||
@@ -0,0 +1,114 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import '@fontsource/roboto/300.css';
|
||||
import '@fontsource/roboto/400.css';
|
||||
import '@fontsource/roboto/500.css';
|
||||
import '@fontsource/roboto/700.css';
|
||||
|
||||
import Grid from '@mui/material/Unstable_Grid2';
|
||||
|
||||
import LeftPanel from './LeftPanel';
|
||||
import InputZone from './InputZone';
|
||||
import Message from './Message';
|
||||
import TacticState from './TacticState';
|
||||
|
||||
|
||||
|
||||
function Level({ sendJsonMessage, lastMessage, lastJsonMessage, nbLevels, level, setCurLevel, setLevelTitle, setFinished }) {
|
||||
const [index, setIndex] = useState(level) // Level number
|
||||
const [tacticDocs, setTacticDocs] = useState([])
|
||||
const [lemmaDocs, setLemmaDocs] = useState([])
|
||||
|
||||
const [leanData, setLeanData] = useState({})
|
||||
const [history, setHistory] = useState([])
|
||||
const [lastTactic, setLastTactic] = useState("")
|
||||
const [errors, setErrors] = useState([])
|
||||
|
||||
const [message, setMessage] = useState("")
|
||||
const [messageOpen, setMessageOpen] = useState(false)
|
||||
|
||||
|
||||
const [completed, setCompleted] = useState(false)
|
||||
|
||||
// The next function will be called when the level changes
|
||||
useEffect(() => {
|
||||
sendJsonMessage({ "loadLevel": level });
|
||||
}, [level, sendJsonMessage])
|
||||
|
||||
// The next function will be called when a message arrives or the level title changes
|
||||
useEffect(() => {
|
||||
console.log(lastMessage)
|
||||
console.log(lastJsonMessage)
|
||||
if ("nb_levels" in lastJsonMessage) { return } // this is an old message from starting the game
|
||||
const data = lastJsonMessage;
|
||||
if ("title" in data) { // This is the level metadata coming in
|
||||
setLevelTitle("Level " + data["index"] + ": " + data["title"])
|
||||
setIndex(parseInt(data["index"]))
|
||||
setTacticDocs(data["tactics"])
|
||||
setLemmaDocs(data["lemmas"])
|
||||
}
|
||||
|
||||
if (data["message"] !== "" && data.errors.length === 0) {
|
||||
setMessage(data["message"])
|
||||
setMessageOpen(true)
|
||||
}
|
||||
setLeanData(data);
|
||||
setErrors(data.errors);
|
||||
if (data.goals.length === 0 && data.errors.length === 0) {
|
||||
setCompleted(true)
|
||||
}
|
||||
|
||||
}, [lastJsonMessage, lastMessage, setLevelTitle])
|
||||
|
||||
|
||||
function sendTactic(input) {
|
||||
sendJsonMessage({ "runTactic": input });
|
||||
setLastTactic(input);
|
||||
setHistory(history.concat([input]));
|
||||
}
|
||||
|
||||
function undo() {
|
||||
if (errors.length === 0) {
|
||||
sendJsonMessage('undo');
|
||||
}
|
||||
if (history.length > 1) {
|
||||
setLastTactic(history[history.length - 1]);
|
||||
} else {
|
||||
setLastTactic("");
|
||||
};
|
||||
setErrors([]);
|
||||
setHistory(history.slice(0, -1));
|
||||
}
|
||||
|
||||
function loadNextLevel() {
|
||||
setCompleted(false)
|
||||
setHistory([])
|
||||
setCurLevel(index + 1)
|
||||
}
|
||||
|
||||
function closeMessage() {
|
||||
setMessageOpen(false)
|
||||
}
|
||||
|
||||
function finishGame() {
|
||||
setLevelTitle("")
|
||||
setFinished(true)
|
||||
}
|
||||
|
||||
return (
|
||||
<Grid container sx={{ mt: 3, ml: 1, mr: 1 }} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
|
||||
<Grid xs={4}>
|
||||
<LeftPanel spells={tacticDocs} inventory={lemmaDocs} />
|
||||
</Grid>
|
||||
<Grid xs={4}>
|
||||
<InputZone index={index} history={history} messageOpen={messageOpen} setMessageOpen={setMessageOpen} completed={completed} sendTactic={sendTactic} nbLevels={nbLevels} loadNextLevel={loadNextLevel}
|
||||
errors={errors} lastTactic={lastTactic} undo={undo} finishGame={finishGame} />
|
||||
<Message isOpen={messageOpen} content={message} close={closeMessage} />
|
||||
</Grid>
|
||||
<Grid xs={4}>
|
||||
<TacticState goals={leanData.goals} errors={errors} lastTactic={lastTactic} completed={completed} />
|
||||
</Grid>
|
||||
</Grid>
|
||||
)
|
||||
}
|
||||
|
||||
export default Level
|
||||
@@ -0,0 +1,29 @@
|
||||
import React from 'react';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import { MathJax } from "better-react-mathjax";
|
||||
import '@fontsource/roboto/300.css';
|
||||
import '@fontsource/roboto/400.css';
|
||||
import '@fontsource/roboto/500.css';
|
||||
import '@fontsource/roboto/700.css';
|
||||
|
||||
import { Button, Dialog, DialogContent, DialogContentText, DialogActions } from '@mui/material';
|
||||
|
||||
function Message({ isOpen, content, close }) {
|
||||
|
||||
return (
|
||||
<Dialog open={isOpen} onClose={close}>
|
||||
<DialogContent>
|
||||
<DialogContentText id="alert-dialog-description">
|
||||
<MathJax><ReactMarkdown>{content}</ReactMarkdown></MathJax>
|
||||
</DialogContentText>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={close} autoFocus={true} disableFocusRipple>
|
||||
Ok
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
|
||||
export default Message
|
||||
@@ -0,0 +1,69 @@
|
||||
import React from 'react';
|
||||
import '@fontsource/roboto/300.css';
|
||||
import '@fontsource/roboto/400.css';
|
||||
import '@fontsource/roboto/500.css';
|
||||
import '@fontsource/roboto/700.css';
|
||||
|
||||
import List from '@mui/material/List';
|
||||
import ListItem from '@mui/material/ListItem';
|
||||
import { Paper, Box, Typography } from '@mui/material';
|
||||
|
||||
const errorRegex = /<stdin>:1:(?<col>[^:]*): (?<msg>.*)/;
|
||||
|
||||
function Goal({ goal }) {
|
||||
const hasObject = typeof goal.objects === "object" && goal.objects.length > 0
|
||||
const hasAssumption = typeof goal.assumptions === "object" && goal.assumptions.length > 0
|
||||
return (
|
||||
<Box sx={{ pl: 2 }}>
|
||||
{hasObject && <Box><Typography variant="h7">Objects</Typography>
|
||||
<List>
|
||||
{goal.objects.map((item) =>
|
||||
<ListItem key={item[0]}>
|
||||
<Typography color="primary" sx={{ mr: 1 }}>{item[0]}</Typography> :
|
||||
<Typography color="secondary" sx={{ ml: 1 }}>{item[1]}</Typography>
|
||||
</ListItem>)}
|
||||
</List></Box>}
|
||||
{hasAssumption && <Box><Typography variant="h7">Assumptions</Typography>
|
||||
<List>
|
||||
{goal.assumptions.map((item) => <ListItem key={item}><Typography color="primary" sx={{ mr: 1 }}>{item[0]}</Typography> :
|
||||
<Typography color="secondary" sx={{ ml: 1 }}>{item[1]}</Typography></ListItem>)}
|
||||
</List></Box>}
|
||||
<Typography variant="h7">Prove:</Typography>
|
||||
<Typography color="primary" sx={{ ml: 2 }}>{goal.goal}</Typography>
|
||||
</Box>)
|
||||
}
|
||||
|
||||
function TacticState({ goals, errors, lastTactic, completed }) {
|
||||
const hasError = typeof errors === "object" && errors.length > 0
|
||||
const hasGoal = typeof goals === "object" && goals.length > 0
|
||||
const hasManyGoal = hasGoal && goals.length > 1
|
||||
var col = ""
|
||||
var msg = ""
|
||||
if (hasError) {
|
||||
const m = errors[0].match(errorRegex)
|
||||
if (m) {
|
||||
col = `Column ${m.groups.col}: `
|
||||
msg = m.groups.msg
|
||||
} else {
|
||||
msg = errors[0]
|
||||
if (msg === "Unrecognized tactic") { msg = "Unknown spell!" }
|
||||
}
|
||||
}
|
||||
return (
|
||||
<Box sx={{ height: "100%" }}>
|
||||
{hasGoal && <Paper sx={{ pt: 1, pl: 2, pr: 3, pb: 1, height: "100%" }}><Typography variant="h5">Current goal</Typography> <Goal goal={goals[0]} /></Paper>}
|
||||
{completed && <Typography variant="h6">Level completed ! 🎉</Typography>}
|
||||
{hasError && <Paper sx={{ pt: 1, pl: 2, pr: 3, pb: 1, height: "100%" }}><Typography variant="h5" color="error">Spell invocation failed</Typography>
|
||||
<Typography sx={{ my: 1 }}>{lastTactic}</Typography>
|
||||
<Typography component="pre" sx={{ my: 1 }}>{col}{msg}</Typography>
|
||||
<Typography>Use the undo button to go back to a sane state.</Typography>
|
||||
</Paper>}
|
||||
{hasManyGoal && <Paper sx={{ pt: 1, pl: 2, pr: 3, pb: 1, mt: 1 }}>
|
||||
<Typography variant="h6" sx={{ mb: 2 }}>Other goals</Typography>
|
||||
{goals.slice(1).map((goal, index) => <Paper><Goal key={index} goal={goal} /></Paper>)}
|
||||
</Paper>}
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
|
||||
export default TacticState
|
||||
@@ -0,0 +1,52 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import { MathJax } from "better-react-mathjax";
|
||||
import '@fontsource/roboto/300.css';
|
||||
import '@fontsource/roboto/400.css';
|
||||
import '@fontsource/roboto/500.css';
|
||||
import '@fontsource/roboto/700.css';
|
||||
|
||||
import { Box, Typography, Button, CircularProgress, Grid } from '@mui/material';
|
||||
|
||||
|
||||
function Welcome({ sendJsonMessage, lastJsonMessage, setNbLevels, setTitle, startGame, setConclusion }) {
|
||||
|
||||
const [leanData, setLeanData] = useState({})
|
||||
|
||||
// Will run at the very beginning
|
||||
useEffect(() => {
|
||||
sendJsonMessage('info')
|
||||
}, [sendJsonMessage])
|
||||
|
||||
// Will run when a Json message arrives
|
||||
useEffect(() => {
|
||||
if (lastJsonMessage != null && lastJsonMessage.hasOwnProperty("nb_levels")) {
|
||||
setLeanData(lastJsonMessage)
|
||||
setNbLevels(lastJsonMessage.nb_levels)
|
||||
setTitle(lastJsonMessage.title)
|
||||
document.title = lastJsonMessage.title
|
||||
setConclusion(lastJsonMessage.conclusion)
|
||||
}
|
||||
}, [lastJsonMessage, setNbLevels, setTitle, setConclusion])
|
||||
|
||||
let content
|
||||
if ("introduction" in leanData) {
|
||||
content = (<Box sx={{ m: 3 }}>
|
||||
<Typography variant="body1" component="div">
|
||||
<MathJax>
|
||||
<ReactMarkdown>{leanData["introduction"]}</ReactMarkdown>
|
||||
</MathJax>
|
||||
</Typography>
|
||||
<Box textAlign='center' sx={{ m: 5 }}>
|
||||
<Button onClick={startGame} variant="contained">Start rescue mission</Button>
|
||||
</Box>
|
||||
</Box>)
|
||||
} else {
|
||||
content = <Box display="flex" alignItems="center" justifyContent="center" sx={{ height: "calc(100vh - 64px)" }}><CircularProgress /></Box>
|
||||
}
|
||||
return <Grid container direction="row" justifyContent="center" alignItems="center">
|
||||
<Grid item xs={12} sm={6}>{content}</Grid>
|
||||
</Grid>
|
||||
}
|
||||
|
||||
export default Welcome
|
||||
@@ -0,0 +1,11 @@
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: Roboto;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: Roboto Mono;
|
||||
color: rgba(0, 32, 90, 0.87);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import React from 'react'
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import './index.css';
|
||||
import App from './App';
|
||||
|
||||
self.$RefreshReg$ = () => {};
|
||||
self.$RefreshSig$ = () => () => {};
|
||||
|
||||
const container = document.getElementById('root');
|
||||
const root = createRoot(container); // createRoot(container!) if you use TypeScript
|
||||
root.render(<App />);
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>
|
||||
|
After Width: | Height: | Size: 2.6 KiB |
Reference in New Issue
Block a user