Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filter UX for tablet/desktop #216

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions apps/playnite-web/src/components/FilterDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const DrawerHeader = styled('div', {
})<{ open: boolean }>(({ open, theme }) => ({
position: 'absolute',
right: `24px`,
top: '13px',
display: 'flex',
alignItems: 'center',
justifyContent: 'flex-end',
Expand All @@ -100,6 +101,9 @@ const DrawerHeader = styled('div', {
...(!open && {
display: 'none',
}),
[theme.breakpoints.down('lg')]: {
top: '0',
},
}))

const DrawerBody = styled('div', {
Expand All @@ -111,8 +115,7 @@ const DrawerBody = styled('div', {
position: 'relative',
flexDirection: 'column',
overflowY: 'hidden',
paddingTop: `56px`,
padding: `${theme.spacing(2.5)}`,
padding: `56px ${theme.spacing(2.5)} ${theme.spacing(2.5)}`,
backgroundColor: theme.palette.background.paper,

'> *': {
Expand Down Expand Up @@ -168,7 +171,6 @@ const FilterDrawer: FC<{
anchor="right"
open={open}
onClose={handleClose}
// ModalProps={{ keepMounted: true }}
>
<DrawerHeader open={open}>
<IconButton
Expand Down
25 changes: 21 additions & 4 deletions apps/playnite-web/src/components/Filters/FilterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,30 @@ const FilterForm: FC<{
sx={(theme) => ({
display: 'flex',
flexDirection: 'row',
justifyContent: 'space-between',
width: '100%',
[theme.breakpoints.up('lg')]: {
justifyContent: 'center',
'> button': {
margin: `0 ${theme.spacing(2)}`,
},
},
[theme.breakpoints.down('lg')]: {
justifyContent: 'space-between',
'> button': {
flex: 1,
},
},
})}
>
<Button type="submit">Filter</Button>
<Button type="reset">Clear</Button>
<Button onClick={handleCancel}>Cancel</Button>
<Button type="submit" size="large">
Filter
</Button>
<Button type="reset" size="large">
Clear
</Button>
<Button onClick={handleCancel} size="large">
Cancel
</Button>
</Box>
</Form>
)
Expand Down
30 changes: 25 additions & 5 deletions apps/playnite-web/src/components/Navigation/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,24 @@ import { Box, useMediaQuery, useTheme } from '@mui/material'
import { FC, PropsWithChildren, ReactNode } from 'react'
import MobileDrawerNavigation from './MobileDrawerNavigation'

const Drawer: FC<PropsWithChildren<{ title?: ReactNode }>> = ({
children,
title,
}) => {
const Drawer: FC<
PropsWithChildren<{
title?: ReactNode | undefined
secondaryMenu?: ReactNode | undefined
}>
> = ({ children, secondaryMenu, title }) => {
const theme = useTheme()
const shouldUseMobileDrawer = useMediaQuery(theme.breakpoints.down('lg'))

return shouldUseMobileDrawer ? (
<MobileDrawerNavigation title={title}>
<MobileDrawerNavigation
title={
<Box sx={{ display: 'flex', alignItems: 'center', width: '100%' }}>
{title}
<Box sx={{ alignSelf: 'flex-end' }}>{secondaryMenu}</Box>
</Box>
}
>
<Box
component={'main'}
sx={(theme) => ({
Expand Down Expand Up @@ -65,6 +74,17 @@ const Drawer: FC<PropsWithChildren<{ title?: ReactNode }>> = ({
},
})}
>
<Box
sx={{
display: 'flex',
position: 'absolute',
top: '24px',
right: '24px',
zIndex: 1500,
}}
>
{secondaryMenu}
</Box>
{children}
</Box>
)
Expand Down
26 changes: 11 additions & 15 deletions apps/playnite-web/src/routes/browse.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FilterAlt } from '@mui/icons-material'
import { Box, Button, styled } from '@mui/material'
import { Button, styled } from '@mui/material'
import type { LoaderFunctionArgs } from '@remix-run/node'
import { json } from '@remix-run/node'
import { useLoaderData } from '@remix-run/react'
Expand Down Expand Up @@ -72,20 +72,16 @@ function Browse() {
return (
<Drawer
title={
<Box sx={{ display: 'flex', alignItems: 'center', width: '100%' }}>
<Title>
<Button variant="text" onClick={handleScrollTop}>
My Games
</Button>
</Title>
<IconButton
onClick={() => setOpen(true)}
name="open-filter-drawer"
sx={{ alignSelf: 'flex-end' }}
>
<FilterAlt />
</IconButton>
</Box>
<Title>
<Button variant="text" onClick={handleScrollTop}>
My Games
</Button>
</Title>
}
secondaryMenu={
<IconButton onClick={() => setOpen(true)} name="open-filter-drawer">
<FilterAlt />
</IconButton>
}
>
<MyLibrary gamesOnPlatforms={gamesOnPlatforms ?? []} />
Expand Down
Loading