diff --git a/client/src/components/privacy_policy.tsx b/client/src/components/privacy_policy.tsx index 7038485..03ac0f4 100644 --- a/client/src/components/privacy_policy.tsx +++ b/client/src/components/privacy_policy.tsx @@ -48,14 +48,14 @@ export const PrivacyPolicy: React.FC = () => { const handleOpen = () => setOpen(true) const handleClose = () => setOpen(false) return ( - + <>

legal

notes

{open ? : null} -
+ ) } diff --git a/client/src/components/welcome.css b/client/src/components/welcome.css index 595bed4..26ed0e8 100644 --- a/client/src/components/welcome.css +++ b/client/src/components/welcome.css @@ -115,7 +115,7 @@ svg .disabled { height: 40px; font-size: 25px; border-radius: 20px; - position: absolute; + position: fixed; right: 10px; bottom: 10px; display: flex; @@ -230,3 +230,27 @@ svg .disabled { text-decoration: underline dotted; } + +.mobile-nav { + padding-top: .5em; + padding-bottom: .5em; + position:relative; + height: 3em; +} + +.mobile-nav .btn-next, .mobile-nav .btn-previous { + position: absolute; + margin: 0; +} + +.mobile-nav .btn-previous { + left: 0; + border-top-left-radius: 0; + border-bottom-left-radius: 0; +} + +.mobile-nav .btn-next { + right: 0; + border-top-right-radius: 0; + border-bottom-right-radius: 0; +} diff --git a/client/src/components/welcome.tsx b/client/src/components/welcome.tsx index 74bbea9..9a0a1d6 100644 --- a/client/src/components/welcome.tsx +++ b/client/src/components/welcome.tsx @@ -9,7 +9,7 @@ import cytoscape, { LayoutOptions } from 'cytoscape' import klay from 'cytoscape-klay'; import './welcome.css' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { faGlobe, faHome, faCircleInfo, faArrowRight, faArrowLeft, faShield, faRotateLeft } from '@fortawesome/free-solid-svg-icons' +import { faGlobe, faBook, faHome, faCircleInfo, faArrowRight, faArrowLeft, faShield, faRotateLeft } from '@fortawesome/free-solid-svg-icons' import { GameIdContext } from '../app'; import { selectCompleted, selectDifficulty } from '../state/progress'; import { useGetGameInfoQuery, useLoadInventoryOverviewQuery } from '../state/api'; @@ -19,6 +19,7 @@ import {PrivacyPolicy} from './privacy_policy'; import { Button } from './button'; import { Documentation, Inventory } from './inventory'; import { store } from '../state/store'; +import { useWindowDimensions } from '../window_width'; cytoscape.use( klay ); @@ -59,7 +60,14 @@ function LevelIcon({ worldId, levelId, position, completed, available }) { function Welcome() { const navigate = useNavigate(); - const [mobileLayout, setModileLayout] = useState(false) + + // TODO: Make mobileLayout be changeable in settings + // TODO: Handle resize Events + const {width, height} = useWindowDimensions() + const [mobileLayout, setModileLayout] = useState(width < 800) + + /** Only for mobile layout */ + const [pageNumber, setPageNumber] = useState(0) const gameId = React.useContext(GameIdContext) const gameInfo = useGetGameInfoQuery({game: gameId}) @@ -184,13 +192,67 @@ function Welcome() { let dx = bounds ? s*(bounds.x2 - bounds.x1) + 2*padding : null - return
+ // TODO: Pack the three columns into components, so we dont need to + // copy them for mobile layout + return
{ gameInfo.isLoading? : mobileLayout ? - <> + (pageNumber == 0 ? +
+
+ + +
+ + {gameInfo.data?.introduction} + +
+ : pageNumber == 1 ? +
+
+ + +
+ + + {svgElements} + +
+ : +
+
+ +
+ {<> + {inventoryDoc ? + + : + + } + } +
+ ) :
@@ -220,7 +282,7 @@ function Welcome() {
} - +
} diff --git a/client/src/components/world_selection_menu.css b/client/src/components/world_selection_menu.css index 806cb2a..5cf54fb 100644 --- a/client/src/components/world_selection_menu.css +++ b/client/src/components/world_selection_menu.css @@ -28,7 +28,7 @@ } /* Test for mobile `title`s */ -@media (pointer: coarse), (hover: none) { +/* @media (pointer: coarse), (hover: none) { [title] { position: relative; display: inline-flex; @@ -44,4 +44,4 @@ width: fit-content; padding: 3px; } -} +} */ diff --git a/client/src/window_width.tsx b/client/src/window_width.tsx new file mode 100644 index 0000000..9e8b484 --- /dev/null +++ b/client/src/window_width.tsx @@ -0,0 +1,21 @@ +import {useState, useEffect} from 'react' + +function getWindowDimensions() { + const {innerWidth: width, innerHeight: height } = window + return {width, height} +} + +export function useWindowDimensions() { + const [windowDimensions, setWindowDimensions] = useState(getWindowDimensions()) + + useEffect(() => { + function handleResize() { + setWindowDimensions(getWindowDimensions()) + } + window.addEventListener('resize', handleResize) + return () => window.removeEventListener('resize', handleResize) + + }, []) + + return windowDimensions +}