4.1.0 • Published 5 years ago

@stellar-apps/hamburger-menu v4.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

@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()
  • 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, and isVisible are also provided to the @hamburger function.
  • menuAs {React.Component}
    • default curls/DrawerBox
    • The Consumer half to the as Provider component. It is used for rendering the collapsible menu portion of the hamburger menu. It also any receives any ref provided to the HamburgerMenu component.
  • 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 from curls/DrawerBox by default.


createHamburger(<options>)

  • options {object}
    • color {string}
      • default primary
      • The background-color of the resulting Hamburger lines
    • numLines {number}
      • default 3
      • The number of lines to render for the Hamburger
    • closeButton {func}
      • A function for rendering a close button. The function receives the props show, hide, toggle, and isVisible.
    • ref {func}
      • A ref forwarded to the <Button> which wraps this component
    • ...props
      • Additional props forwarded to the <Button> which wraps this component

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;
  `
}
4.1.0

5 years ago

4.0.0

5 years ago

3.0.10

5 years ago

3.0.9

5 years ago

3.0.8

5 years ago

3.0.7

5 years ago

3.0.6

5 years ago

3.0.5

5 years ago

3.0.4

5 years ago

3.0.3

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.0.0

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago