-
Notifications
You must be signed in to change notification settings - Fork 198
/
Copy pathMenuButton.js
64 lines (56 loc) · 1.45 KB
/
MenuButton.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import React from 'react'
import { styled } from '@mui/material/styles'
import { Hidden } from '@mui/material'
import PropTypes from 'prop-types'
import clsx from 'clsx'
import ToolbarButton from '../ToolbarButton'
import MenuIcon from './MenuIcon'
const PREFIX = 'RSFMenuButton'
const classes = {
link: `${PREFIX}-link`,
}
const StyledHidden = styled(Hidden)(() => ({
[`& .${classes.link}`]: {
textDecoration: 'none',
},
}))
export {}
/**
* The button that controls that opens and closes the main app menu.
*/
export default function MenuButton({ MenuIcon, menuIconProps, open, onClick, className, style }) {
return (
<StyledHidden mdUp implementation="css" key="menuButton">
<a
on="tap:AMP.setState({ rsfMenuState: { open: !rsfMenuState.open, list: '@' } }), rsfMenu.toggle"
className={clsx(classes.link, className)}
style={style}
>
<ToolbarButton
aria-label="Menu"
color="inherit"
onClick={onClick}
icon={<MenuIcon open={open} {...menuIconProps} />}
/>
</a>
</StyledHidden>
)
}
MenuButton.propTypes = {
/**
* A react component to use for the menu icon
*/
MenuIcon: PropTypes.elementType,
/**
* Props for the menu icon
*/
menuIconProps: PropTypes.object,
open: PropTypes.bool,
onClick: PropTypes.func,
className: PropTypes.string,
style: PropTypes.object,
}
MenuButton.defaultProps = {
MenuIcon,
menuIconProps: {},
}