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-shortcut-picker

v1.3.1

Published

`ShortcutPicker` is a React component for picking shortcuts. It's easy to use and to embed into your website.

Downloads

4

Readme

ShortcutPicker

ShortcutPicker is a React component for picking shortcuts. It's easy to use and to embed into your website.

  • You dynamically picking the shortcut, thereby the users cannot set one that they would not be able to use due to the default settings of the browser.
  • You can onfocus the field with Enter and Escape. Enter saves the modified keybinding, Escape cancels it and restores the previous one.
  • You can delete the current shortcut with Delete, which set it to the empty default version.

You can try it out on our website.

🚀 How to embed into your website

You are required to give the component the following parameters:

  • shortcutCmd: (string[] | undefined) The current keybinding for this shortcut. The keybinding should be add as a string array. If there is no keybinding yet, undefined type should be given.

  • id: (string) The unique identifier of the command.

  • handleShortcutCmd: (id: string, shortcutCmd: string[] | undefined) => void A function which will be called with the given id and with the shortcutCmd chosen by the user. If the user deletes the command, the shortcutCmd will be undefined.

These following parameters are optional:

  • maxCommandNumber: (number) The maximum allowed number of command parts. Default: 4. Example: "Shift+2+3" will be counted as 3.

  • emptyCommand: (string) This text will be displayed when no command is given or the user deletes it. Default: "Click to add shortcut.".

🎁 Example

The following code shows how easy-to-use the ShortcutPicker is:

import ShortcutPicker from "react-shortcut-picker";

<StyledCommandNameContainer>
      {keyCommandToName[command]}
</StyledCommandNameContainer>
<ShortcutPicker
      shortcutCmd={convertLocStorage(command)}
      id={command}
      handleShortcutCmd={handleShortcutCmd}
/>

TODO:

  • [x] with npm run lint:fix you can run eslint, that checks your code for a lot of coding errors. You can find an explanation behind them at https://airbnb.io/javascript/ which is the plugin we're using.
  • [x] There were a lot of errors in the code, but I've disabled them with comments ( like // eslint-disable-next-line no-plusplus ) remove the disabling, fix the code, if you're interested in the rule then look it up, you might learn something.
  • [ ] Try out storybook, make a small example
  • [x] Finish up the README, write usage explanation
  • [ ] Write a blog post on our blog, include the shortcut-picker in the blog post to display an interactive demo
  • [ ] Clean up the code, but we can do that together
  • [x] don't use global variables, use setState
  • [.] Check out how cypress works

Local development

To use this package in another project:

  • npm link in react-shortcut-picker <-- here
  • npm link react-shortcut-picker in the project you want to use it <-- spideryarn

Or

  • npm install path/to/project in the project you want to use it

If you get hook error with react: from https://stackoverflow.com/questions/65259040/react-antd-rollup-component-library-error-invalid-hook-call-hooks-can-onl

  • first: [npm link] a spideryarn/web/node_modules/react -ban
  • second: [npm link react] a react-shortcut-picker -ben