All Projects → socialtables → react-infinity-menu

socialtables / react-infinity-menu

Licence: Apache-2.0 License
A react component that displays an unlimited deep menu

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects
HTML
75241 projects

Projects that are alternatives of or similar to react-infinity-menu

tmwa
DEPRECATED: The server running The Mana World Legacy. All new projects should use Hercules instead. See the "evol-hercules" repo.
Stars: ✭ 44 (-25.42%)
Mutual labels:  legacy, deprecated
steam
DEPRECATED Build, manage and deploy H2O's high-speed machine learning models.
Stars: ✭ 59 (+0%)
Mutual labels:  deprecated
rocketpwa
[DEPRECATED] Command-line toolbelt for PWA developers
Stars: ✭ 37 (-37.29%)
Mutual labels:  deprecated
AASecondaryScreen
[Deprecated] · Approachable implementation of iOS AirPlay-Mirroring using Swift.
Stars: ✭ 40 (-32.2%)
Mutual labels:  deprecated
nord
An unofficial NordVPN client [DEPRECATED]
Stars: ✭ 25 (-57.63%)
Mutual labels:  deprecated
aim
Artificial Intelligence Modules, components to run in the Internet of Things framework, Dodedodo.com, http://dodedodo.com. These modules will run on your smartphone, on a raspberry pi, on a server, in a docker, and all native, in C++! The modules communicate through firewalls using XMPP. And on single machine they can use ZeroMQ, YARP, or Androi…
Stars: ✭ 13 (-77.97%)
Mutual labels:  legacy
ton-client-rs
TON Labs SDK Client Library for Rust
Stars: ✭ 15 (-74.58%)
Mutual labels:  deprecated
react-native-value-picker
Cross-Platform iOS(ish) style picker for react native.
Stars: ✭ 18 (-69.49%)
Mutual labels:  react-component
react-text-more-less
📃React component to show more text or show less
Stars: ✭ 16 (-72.88%)
Mutual labels:  react-component
react-duotone
React Duotone Component
Stars: ✭ 26 (-55.93%)
Mutual labels:  react-component
node-bandwidth
NodeJS Client library for Bandwidth Voice and Messaging APIs
Stars: ✭ 38 (-35.59%)
Mutual labels:  deprecated
geoservices-js
Deprecated - please consider using @esri/arcgis-rest-js
Stars: ✭ 53 (-10.17%)
Mutual labels:  deprecated
angular-karma test-explorer
vscode extension for easy angular testing and debugging
Stars: ✭ 67 (+13.56%)
Mutual labels:  deprecated
org-beamer-cn
[Deprecated] org-mode Simple Chinese Template for Beamer
Stars: ✭ 23 (-61.02%)
Mutual labels:  deprecated
jog arm
A real-time robot arm jogger.
Stars: ✭ 39 (-33.9%)
Mutual labels:  deprecated
react-video-players
📺 Library of React video player components that offer a consistent interface and callback system for Vimeo, YouTube and the <video> tag. Along with a handy higher order component for building your own 😉
Stars: ✭ 13 (-77.97%)
Mutual labels:  react-component
shake
緊急地震速報プログラム – Desktop Earthquake Warnings
Stars: ✭ 31 (-47.46%)
Mutual labels:  deprecated
react-middle-ellipsis
Truncate a long string in the middle, instead of the end.
Stars: ✭ 44 (-25.42%)
Mutual labels:  react-component
apiblueprintorg
old apiblueprint.org site
Stars: ✭ 19 (-67.8%)
Mutual labels:  deprecated
react-daterange-picker
A react date range picker to using @material-ui. Live Demo: https://flippingbitss.github.io/react-daterange-picker/
Stars: ✭ 85 (+44.07%)
Mutual labels:  react-component

react-infinity-menu

Circle CI

Demo

Awesome demo

Installation

npm install react-infinity-menu

How to use

import InfinityMenu from "react-infinity-menu";
import "react-infinity-menu/src/infinity-menu.css";

class Example extends React.Component {
	onNodeMouseClick(event, tree, node, level, keyPath) {
		this.setState({
			tree: tree
		});
	}

	onLeafMouseClick(event, leaf) {
		console.log( leaf.id ); // Prints the leaf id
		console.log( leaf.name ); // Prints the leaf name
	}

	onLeafMouseUp(event, leaf) {
		console.log( leaf.id ); // Prints the leaf id
		console.log( leaf.name ); // Prints the leaf name
	}

	onLeafMouseDown(event, leaf) {
		console.log( leaf.id ); // Prints the leaf id
		console.log( leaf.name ); // Prints the leaf name
	}

	render() {
		return (
			<InfinityMenu
				tree={this.state.tree}
				onNodeMouseClick={this.onNodeMouseClick}
				onLeafMouseClick={this.onLeafMouseClick}/*optional*/
				onLeafMouseDown={this.onLeafMouseDown}/*optional*/
				onLeafMouseUp={this.onLeafMouseUp}/*optional*/
				maxLeaves={5}/*optional*/
			/>
		);
	}
}

Properties

tree(Array)

A tree to represent the folder structure. Here is the example data you could pass into the tree props.

[
	{
		name: "menu1", /*require*/
		id: 1, /*require*/
		isOpen: true, /*require*/
		customComponent: YOUR_OWN_COMPONENT_FOR_MENU,
		children: [
			{
				name: "submenu1",
				id: 1,
				isOpen: true,
				customComponent: YOUR_OWN_COMPONENT_FOR_SUB_MENU,
				children: [
					{
						name: "item1-1",
						id: 1
					},
					{
						name: "item1-2",
						id: 2
					}
				]
			},
			{
				name: "submenu2",
				id: 2,
				isOpen: true,
				customComponent: YOUR_OWN_COMPONENT_FOR_SUB_MENU,
				children: [
					{
						name: "item2-1",
						id: 1
					}
				]
			}
		]
	},
	{
		name: "menu2", /*require*/
		id: 2, /*require*/
		isOpen: true, /*require*/
		customComponent: YOUR_OWN_COMPONENT_FOR_MENU,
		children: [
			{
				name: "item3-1",
				id: 1
			}
		]
	}
];

disableDefaultHeaderContent (boolean)

A boolean to set if user want to display the default header search input. If user pass in headerContent, the default header will be disabled.

headerContent(React Component)

Subcomponent rendered above the tree.

headerContent is passed in to InfinityMenu. It is rendered above the tree subcomponent.

headerProps(object)

Additional props for headerContent.

  • headerProps is an optional prop of InfinityMenu. The props in this object are passed as props to a headerContent component. This is useful when extending InfinityMenu.

Passing the following into InfinityMenu as the headerProps prop sets the title prop on the headerContent component.

{
	title: "my great title"
}

customComponentMappings (object)

A mapping that let user to pass in customComponent as string.

var myComponentMappings = {
    "MyComponent1": MyComponent1,
    "MyComponent2": MyComponent2
}

customComponent(React Component)

A custom React component the user can pass in.

  • As the customComponent at the node level, you will receive props key, onClick, name, isOpen, data and isSearching.

  • As the customComponent at the leaf level, you will receive props key, onMouseDown, onMouseUp, onClick, name, icon and data.

    Example of customComponent

    class Node extends React.Component {
        render() {
            return (
                <div key={this.props.key} onClick={this.props.onClick}>
                    <label>{this.props.name}</label>
                </div>
            );
        }
    }

filter(function)[node, searchInput]

By default, when the menu is in searching mode, it will filter all nodes by whether their name is equal to the current searchInput. If the node name is equal to the searchInput, then the node will pass the filter and be displayed in tree (if it fails the filter, it will not be displayed in the tree).

This allows the user to specify their own filtering criteria. When the menu is in search mode, every node will be run against the filter() function:

  • If the function returns true, the node will pass the filter, and be displayed in the tree.
  • If the function returns false, the node will fail the filter, and will not be displayed in the tree.

The function takes the following arguments:

  • node (object) is the folder(node) the user clicked on. Includes the following properties: id, name, isOpen and children.
  • searchInput (string) The current search term

emptyTreeComponent (React Component)

If the tree prop is an empty array or if the menu is in searching mode and no nodes match the filter, then the tree is considered "empty".

By default, nothing will be displayed in an empty tree.

However, if this prop is passed in, the specified component will be rendered when the tree is empty.

This allows you have a very customized "empty tree" message/image.

emptyTreeComponentProps (object)

Allows you to specify props to pass to the emptyTreeComponent.

By default, this is an empty object.

onNodeMouseClick(function)[event, tree, node, level, keyPath]

This function will get call when user click on the folder(node). The function arguments include event, tree, node and level.

  • event is the mouse click event.
  • tree is the updated tree, you should update your own tree accordingly.
  • node is the folder(node) the user clicked on. Including the id, name, isOpen and children.
  • level is the distance from the root.
  • keyPath is the path from root to current node

onLeafMouseClick(function)[event, leaf]

Bind to the onClick on the leaf. This function will get call when user click on the item(leaf). The function arguments include event, leaf.

  • event is the click event.
  • leaf is the item user clicked on. Includes name, id, keyPath and all data the user inputs when they pass in the tree.

onLeafMouseDown(function)[event, leaf]

Bind to the onMouseDown on the leaf. This function will get call when user mouse down on the item(leaf). The function arguments include event, leaf.

  • event is the click event.
  • leaf is the item user clicked on. Includes name, id, keyPath and all data the user inputs when they pass in the tree.

onLeafMouseUp(function)[event, leaf]

Bind to the onMouseUp on the leaf. This function will get call when user mouse up on the item(leaf). The function arguments include event, leaf.

  • event is the click event.
  • leaf is the item user clicked on. Includes name, id, keyPath and all data the user inputs when they pass in the tree.

maxLeaves(integer)

Sets the maximum number of leaf to show initially. Also used as an increment when then load more is pressed.

shouldComponentUpdate(function) [currProps, currState, nextProps, nextState]

A function that will be called inside shouldComponentUpdate. It's a good place to optimize update.

Styles

There is a default style sheet you can use if you so desire. /src/infinity-menu.css

License

Copyright (C) 2017 Social Tables, Inc. (https://www.socialtables.com) All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].