npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hrishikeshdk/react-sidenav

v0.1.0

Published

React SideNav

Downloads

2

Readme

react-sidenav build status Coverage Status

NPM

React SideNav

Demo: https://trendmicro-frontend.github.io/react-sidenav

Installation

  1. Install the latest version of react and react-sidenav:
npm install --save react @trendmicro/react-sidenav
  1. At this point you can import @trendmicro/react-sidenav and its styles in your application as follows:
import SideNav, { Toggle, Nav, NavItem, NavIcon, NavText } from '@trendmicro/react-sidenav';

// Be sure to include styles at some point, probably during your bootstraping
import '@trendmicro/react-sidenav/dist/react-sidenav.css';

Usage

These examples make use of font-awesome.

<SideNav
    onSelect={(selected) => {
        // Add your code here
    }}
>
    <SideNav.Toggle />
    <SideNav.Nav defaultSelected="home">
        <NavItem eventKey="home">
            <NavIcon>
                <i className="fa fa-fw fa-home" style={{ fontSize: '1.75em' }} />
            </NavIcon>
            <NavText>
                Home
            </NavText>
        </NavItem>
        <NavItem eventKey="charts">
            <NavIcon>
                <i className="fa fa-fw fa-line-chart" style={{ fontSize: '1.75em' }} />
            </NavIcon>
            <NavText>
                Charts
            </NavText>
            <NavItem eventKey="charts/linechart">
                <NavText>
                    Line Chart
                </NavText>
            </NavItem>
            <NavItem eventKey="charts/barchart">
                <NavText>
                    Bar Chart
                </NavText>
            </NavItem>
        </NavItem>
    </SideNav.Nav>
</SideNav>

React Router v4 with React v16

<Router>
    <Route render={({ location, history }) => (
        <React.Fragment>
            <SideNav
                onSelect={(selected) => {
                    const to = '/' + selected;
                    if (location.pathname !== to) {
                        history.push(to);
                    }
                }}
            >
                <SideNav.Toggle />
                <SideNav.Nav defaultSelected="home">
                    <NavItem eventKey="home">
                        <NavIcon>
                            <i className="fa fa-fw fa-home" style={{ fontSize: '1.75em' }} />
                        </NavIcon>
                        <NavText>
                            Home
                        </NavText>
                    </NavItem>
                    <NavItem eventKey="devices">
                        <NavIcon>
                            <i className="fa fa-fw fa-device" style={{ fontSize: '1.75em' }} />
                        </NavIcon>
                        <NavText>
                            Devices
                        </NavText>
                    </NavItem>
                </SideNav.Nav>
            </SideNav>
            <main>
                <Route path="/" exact component={props => <RootComponent />} />
                <Route path="/home" component={props => <Home />} />
                <Route path="/devices" component={props => <Devices />} />
            </main>
        </React.Fragment>
    )}
    />
</Router>

Close the side navigation menu when clicking outside

You can find a click-outside React component (https://github.com/tj/react-click-outside/blob/master/index.js) and do something below:

<ClickOutside
    onClickOutside={() => {
        this.setState({ expanded: false });
    }}
>
    <SideNav
        expanded={this.state.expanded}
        onToggle={(expanded) => {
            this.setState({ expanded });
        }}
    >
        <SideNav.Toggle />
        <SideNav.Nav defaultSelected="home">
            <NavItem eventKey="home">
                <NavIcon>
                    <i className="fa fa-fw fa-home" style={{ fontSize: '1.75em' }} />
                </NavIcon>
                <NavText>
                    Home
                </NavText>
            </NavItem>
        </SideNav.Nav>
    </SideNav>
</ClickOutside>

API

Properties

SideNav

Name | Type | Default | Description :--- | :--- | :------ | :---------- componentClass | element | 'nav' | A custom element for this component. disabled | boolean | | Whether the navigation toggle is disabled. expanded | boolean | | Whether the side navigation is expanded or collapsed. onToggle | function(boolean) | | Callback fired when toggling the side navigation between expanded and collapsed state. onSelect | function(eventKey, event) | | Callback fired when a navigation item is selected.

Toggle

Name | Type | Default | Description :--- | :--- | :------ | :---------- componentClass | element | 'button' | A custom element for this component. disabled | boolean | false | Whether the navigation toggle is disabled. expanded | boolean | false | Whether the side navigation is expanded or collapsed.

Nav

Name | Type | Default | Description :--- | :--- | :------ | :---------- componentClass | element | 'div' | A custom element for this component. onSelect | function(eventKey, event) | | Callback fired when a navigation item is selected. selected | any | | The selected navigation item. defaultSelected | any | | The initially selected navigation item. expanded | boolean | false | Whether the side navigation is expanded or collapsed.

NavItem

Name | Type | Default | Description :--- | :--- | :------ | :---------- componentClass | element | 'div' | A custom element for this component. active | boolean | false | Highlight the navigation item as active. disabled | boolean | false | Disable the navigation item, making it unselectable. expanded | boolean | false | Whether the navigation item is expanded or collapsed. eventKey | any | (required) | Value passed to the onSelect handler, useful for identifying the selected navigation item. onClick | function(event) | | Callback fired when the navigation item is clicked. onSelect | function(eventKey, event) | | Callback fired when a navigation item is selected. navitemClassName | | | navitemStyle | | | subnavClassName | | | subnavStyle | | |

NavIcon

Name | Type | Default | Description :--- | :--- | :------ | :---------- children | any | |

NavText

Name | Type | Default | Description :--- | :--- | :------ | :---------- children | any | |

License

MIT