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-selectable-menu-list

v1.19.5

Published

Selectable List from Material-UI that can be filled with an array of items

Downloads

63

Readme

Material-UI Selectable Menu List

Build Status Dependency Status License Code Coverage Code Style

Table of Contents

Description

Material-UI Selectable Menu List is a React-Redux component that uses Material-UI to create a List from a Array. Ihe array should contain only the props used for the ListItems and they can have one parameter more visible. This will define if the ListItem will be displayed or not. It should make creating dynamic Menues easyer becaus you don't habe to take care of every ListItem seperately.

Nesting is also supported. Adding subheadrs and dividers is also no problem. More about that we will see in the Usage part.

Managin an List with only one poroperty as array list of ListItems allowes us to move the array in a seperate file and this way to make the code much easyer to read.

You can try it out the DEMO.

Installation

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

npm i -S material-ui-selectable-menu-list

Usage

To use it just import the component and set as property a list of menu items:


import {SelectableMenuList} from 'material-ui-selectable-menu-list'

const folders_list=[
  {
    subheader: 'Folders',
  },
  {
    value:'/photos',
    primaryText: 'Photos',
    secondaryText: 'Jan 9, 2014',
    leftAvatar: <Avatar icon={<FileFolder />} />,
    rightIcon: <ActionInfo/>
  },
  {
    value:'/recipes',
    primaryText: 'Recipes',
    secondaryText: 'Jan 17, 2014',
    leftAvatar: <Avatar icon={<FileFolder />} />,
    rightIcon: <ActionInfo/>
  },
  {
    value:'/work',
    primaryText: 'Work',
    secondaryText: 'Jan 28, 2014',
    leftAvatar: <Avatar icon={<FileFolder />} />,
    rightIcon: <ActionInfo/>
  },
  {
    divider: true,
  },
  {
    subheader: 'Files',
  },
  {
    value:'/vacation_itinerary',
    primaryText: 'Vacation itinerary',
    secondaryText: 'Jan 20, 2014',
    primaryTogglesNestedList: false,
    leftAvatar: <Avatar icon={<ActionAssignment />} backgroundColor={blue500} />,
    rightIcon: <ActionInfo/>
  },
  {
    value:'/kitchen_remodel',
    primaryText: 'Kitchen remodel',
    secondaryText: 'Jan 10, 2014',
    leftAvatar: <Avatar icon={<EditorInsertChart />} backgroundColor={yellow600} />,
    rightIcon: <ActionInfo/>
  },
]

...

//then in your component
  <SelectableMenuList
    items={folders_list}
    onIndexChange={this.handleChange}
    index={index}
  />

...

Because it is selectable you will have to send a index (string) parameter witch defines witch ListItem should be selected and onIndexChange callback witch will handle the ListItem Click event. In the demo applicatgion I use it together with the redux-router to go to another application part and the index value comes from the redux-router path. That way i have complete navigation menu :)

Every value in the array elements will be send to the ListItem as prop. You can also send inline and style to change those properties for each ListItem. The Divider and Subheader elements can also recieve this kind of properties.

As you can see from the example to add a divider we just have to add one item more with the value divider: true.

For the Subheader just add the value subheader: "Some text".

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

Contributing

Every help no mather if it is a kritik, suggestion or pull request is welkome :)