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

material-ui-responsive-drawer

v1.19.4

Published

React-Redux Component that uses Material-UI

Downloads

108

Readme

Material-UI responsive Drawer

Build Status Dependency Status License Code Coverage Code Style

Table of Contents

Description

Material-UI responsive Drawer is a React-Redux component that uses Material-UI to create a responsive Drawer.

You can try it out the DEMO.

Installation

This project can be installed as npm module using following command:

npm i -S material-ui-responsive-drawer

Usage

Preparation

Material-UI

For this project components to work in your application after the npm installation you have to be sure that everything is correctly setup for Material-UI to work. You can find more about that here.

Redux responsive

We also need to add the responsiveStoreEnhancer from redux-responsive into our store:


import {responsiveStoreEnhancer} from 'redux-responsive';
const store = createStore(reducers, responsiveStoreEnhancer);

You can find more about the redux-responsive project here.

Reducers

No matter where you store your reducers the ResponsiveDrawer needs access to a specific reducer and its state. For that we add to our reducers index.js file where we combine all our reducers the following two reducers:


import {responsiveStateReducer} from 'redux-responsive';
import {combineReducers} from 'redux';
import {responsiveDrawer} from 'material-ui-responsive-drawer';

const reducers = combineReducers({
  browser: responsiveStateReducer,
  responsiveDrawer: responsiveDrawer
})

export default reducers;

That are the point we have to do before using this module in our application.

Examples

The module contains of three main parts:

  • ResponsiveDrawer the responsive Drawer
  • BodyContainer the responsive body that is adjusting its position according to the drawer
  • ResponsiveAppBar the responsive AppBar that works with the ResponsiveDrawer together

All can be imported like this:


import {
  ResponsiveDrawer,
  BodyContainer,
  ResponsiveAppBar
} from 'material-ui-responsive-drawer'

All of them are just containers in witch you can put all your other application components:


<div>
    <ResponsiveDrawer>
      <div>
        //all your components you want to have in the drawer part
      </div>
    </ResponsiveDrawer>
    <BodyContainer>
      <ResponsiveAppBar
          title={'Responsive Material-UI Drawer DEMO'}
          iconElementRight={<FlatButton label="Demo" />}
        />
      <div>
        //all your components you want to have in the body part
      </div>
    </BodyContainer>
</div>

The ResponsiveDrawer has the same properties as the Material-UI Drawer. The ResponsiveAppBar has the same properties as the Material-UI AppBar.

There are some properties that should always be the same in this three components:

  • width - if the width of the drawer is set to a specific value the width of the BodyContainer should be set to the same to avoid overlapping. Default is 256.
  • openSecondary - defines on witch side the Drawer will open so the BodyContainer should also have the same value for this property. Default is false.
  • breakPoint - defines on witch size of the window the Drawer will be closed (small windows) or open and docked (large windows). Default is 'medium'. You can add custom break points to the redux-responsive implementation and change the breakPoint for the ResponsiveDrawer. More about that you can find here

All this properties are optional.

To use the actions for changing the drawer properties we will need some more code. For example we can change the responsive state of the drawer by calling the action setResponsive that needs a boolean as parameter witch defines if the drawer is responsive or not.

The actions available in this module are: toggleDrawerOpen, toggleDrawerDock, setDrawerOpen(open), setResponsive(responsive).

We can import them from the module like this:


import {
  ResponsiveDrawer,
  BodyContainer,
  ResponsiveAppBar,
  toggleDrawerOpen,
  toggleDrawerDock,
  setResponsive
} from 'material-ui-responsive-drawer'

An complete example with all the actions called can be found in the App.js of the demo part of this project.

Contributing

Every help no matter if it is a critique, suggestion or pull request is welcome :)