Skip to content

Commit

Permalink
feat: show instruction dialog for users visiting WalkInWallet for the…
Browse files Browse the repository at this point in the history
…ir first time
  • Loading branch information
fabianbormann committed Aug 30, 2023
1 parent 5439482 commit f1a97d6
Show file tree
Hide file tree
Showing 6 changed files with 202 additions and 1 deletion.
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@cardano-foundation/cardano-connect-with-wallet-core": "^0.2.3",
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@fontsource/roboto": "^5.0.8",
"@mui/icons-material": "^5.14.3",
"@mui/material": "^5.14.4",
"axios": "^1.2.2",
Expand Down
Binary file modified public/models/door.glb
Binary file not shown.
2 changes: 2 additions & 0 deletions src/3d/Scene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { Grid, Link, Typography, useTheme } from '@mui/material';
import LinkIcon from '@mui/icons-material/Link';
import LinkOffIcon from '@mui/icons-material/LinkOff';
import { hasTouchScreen, moveToPickedObject, setupInputs } from './Inputs';
import { InstructionOverlay } from '../components/InstructionOverlay';

const FullView = styled('div')({
height: '100%',
Expand Down Expand Up @@ -315,6 +316,7 @@ const MainScene = ({
antialias
onSceneReady={(scene) => setMainScene(scene)}
/>
<InstructionOverlay />
<Hud
style={{
display: hudDisplayVisible ? 'block' : 'none',
Expand Down
176 changes: 176 additions & 0 deletions src/components/InstructionOverlay.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
import { Backdrop, Grid, Paper, Typography, useTheme } from '@mui/material';
import TouchAppIcon from '@mui/icons-material/TouchApp';
import VisibilityIcon from '@mui/icons-material/Visibility';
import SensorDoorIcon from '@mui/icons-material/SensorDoor';
import ImageIcon from '@mui/icons-material/Image';
import KeyboardIcon from '@mui/icons-material/Keyboard';
import { useState } from 'react';
import { hasTouchScreen } from '../3d/Inputs';
import { useLocalStorage } from '../helper';

const instructions = {
mobile: {
move: 'Move by dragging',
look: 'Look around by dragging with two fingers',
enter: 'Enter a room through a double tap on its door',
focus: 'Focus paintings by tapping on them',
dismiss: 'Tap anywhere to dismiss',
},
desktop: {
move: 'Move by WASD or arrow keys',
look: 'Look around by dragging with the mouse',
enter: 'Enter a room through pressing space',
focus: 'Focus paintings by clicking on them',
dismiss: 'Click anywhere to dismiss',
},
};

export const InstructionOverlay = () => {
const [open, setOpen] = useState(true);
const [seen, setSeen] = useLocalStorage('seen', false);

if (seen) {
return null;
}

const theme = useTheme();

const handleClose = () => {
setSeen(true);
setOpen(false);
};

const guide = hasTouchScreen() ? instructions.mobile : instructions.desktop;

return (
<Backdrop
sx={{
zIndex: theme.zIndex.drawer + 1,
}}
open={open}
onClick={handleClose}
>
<Paper
elevation={0}
sx={{
p: 2,
borderRadius: 0,
maxWidth: 800,
width: '80%',
background: 'white',
}}
>
<Grid container sx={{ flexDirection: 'row' }}>
<Grid item xs={12}>
<Typography
variant="h5"
gutterBottom
sx={{
textAlign: 'center',
}}
>
Welcome to WalkInWallet
</Typography>
<Typography
variant="subtitle1"
gutterBottom
sx={{
textAlign: 'center',
}}
>
Is it your first time here? Let us guide you through the controls.
</Typography>
</Grid>
<Grid
container
item
xs={6}
flexDirection="column"
sx={{ justifyContent: 'center', alignItems: 'center' }}
>
{hasTouchScreen() ? (
<TouchAppIcon sx={{ fontSize: '4rem' }} />
) : (
<KeyboardIcon sx={{ fontSize: '4rem' }} />
)}
<Typography
variant="h6"
gutterBottom
sx={{
textAlign: 'center',
}}
>
{guide.move}
</Typography>
</Grid>
<Grid
container
item
xs={6}
flexDirection="column"
sx={{ justifyContent: 'center', alignItems: 'center' }}
>
<VisibilityIcon sx={{ fontSize: '4rem' }} />
<Typography
variant="h6"
gutterBottom
sx={{
textAlign: 'center',
}}
>
{guide.look}
</Typography>
</Grid>
<Grid
container
item
xs={6}
flexDirection="column"
sx={{ justifyContent: 'center', alignItems: 'center' }}
>
<SensorDoorIcon sx={{ fontSize: '4rem' }} />
<Typography
variant="h6"
gutterBottom
sx={{
textAlign: 'center',
}}
>
{guide.enter}
</Typography>
</Grid>
<Grid
container
item
xs={6}
flexDirection="column"
sx={{ justifyContent: 'center', alignItems: 'center' }}
>
<ImageIcon sx={{ fontSize: '4rem' }} />
<Typography
variant="h6"
gutterBottom
sx={{
textAlign: 'center',
}}
>
{guide.focus}
</Typography>
</Grid>
</Grid>
<Typography variant="subtitle2" sx={{ mt: 2, textAlign: 'center' }}>
{guide.dismiss}
</Typography>
<Typography
variant="subtitle2"
gutterBottom
sx={{
textAlign: 'center',
}}
>
This dialog will show up only once
</Typography>
</Paper>
</Backdrop>
);
};
13 changes: 12 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import { createTheme, ThemeProvider } from '@mui/material';
import '@fontsource/roboto/300.css';
import '@fontsource/roboto/400.css';
import '@fontsource/roboto/500.css';
import '@fontsource/roboto/700.css';

const theme = createTheme({
palette: {
Expand All @@ -11,11 +15,18 @@ const theme = createTheme({
main: '#12284b',
},
secondary: {
light: '#FD7CCD',
main: '#ef2f6d',
},
success: {
main: '#6DFACD',
},
info: {
main: '#00C2D5',
},
},
typography: {
fontFamily: ['LibreBaskerville', 'serif'].join(','),
fontFamily: ['Roboto', 'sans-serif'].join(','),
},
});

Expand Down

0 comments on commit f1a97d6

Please sign in to comment.