Skip to content

Commit 801d791

Browse files
maglandbendichter
andauthored
mobile friendly layout (#50)
Co-authored-by: Ben Dichter <ben.dichter@gmail.com>
1 parent 4f02fac commit 801d791

4 files changed

Lines changed: 110 additions & 49 deletions

File tree

src/App.tsx

Lines changed: 74 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useEffect, useCallback, useState, useRef } from 'react';
22
import { ThemeProvider, createTheme, CssBaseline } from '@mui/material';
3-
import { Box, AppBar, Toolbar, Typography, IconButton, Alert, Snackbar } from '@mui/material';
3+
import { Box, AppBar, Toolbar, Typography, IconButton, Alert, Snackbar, Tooltip } from '@mui/material';
44
import InfoIcon from '@mui/icons-material/Info';
55
import GitHubIcon from '@mui/icons-material/GitHub';
66
import { MetadataProvider, useMetadataContext } from './context/MetadataContext';
@@ -229,34 +229,49 @@ function AppContent() {
229229

230230
if (showWelcome) {
231231
return (
232-
<Box sx={{ display: 'flex', flexDirection: 'column', height: '100vh' }}>
232+
<Box sx={{ display: 'flex', flexDirection: 'column', height: '100vh', width: '100%', overflow: 'hidden' }}>
233233
{/* Minimal App Bar for welcome page */}
234234
<AppBar position="static" elevation={1}>
235-
<Toolbar variant="dense">
236-
<Box component="img" src={logoIcon} alt="Logo" sx={{ height: 24, mr: 1 }} />
237-
<Typography variant="h6" component="div" sx={{ flexGrow: 1 }}>
235+
<Toolbar variant="dense" sx={{ minHeight: { xs: 48, sm: 48 }, px: { xs: 1, sm: 2 } }}>
236+
<Box component="img" src={logoIcon} alt="Logo" sx={{ height: 24, mr: { xs: 0.5, sm: 1 } }} />
237+
<Typography
238+
variant="h6"
239+
component="div"
240+
sx={{
241+
flexGrow: 1,
242+
fontSize: { xs: '0.9rem', sm: '1.25rem' },
243+
whiteSpace: 'nowrap',
244+
overflow: 'hidden',
245+
textOverflow: 'ellipsis',
246+
mr: { xs: 0.5, sm: 2 },
247+
display: { xs: 'none', sm: 'block' }
248+
}}
249+
>
238250
Dandiset Metadata Assistant
239251
</Typography>
252+
<Box sx={{ flexGrow: { xs: 1, sm: 0 } }} />
240253
<IconButton
241254
color="inherit"
242255
onClick={() => setAboutDialogOpen(true)}
243256
size="small"
244-
sx={{ mr: 1 }}
257+
sx={{ mr: { xs: 0.5, sm: 1 }, flexShrink: 0 }}
245258
>
246259
<InfoIcon />
247260
</IconButton>
248-
<IconButton
249-
color="inherit"
250-
component="a"
251-
href="https://github.com/magland/dandiset-metadata-assistant"
252-
target="_blank"
253-
rel="noopener noreferrer"
254-
size="small"
255-
sx={{ mr: 1 }}
256-
>
257-
<GitHubIcon />
258-
</IconButton>
259-
<ApiKeyManager />
261+
<Box sx={{ flexShrink: 0 }}>
262+
<IconButton
263+
color="inherit"
264+
component="a"
265+
href="https://github.com/magland/dandiset-metadata-assistant"
266+
target="_blank"
267+
rel="noopener noreferrer"
268+
size="small"
269+
sx={{ mr: 1 }}
270+
>
271+
<GitHubIcon />
272+
</IconButton>
273+
<ApiKeyManager />
274+
</Box>
260275
</Toolbar>
261276
</AppBar>
262277

@@ -275,17 +290,38 @@ function AppContent() {
275290
}
276291

277292
return (
278-
<Box sx={{ display: 'flex', flexDirection: 'column', height: '100vh' }}>
293+
<Box sx={{ display: 'flex', flexDirection: 'column', height: '100vh', width: '100%', overflow: 'hidden' }}>
279294
{/* App Bar with loaded dandiset */}
280295
<AppBar position="static" elevation={1}>
281-
<Toolbar variant="dense">
282-
<Box component="img" src={logoIcon} alt="Logo" sx={{ height: 24, mr: 1 }} />
296+
<Toolbar variant="dense" sx={{ minHeight: { xs: 48, sm: 48 }, px: { xs: 1, sm: 2 } }}>
297+
<Tooltip title="Go to welcome screen">
298+
<IconButton
299+
color="inherit"
300+
onClick={handleChangeDandiset}
301+
size="small"
302+
sx={{
303+
mr: { xs: 0.5, sm: 1 },
304+
flexShrink: 0,
305+
display: { xs: 'inline-flex', sm: 'none' }
306+
}}
307+
>
308+
<Box component="img" src={logoIcon} alt="Logo" sx={{ height: 20 }} />
309+
</IconButton>
310+
</Tooltip>
311+
<Box component="img" src={logoIcon} alt="Logo" sx={{ height: 24, mr: { xs: 0.5, sm: 1 }, display: { xs: 'none', sm: 'block' } }} />
283312
<Typography
284313
variant="h6"
285314
component="div"
286315
sx={{
287-
mr: 3,
316+
mr: { xs: 1, sm: 3 },
288317
cursor: 'pointer',
318+
fontSize: { xs: '0.9rem', sm: '1.25rem' },
319+
whiteSpace: 'nowrap',
320+
overflow: 'hidden',
321+
textOverflow: 'ellipsis',
322+
flexShrink: 1,
323+
minWidth: 0,
324+
display: { xs: 'none', sm: 'block' },
289325
'&:hover': {
290326
opacity: 0.8,
291327
}
@@ -294,29 +330,31 @@ function AppContent() {
294330
>
295331
Dandiset Metadata Assistant
296332
</Typography>
297-
<Box sx={{ flexGrow: 1 }}>
333+
<Box sx={{ flexGrow: 1, minWidth: 0 }}>
298334
<DandisetIndicator onChangeDandiset={handleChangeDandiset} />
299335
</Box>
300336
<IconButton
301337
color="inherit"
302338
onClick={() => setAboutDialogOpen(true)}
303339
size="small"
304-
sx={{ mr: 1 }}
340+
sx={{ mr: { xs: 0.5, sm: 1 }, flexShrink: 0 }}
305341
>
306342
<InfoIcon />
307343
</IconButton>
308-
<IconButton
309-
color="inherit"
310-
component="a"
311-
href="https://github.com/magland/dandiset-metadata-assistant"
312-
target="_blank"
313-
rel="noopener noreferrer"
314-
size="small"
315-
sx={{ mr: 1 }}
316-
>
317-
<GitHubIcon />
318-
</IconButton>
319-
<ApiKeyManager />
344+
<Box sx={{ flexShrink: 0 }}>
345+
<IconButton
346+
color="inherit"
347+
component="a"
348+
href="https://github.com/magland/dandiset-metadata-assistant"
349+
target="_blank"
350+
rel="noopener noreferrer"
351+
size="small"
352+
sx={{ mr: 1 }}
353+
>
354+
<GitHubIcon />
355+
</IconButton>
356+
<ApiKeyManager />
357+
</Box>
320358
</Toolbar>
321359
</AppBar>
322360

src/components/Controls/DandisetIndicator.tsx

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,35 @@ export function DandisetIndicator({ onChangeDandiset }: DandisetIndicatorProps)
1515
}
1616

1717
return (
18-
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
19-
<FolderOpenIcon sx={{ fontSize: 20, opacity: 0.8 }} />
20-
<Typography variant="body1" sx={{ fontWeight: 500, userSelect: 'none' }}>
21-
Dandiset {dandisetId}
18+
<Box sx={{ display: 'flex', alignItems: 'center', gap: { xs: 0.5, sm: 1 }, minWidth: 0 }}>
19+
<FolderOpenIcon sx={{ fontSize: 20, opacity: 0.8, flexShrink: 0, display: { xs: 'none', sm: 'block' } }} />
20+
<Typography
21+
variant="body1"
22+
sx={{
23+
fontWeight: 500,
24+
userSelect: 'none',
25+
fontSize: { xs: '0.85rem', sm: '1rem' },
26+
whiteSpace: 'nowrap',
27+
overflow: 'hidden',
28+
textOverflow: 'ellipsis',
29+
minWidth: 0
30+
}}
31+
>
32+
{dandisetId}
2233
</Typography>
2334
<Button
2435
size="small"
2536
onClick={onChangeDandiset}
26-
startIcon={<SwapHorizIcon />}
37+
startIcon={<SwapHorizIcon sx={{ display: { xs: 'none', sm: 'inline-block' } }} />}
2738
sx={{
2839
color: 'inherit',
29-
ml: 1,
40+
ml: { xs: 0.5, sm: 1 },
3041
textTransform: 'none',
31-
fontSize: '0.8rem',
42+
fontSize: { xs: '0.7rem', sm: '0.8rem' },
43+
minWidth: 'auto',
44+
px: { xs: 1, sm: 1.5 },
45+
flexShrink: 0,
46+
display: { xs: 'none', sm: 'inline-flex' },
3247
'&:hover': {
3348
backgroundColor: 'rgba(255, 255, 255, 0.1)',
3449
},

src/components/Layout/MainLayout.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export function MainLayout({
6464
ref={containerRef}
6565
sx={{
6666
display: 'flex',
67+
flexDirection: { xs: 'column', md: 'row' },
6768
height: '100%',
6869
width: '100%',
6970
overflow: 'hidden',
@@ -72,8 +73,8 @@ export function MainLayout({
7273
{/* Left Panel */}
7374
<Box
7475
sx={{
75-
width: `${leftWidth}%`,
76-
height: '100%',
76+
width: { xs: '100%', md: `${leftWidth}%` },
77+
height: { xs: '50%', md: '100%' },
7778
overflow: 'auto',
7879
flexShrink: 0,
7980
}}
@@ -85,12 +86,13 @@ export function MainLayout({
8586
<Box
8687
onMouseDown={handleMouseDown}
8788
sx={{
88-
width: '6px',
89-
height: '100%',
89+
width: { xs: '100%', md: '6px' },
90+
height: { xs: '6px', md: '100%' },
9091
backgroundColor: isDragging ? 'primary.main' : 'divider',
91-
cursor: 'col-resize',
92+
cursor: { xs: 'row-resize', md: 'col-resize' },
9293
flexShrink: 0,
9394
transition: isDragging ? 'none' : 'background-color 0.2s',
95+
display: { xs: 'none', md: 'block' },
9496
'&:hover': {
9597
backgroundColor: 'primary.light',
9698
},
@@ -101,7 +103,7 @@ export function MainLayout({
101103
<Box
102104
sx={{
103105
flex: 1,
104-
height: '100%',
106+
height: { xs: '50%', md: '100%' },
105107
overflow: 'auto',
106108
minWidth: 0,
107109
}}

src/index.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,10 @@ html, body, #root {
88
padding: 0;
99
height: 100%;
1010
width: 100%;
11+
max-width: 100vw;
12+
overflow-x: hidden;
13+
}
14+
15+
html {
16+
-webkit-text-size-adjust: 100%;
1117
}

0 commit comments

Comments
 (0)