toggle inventory on mobile

pull/118/head
Jon Eugster 2 years ago
parent 34009bcc17
commit 3a50b4ab88

@ -301,3 +301,7 @@ td code {
.menu.dropdown .svg-inline--fa { .menu.dropdown .svg-inline--fa {
width: 1.8rem; width: 1.8rem;
} }
.nav-btns .btn {
margin-left: .5em;
}

@ -26,7 +26,7 @@ import { EditorConnection, EditorEvents } from '../../../node_modules/lean4-info
import { EventEmitter } from '../../../node_modules/lean4-infoview/src/infoview/event'; import { EventEmitter } from '../../../node_modules/lean4-infoview/src/infoview/event';
import type { Location } from 'vscode-languageserver-protocol'; import type { Location } from 'vscode-languageserver-protocol';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faBars, faCode, faPencilSquare, faXmark, faHome, faCircleInfo, faArrowRight, faArrowLeft, faShield, faRotateLeft } from '@fortawesome/free-solid-svg-icons' import { faBars, faBook, faCode, faPencilSquare, faXmark, faHome, faCircleInfo, faArrowRight, faArrowLeft, faShield, faRotateLeft } from '@fortawesome/free-solid-svg-icons'
import { styled, useTheme, Theme, CSSObject } from '@mui/material/styles'; import { styled, useTheme, Theme, CSSObject } from '@mui/material/styles';
import { GameIdContext } from '../app'; import { GameIdContext } from '../app';
@ -45,6 +45,7 @@ import { GameHint } from './infoview/rpc_api';
import { Impressum } from './privacy_policy'; import { Impressum } from './privacy_policy';
import { store } from '../state/store'; import { store } from '../state/store';
import { useWindowDimensions } from '../window_width'; import { useWindowDimensions } from '../window_width';
import { ArrowLeft } from '@mui/icons-material';
function Level() { function Level() {
@ -307,8 +308,11 @@ function PlayableLevel({worldId, levelId}) {
<LevelAppBar isLoading={level.isLoading} <LevelAppBar isLoading={level.isLoading}
levelTitle={`${mobile ? '' : 'Level '}${levelId} / ${gameInfo.data?.worldSize[worldId]}` + levelTitle={`${mobile ? '' : 'Level '}${levelId} / ${gameInfo.data?.worldSize[worldId]}` +
(level?.data?.title && ` : ${level?.data?.title}`)} (level?.data?.title && ` : ${level?.data?.title}`)}
worldId={worldId} levelId={levelId} toggleImpressum={toggleImpressum}/> worldId={worldId} levelId={levelId} toggleImpressum={toggleImpressum}
pageNumber={pageNumber} setPageNumber={setPageNumber}/>
{mobile? {mobile?
// TODO: This is copied from the `Split` component below...
<>
<div className={`app-content level-mobile ${level.isLoading ? 'hidden' : ''}`}> <div className={`app-content level-mobile ${level.isLoading ? 'hidden' : ''}`}>
<div className={`exercise-panel ${pageNumber == 0 ? '' : 'hidden'}`}> <div className={`exercise-panel ${pageNumber == 0 ? '' : 'hidden'}`}>
<EditorContext.Provider value={editorConnection}> <EditorContext.Provider value={editorConnection}>
@ -321,6 +325,16 @@ function PlayableLevel({worldId, levelId}) {
{impressum ? <Impressum handleClose={closeImpressum} /> : null} {impressum ? <Impressum handleClose={closeImpressum} /> : null}
</div> </div>
</div> </div>
<div className={`inventory-panel ${pageNumber == 1 ? '' : 'hidden'}`}>
{!level.isLoading &&
<>{inventoryDoc ?
<Documentation name={inventoryDoc.name} type={inventoryDoc.type} handleClose={closeInventoryDoc}/>
:
<Inventory levelInfo={level?.data} openDoc={openInventoryDoc} />
}</>
}
</div>
</>
: :
<Split minSize={0} snapOffset={200} sizes={[25, 50, 25]} className={`app-content level ${level.isLoading ? 'hidden' : ''}`}> <Split minSize={0} snapOffset={200} sizes={[25, 50, 25]} className={`app-content level ${level.isLoading ? 'hidden' : ''}`}>
<div className="chat-panel"> <div className="chat-panel">
@ -436,7 +450,7 @@ function Introduction({worldId}) {
} }
/** The top-navigation bar */ /** The top-navigation bar */
function LevelAppBar({isLoading, levelId, worldId, levelTitle, toggleImpressum}) { function LevelAppBar({isLoading, levelId, worldId, levelTitle, toggleImpressum, pageNumber = undefined, setPageNumber = undefined}) {
const gameId = React.useContext(GameIdContext) const gameId = React.useContext(GameIdContext)
const gameInfo = useGetGameInfoQuery({game: gameId}) const gameInfo = useGetGameInfoQuery({game: gameId})
@ -462,9 +476,22 @@ function LevelAppBar({isLoading, levelId, worldId, levelTitle, toggleImpressum})
{levelTitle} {levelTitle}
</span> </span>
</div> </div>
<div className="nav-btns">
{pageNumber == 0 ?
<Button to=""
title="show inventory" inverted="true" onClick={() => {setPageNumber(1)}}>
<FontAwesomeIcon icon={faBook}/>
</Button>
: pageNumber == 1 &&
<Button to=""
title="show inventory" inverted="true" onClick={() => {setPageNumber(0)}}>
<FontAwesomeIcon icon={faArrowLeft}/>
</Button>
}
<Button to="" id="menu-btn" onClick={(ev) => {setNavOpen(!navOpen)}} > <Button to="" id="menu-btn" onClick={(ev) => {setNavOpen(!navOpen)}} >
{navOpen ? <FontAwesomeIcon icon={faXmark} /> : <FontAwesomeIcon icon={faBars} />} {navOpen ? <FontAwesomeIcon icon={faXmark} /> : <FontAwesomeIcon icon={faBars} />}
</Button> </Button>
</div>
<div className={'menu dropdown' + (navOpen ? '' : ' hidden')}> <div className={'menu dropdown' + (navOpen ? '' : ' hidden')}>
{levelId < gameInfo.data?.worldSize[worldId] && {levelId < gameInfo.data?.worldSize[worldId] &&
<Button inverted="true" <Button inverted="true"

@ -236,6 +236,7 @@ svg .disabled {
padding-bottom: .5em; padding-bottom: .5em;
position:relative; position:relative;
height: 3em; height: 3em;
width: 100%;
} }
.mobile-nav .btn-next, .mobile-nav .btn-previous { .mobile-nav .btn-next, .mobile-nav .btn-previous {

@ -204,7 +204,7 @@ function Welcome() {
<FontAwesomeIcon icon={faArrowLeft} />&nbsp;<FontAwesomeIcon icon={faGlobe} /> <FontAwesomeIcon icon={faArrowLeft} />&nbsp;<FontAwesomeIcon icon={faGlobe} />
</Button> </Button>
<Button className="btn btn-next" to="" <Button className="btn btn-next" to=""
title="show inventory" onClick={() => {setPageNumber(1)}}> title="world tree" onClick={() => {setPageNumber(1)}}>
Game&nbsp;<FontAwesomeIcon icon={faArrowRight}/> Game&nbsp;<FontAwesomeIcon icon={faArrowRight}/>
</Button> </Button>
</div> </div>
@ -237,7 +237,7 @@ function Welcome() {
<div className="inventory-panel"> <div className="inventory-panel">
<div className="mobile-nav"> <div className="mobile-nav">
<Button className="btn btn-previous" to="" <Button className="btn btn-previous" to=""
title="back to introduction" onClick={() => {setPageNumber(1)}}> title="world tree" onClick={() => {setPageNumber(1)}}>
<FontAwesomeIcon icon={faArrowLeft} />&nbsp;Game <FontAwesomeIcon icon={faArrowLeft} />&nbsp;Game
</Button> </Button>
</div> </div>

Loading…
Cancel
Save