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-zeroconfig-components

v1.10.2

Published

React components that require zero configuration.

Downloads

23

Readme

React Zero-Config Components

React components that require (almost) zero configuration.

For Stripe payments etc, see https://github.com/tomsoderlund/react-zeroconfig-payments

Installation

yarn add react-zeroconfig-components  # or: npm install react-zeroconfig-components

Accessibility

  • [x] All components use button where applicable
  • [x] Keyboard/tab support

Styling

Styling is optional, CSS files are included but you can also use styled-components or similar.

How to import CSS file, example:

import '../node_modules/react-zeroconfig-components/dist/TokenList.css'

Components

There are three groups of components:

  1. Array-based components: these all have similar props, they all take an array of strings or { name, value } and renders a list or a menu.
  2. Input components: taking input from the user.
  3. Other components: everything else.

See the Storybook stories in /stories to see how the components are used in code, including more advanced use cases.

Array-based components

Array-based components

Component: List

import { List } from 'react-zeroconfig-components'

<List
  values={arrayOfObjects}
  numbered={false}
  customFormat={optionalCustomFormat}
/>

const optionalCustomFormat = (row, index) => {
  /* return formatted value */
}

List

Component: Table

<Table
  values={arrayOfObjects}
  customFormat={optionalCustomFormat}
/>

const optionalCustomFormat = (field, value, rowIndex, columnIndex) => {
  /* return formatted value */
}

Table

Component: RadioButtons

<RadioButtons
  options={arrayOfStringsOrObjects}
  value={currentValue}
  onChange={value => handleChange(value)}
/>

RadioButtons

Component: SelectDropdown

<SelectDropdown
  options={arrayOfStringsOrObjects}
  value={currentValue}
  onChange={value => handleChange(value)}
/>

SelectDropdown

Component: SelectMenu

<SelectMenu
  options={arrayOfStringsOrObjects}
  value={currentValue}
  onChange={value => handleChange(value)}
/>

SelectMenu

Component: TabMenu

<TabMenu
  options={arrayOfStringsOrObjects}
  value={currentValue}
  onChange={value => handleChange(value)}
/>

TabMenu

Advanced example:

<TabMenu
  options={arrayOfStringsOrObjects}
  value={currentValue}
  onChange={handleChange}
  
  elementType='nav'
  customChild={MyCustomComponent}
/>

Component: TokenList

<TokenList
  options={arrayOfStringsOrObjects}
  value={currentValue}
  onSelect={token => handleSelect(token)}
  onRemove={token => handleRemove(token)}
/>

TokenList

Input components

Input components

Component: ToggleSwitch

<ToggleSwitch
  value={currentValue}
  onChange={value => handleChange(value)}
/>

ToggleSwitch

Component: TokenInput

<TokenInput
  options={arrayOfStringsOrObjects}
  value={smallerArrayOfStringsOrObjects}
  onAdd={handleAdd}
  onRemove={handleRemove}
/>

TokenInput

Component: TokenSearchInput

<TokenSearchInput
  value={arrayOfStringsOrObjects}
  onSearch={async (searchText) => { return foundMatch }}
  onAdd={handleAdd}
  onRemove={handleRemove}

  placeholder='Type here to search'
  canAddAny={true}
/>

TokenSearchInput

Component: SearchInput

<SearchInput
  onSearch={async (searchText) => { return foundMatch }}
  onSubmit={handleSubmit}

  placeholder='Type here to search'
  canSubmitAny={true}
/>

SearchInput

Component: EditInPlace

<EditInPlace
  placeholder='Edit headline'
  value={article.headline}
  onChange={headline => updateArticle({ headline })}
  canEdit={!!user}
  style={{ fontSize: '2.5em' }}
>
  <h1>{article.headline}</h1>
</EditInPlace>

EditInPlace

Other components

Other components

Component: ListCard

<ListCard
  name='Sam Lowry'
  details='Main character'
  imageUrl='https://pbs.twimg.com/profile_images/943955598718017536/XVuOSUzc_400x400.jpg'
>
  <button>Edit</button>
  <button>Delete</button>
</ListCard>

ListCard

Component: Card

<Card
  layer={0}
  visible={isVisible}
  onClose={event => setIsVisible(!isVisible)}
>
  (...content...)
</Card>
<Card
  layer={1}
  ...
/>

Card

Events

  • onAdd
  • onChange
  • onClose
  • onRemove
  • onSearch
  • onSelect
  • onSubmit

Developing components

Create new component

yarn new

How to test and preview

Preview components in Storybook:

yarn storybook

...then open http://localhost:6006/ in your browser.

storybook

How to build and publish a new NPM package

yarn publish  # yarn prepare (Babel) will be run automatically

Troubleshooting

React Hook order error:

Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:

  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.

Solution: check if conflicting versions:

yarn list react  # or npm ls react

Todo

  • [ ] Range slider
  • [ ] Range slider 2D