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-split-button

v1.0.1

Published

A carefully crafted split-button for React

Downloads

111

Readme

react-split-button

A carefully crafted split-button for React

See split-button demo

Install

$ npm install react-split-button --save

Description

The split-button is similar to the dropdown button, but also enables a default action on the button, without showing the drop-down menu.

The split button smartly positions the drop-down menu to fit into the document. You can customize how the menu is aligned to the button. With one function, you can respond to a click in the menu at any nesting level.

Worth trying out, see the demo page

Changelog

See Changelog

Usage


var SplitButton = require('react-split-button')

var items = [
	{
		label: 'save as',
		onClick: function(){
			console.log('saved as')
		},
		items: [
			{
				label: 'PDF',
				onClick: function(){
					console.log('save as PDF')
				}
			},
			{
				label: 'Postscript'
			}
		]
	},
	{
		label: 'export',
		onClick: function(){
			console.log('exported')
		}
	},
]

function save(){
	console.log('SAVED!')
}

<SplitButton items={items} onClick={save}>
	Save
</SplitButton>

function onMenuClick(event, itemProps){
	console.log('You clicked ', itemProps.data.label)
}

<SplitButton items={items} onMenuClick={onMenuClick} onClick={save}>
	Save
</SplitButton>

Properties

The split button is implemented as two buttons, one next to the other (named button and arrow from now on). The arrow button is just a react-dropdown-button

Actions

  • onClick: Function - function to be called when the button is clicked (not the arrow!)
  • onToggle: Function(pressed: boolean) - function to be called when the button is toggled
  • onArrowClick: Function - function to be called when the arrow is clicked
  • onMenuClick: Function(event, itemProps) - a function to be called when a menu item is clicked

Menu-related attributes

  • items - an array of menu items to build the menu
  • menu - you can specify a menu instead of the menu items

Other attributes

  • href - href for the button

  • align - applied to the button

  • label - applied to the button

  • disabled - applied to the button and the arrow

  • pressed - applied to the button

  • defaultPressed - applied to the button

  • theme - a theme to apply the button and the arrow. See buttom styling

  • buttonProps - props for the button

  • arrowProps - props for the arrow

  • commonProps - props for both the button and the arrow

  • buttonStyle

  • arrowStyle

  • commonStyle - styles to be applied to both the arrow and the button

Contributing

$ npm install
$ npm run dev # to start webpack-dev-server
$ npm run serve # to start http-server on port 9091

now navigate to localhost:9091

Roadmap

See Roadmap

License

MIT