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-quickie-controls

v0.8.0

Published

Quick development controls for React projects. Change values and colors quickly in your development environment or storybooks.

Downloads

10

Readme

React Quickie Controls

React hooks to make quick controls to use for development or in storybooks. A test control can be added to your app or component by just importing this library and adding a single line to your code. You can append more controls to the same instance and experiment with different values for numbers, strings and colors. They can be in multiple places anywhere in the tree. When the hook unmounts that control will be removed from the list and any others will continue to work.

npm install react-quickie-controls

Storybook Demos

NOTE: This is a beta project and is only being used in a couple of places. Since it's only for development it's relatively safe to put it out there for others to try out. Please don't put this in your app though.

How does it work?

For example, if you wanted to quickly be able to change a number to different values between 1 and 100 you could just do the following...

import { useValueSlider } from 'react-quickie-controls';

const MyComponent = () => {
  // this will render a value slider in the upper right of the screen
  // changing the slider value will cause this component to update
  const x = useValueSlider('X Value:', 10, 1, 100, 0.5); // (label, value, min?, max?, step?)

  return <div>The X Value: {x}</div>;
};

Need to add two color selectors as well? No problem.

import { useValueSlider, useColorPicker } from 'react-quickie-controls';

const MyComponent = () => {
  const x = useValueSlider('X Value:', 10, 0, 100, 0.5);
  const color = useColorPicker('Color:', '#333');
  const backgroundColor = useColorPicker('Background Color:', '#555');

  return <div style={{{color, backgroundColor }}>The X Value: {x}</div>;
};

You get the idea.

Currently, this package exports these three React hooks...

import {
  useValueSlider,
  useColorPicker,
  useSelectControl,
} from 'react-quickie-controls';

Fun Fact

Each control is actually a mini React app.

Road Map

If people start using this, there's a lot that could be done. More control types and better styling/customization come to mind.

One more example...

type MyOptionType = {
  value: () => string, // could be whatever, string, number, function, etc
  label: string,
};

export const kitchenSink = () => {
  const text =
    useSelectControl <
    MyOptionType >
    ('Select Control: ',
    [
      { value: () => 'Option 1', label: 'The First Option' },
      { value: () => 'Option 2', label: 'The Second Option' },
      { value: () => 'Option 3', label: 'The Third Option' },
    ]);

  const width = useValueSlider('Width: ', 100, 50, 300, 10);
  const height = useValueSlider('Height: ', 100, 50, 300, 10);

  const backgroundColor = useColorPicker('Background Color: ', '#0000ff');
  const border = useColorPicker('Border Color: ', '#ccc');

  return (
    <div
      style={{
        width,
        height,
        color: '#fff',
        backgroundColor,
        border: `2px solid ${border}`,
      }}
    >
      {text.value()}
    </div>
  );
};