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

react-multilevel-menu

v1.3.0

Published

Multi-Level Menu for React Projects.

Downloads

243

Readme

react-multilevel-menu

Multi-Level Menu for React Projects.

Why react-multilevel-menu?

The main goal of this package is to deliver a slim and Skinny Multi-Level Menu for React Projects. That can fit into any kind of projects with no muss, no fuss. Within few lines, you will get an animation ready multilevel list that just works.

Demo

Check the Multi-Level Menu in action, click here.

Features

  1. FontAwesome Icons are supported.
  2. Use images as icons in the list.

Installation

You can use either the npm or yarn command-line tool to install packages. Use whichever is appropriate for your project in the examples below.

NPM

npm install --save react-multilevel-menu

YARN

yarn add --save react-multilevel-menu

Usage

Follow below steps to add multi level list in your project

1. Import MultilevelMenu from react-multilevel-menu

import { MultilevelMenu } from 'react-multilevel-menu';

import {list, configurations} from './constants'; // Your Menu Array and configuration Object


const App = () => {
  const selectedItem = (event) => {
    console.log(event);
  }

  return (
    <div className="app__page-container">
        <MultilevelMenu 
        list={list} 
        configuration={configurations} 
        selectedListItem={selectedItem} 
        selectedLabel={selectedItem}
      />
    </div>
  );
};

export default App

2. Structure of array to display the list

Make sure you structure of array should look like array shown below,

const list: MultilevelNodes[] = [
    {
        label: 'NPM',
        faIcon: 'fab fa-500px',
        link: 'https://www.npmjs.com/package/ng-material-multilevel-menu',
        hrefTargetType: '_blank' // _blank|_self|_parent|_top|framename
    },
    {
        label: 'Item 1 (with Font awesome icon)',
        imageIcon: '/batman.jpg',
        activeImageIcon: '/ironman.jpg',
        items: [
            {
                label: 'Item 1.1',
                faIcon: 'fab fa-accusoft',
                onSelected: function() {
                    console.log('Item 1.2.2.1');
                }
            },
            {
                label: 'Item 1.2',
                faIcon: 'fab fa-accessible-icon',
                items: [
                    {
                        label: 'Item 1.2.1',
                        faIcon: 'fas fa-allergies',
                        onSelected: function() {
                            console.log('Item 1.2.2.1');
                        }
                    },
                    {
                        label: 'Item 1.2.2',
                        faIcon: 'fas fa-ambulance',
                        items: [
                            {
                                label: 'Item 1.2.2.1',
                                faIcon: 'fas fa-anchor',
                                onSelected: function() {
                                    console.log('Item 1.2.2.1');
                                }
                            }
                        ]
                    }
                ]
            }
        ]
    },
    {
        label: 'Item 2',
        faIcon: 'fas fa-anchor', 
        items: [
            {
                label: 'Item 2.1',
                faIcon: 'fab fa-accusoft',
                activeFaIcon: 'fab fa-accusoft',
                disabled: true,
            },
            {
                label: 'Item 2.2',
                faIcon: 'fas fa-anchor', 
                activeFaIcon: 'fab fa-accusoft',
            }
        ]
    },
    {
        label: 'Item 3',
        faIcon: 'fab fa-accusoft',
        activeFaIcon: 'fas fa-anchor', 
        onSelected: function() {
            console.log('Item 3');
        }
    },
    {
        label: 'Item 4',
        link: '/item-4',
        faIcon: 'fab fa-accusoft',
        hidden: true
    }
];

Menu Configuration

  • Using configuration, You can customise the appearance of the list.
    • paddingAtStart: boolean => [optional] If you don't want padding at the start of the list item, then you can give false. The default value will be true.
    • highlightOnSelect: boolean => [optional] If you want to highlight the clicked item in the list, then you can do that by making it true. The default value will be false.
    • useDividers: boolean => [optional] If you want to the list to have dividers. The default value will be true.
    • classname: string; => [optional] You can give your own custom class name in order to modify the list appearance.
    • listBackgroundColor: string; => [optional] You can apply custom color to the background of the list.
    • fontColor: string; => [optional] Changes the color of Text and icons inside the list.
    • backgroundColor: string; => [optional] This will change the background color list container.
    • selectedListFontColor: string; => [optional] This will change the font color of selected list item.

Below is example how you can apply different background and Font colors,

config = {
    paddingAtStart: true,
    classname: 'my-custom-class',
    listBackgroundColor: `rgb(208, 241, 239)`,
    fontColor: `rgb(8, 54, 71)`,
    backgroundColor: `rgb(208, 241, 239)`,
    selectedListFontColor: `red`,
    highlightOnSelect: true,
    useDividers: false,
};

Default classes

  • selected-amml-item: This class will be applied to currently selected link and it's father links.
  • active-amml-item: This class will be applied to currently selected link.

Contribution

I welcome you to fork and add more features into it. If you have any bugs or feature request, please create an issue at github repository.

Thanks

This Project is build using tsdx.

License

MIT