Skip to content

Commit

Permalink
Merge pull request #33 from markolofsen/dev
Browse files Browse the repository at this point in the history
fix main menu
  • Loading branch information
markolofsen authored Mar 13, 2023
2 parents 360d13b + 175dd3e commit 0112b6a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 36 deletions.
23 changes: 7 additions & 16 deletions src/@core/hooks/useMedia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,15 @@ export const useMedia = () => {

const matches = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl']

const chunks: MediaItem = {
xs: false,
sm: false,
md: false,
lg: false,
xl: false,
xxl: false,
}

const res: MediaDict = {
up: chunks,
down: chunks,
only: chunks,
const res: MediaDict | any = {
up: {},
down: {},
only: {},
}
for (const i of matches) {
res.up[i] = useMediaQuery((theme: any) => theme.breakpoints.up(i)) as boolean
res.down[i] = useMediaQuery((theme: any) => theme.breakpoints.down(i)) as boolean
res.only[i] = useMediaQuery((theme: any) => theme.breakpoints.only(i)) as boolean
res.up[i] = useMediaQuery((theme: any) => theme.breakpoints.up(i))
res.down[i] = useMediaQuery((theme: any) => theme.breakpoints.down(i))
res.only[i] = useMediaQuery((theme: any) => theme.breakpoints.only(i))
}

return res as MediaDict
Expand Down
2 changes: 1 addition & 1 deletion src/iconify-bundle/icons-bundle-react.js

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

64 changes: 45 additions & 19 deletions src/views/Player/Controls/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ import * as React from 'react';

// mui
import { styled } from '@mui/system';
import { Box, Collapse, Button } from '@mui/material';
import ClickAwayListener from '@mui/base/ClickAwayListener';

// icons
import MenuIcon from '@mui/icons-material/Menu';

// hooks
import { useMedia } from 'src/@core/hooks/useMedia'

Expand Down Expand Up @@ -49,6 +53,12 @@ const RootDiv = styled('ul')(({ theme }: any) => ({

}))

const IconButtonMenu = styled(Button)(({ theme }: any) => ({
backgroundColor: 'rgba(0,0,0,.5)',
backdropFilter: 'blur(4px)',
borderRadius: theme.shape.borderRadius * 1.2,
border: `1px solid ${theme.palette.divider}`,
}))

export default function Controls() {

Expand All @@ -58,32 +68,48 @@ export default function Controls() {
// states
const [show, setShow] = React.useState(true)

React.useEffect(() => {
setShow(media.down.sm ? false : true)
}, [media.down.sm])

return (
<ClickAwayListener

onClickAway={() => {
if (media.down.sm) {
setShow(false)
}
}}>

<RootDiv
onMouseEnter={() => {
setShow(true)
}}
onTouchStart={() => {
setShow(true)
}}
sx={{
opacity: show ? 1 : .5
}}>
<li data-li="menu">
<MainMenu />
</li>
<li data-li="gallery">
<Gallery />
</li>
</RootDiv>
<Box sx={{
padding: '1rem',
pointerEvents: 'none',
'& > *': {
pointerEvents: 'all',
}
}}>
{!show && (
<IconButtonMenu
size='large'
color="inherit"
startIcon={<MenuIcon />}
onClick={() => {
setShow(true)
}}>
Menu
</IconButtonMenu>
)}

<Collapse in={show}>
<RootDiv>
<li data-li="menu">
<MainMenu />
</li>
<li data-li="gallery">
<Gallery />
</li>
</RootDiv>

</Collapse>
</Box>
</ClickAwayListener>
)
}

1 comment on commit 0112b6a

@vercel
Copy link

@vercel vercel bot commented on 0112b6a Mar 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.