Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

navpush

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

navpush

>

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

navpush

NPM JavaScript Style
Guide

Install

npm install --save navpush

Example


import React, { Component } from 'react';

import 'navpush/dist/styles/Hamburger.css';
import 'navpush/dist/styles/PushRight.css';
import { PushRight, Hamburger } from 'navpush';

class App extends Component {
  render() {
    // navpush should go at the top of your body
    return (
      <PushRight
        fixbox={ ( isOpen, toggle ) => {
          // For any of the off-canvas animations, you will need to place your
          // fixed elements inside the fixbox render prop.
          return (
            <header>
              <a className="logo" href="/">
                Name of site
              </a>
              {
                // The exported Hamburger component is added for convenience, but you can use whatever
                // component you would like to trigger the open menu as long
                // as it calls the toggle callback.
              }
              <Hamburger onClick={ toggle } />
            </header>
          );
        } }
        nav={ ( isOpen, toggle ) => {
          // Place all your nav content here. You can also include a close
          // button and pass it the toggle callback to close the menu.
          return (
            <div>
              <button className="CloseBtn" onClick={ toggle } />
              <ul>
                <li>
                  <a href="/Features">Features</a>
                </li>
                <li>
                  <a href="/About">About</a>
                </li>
                <li>
                  <a href="/Contact">Contact</a>
                </li>
              </ul>
            </div>
          );
        } }
      >
        {( isOpen, toggle ) => {
          // Place your page's content (elements that are not fixed) as children.
          return <section className="hero">Hello World!</section>;
        }}
      </PushRight>
    );
  }
}

export default App;

Styling

CSS Modules are supported by importing the navpush/styles/*.module.scss files of your choice and passing them to the relevant component(s) as props. Here is an example of using the Hamburger and OverlayLeft themes

import React, { Component } from 'react';

import HamburgerTheme from 'navpush/dist/styles/Hamburger.module.scss';
import Theme from 'navpush/dist/styles/PushRight.module.scss';
import { OverlayLeft, Hamburger } from 'navpush';

class App extends Component {
  render() {
    return (
      <OverlayLeft
        theme={ Theme }
        nav={ ( isOpen, toggle ) => <div>Sidebar content</div> }
      >
        {( isOpen, toggle ) => (
          <div>
            <header>
              <Hamburger theme={ HamburgerTheme } onClick={ toggle } />
            </header>
            <section className="hero">Hello World!</section>;
          </div>
        )}
      </OverlayLeft>
    );
  }
}

export default App;

License

MIT

FAQs

Package last updated on 17 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc