@stellar-apps/hamburger-menu
v4.1.0
Published
A component for creating configurable and versatile hamburger menus and hamburgers.
Downloads
55
Readme
@stellar-apps/hamburger-menu
A component for creating configurable and versatile hamburger menus and hamburgers.
Installation
yarn add @stellar-apps/hamburger-menu
Usage
import HamburgerMenu, {createHamburger} from '@stellar-apps/hamburger-menu'
const Hamburger = createHamburger({numLines: 3})
function Header (props) {
return (
<HamburgerMenu hamburger={Hamburger} fromLeft>
{({show, hide, toggle, isVisible}) => (
<Box bg='primary' w='100%' h='100%' ov='auto touch'>
This is the menu
</Box>
)}
</HamburgerMenu>
)
}HamburgerMenu
A render props component for creating hamburger menus
Props
This component also accepts any props that the as component takes
hamburger {func}- default function returned by
createHamburger()
- default function returned by
as {React.Component}- default
curls/Drawer - A context Provider which controls the logic for opening and closing of the collapsible menu portion
of the hamburger menu. Its render props
show,hide,toggle, andisVisibleare also provided to the@hamburgerfunction.
- default
menuAs {React.Component}- default
curls/DrawerBox - The Consumer half to the
asProvider component. It is used for rendering the collapsible menu portion of the hamburger menu. It also any receives any ref provided to theHamburgerMenucomponent.
- default
children {func}- Returns the collapsible menu of portion of the hamburger menu. It is provided as the child
component to
menuAs. It receives the render props fromcurls/DrawerBoxby default.
- Returns the collapsible menu of portion of the hamburger menu. It is provided as the child
component to
createHamburger(<options>)
options {object}color {string}- default
primary - The
background-colorof the resulting Hamburger lines
- default
numLines {number}- default
3 - The number of lines to render for the Hamburger
- default
closeButton {func}- A function for rendering a close button. The function receives the props
show,hide,toggle, andisVisible.
- A function for rendering a close button. The function receives the props
ref {func}- A ref forwarded to the
<Button>which wraps this component
- A ref forwarded to the
...props- Additional props forwarded to the
<Button>which wraps this component
- Additional props forwarded to the
Hamburger line defaultTheme
const defaultTheme = {
color: 'primary',
getLine: n => css`
width: 18px;
height: 2px;
min-height: 2px;
border-radius: 2px;
margin-top: 1px;
margin-bottom: 1px;
position: relative;
contain: strict;
`
}