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-scenes

v2.1.6

Published

React Scenes is a simple way to create/test your react components inside your app.

Downloads

17

Readme

React Scenes v2 🌉

React Scenes is a simple way to create/test your react components inside your app.

Live demo at https://react-scenes.doub.co

Why?

We tried lots of tools to simplify our in-house react component creation process, most of the tools either has separate build process or not enough feature set. React Scenes is more simple, easy to use, flexible and does not need a separate build process, it is plug and play.

Installation

npm install react-scenes --save


Usage

Scenes

Libraries is just a react component that uses Scenes, you can point any route to any library just like normal pages.

import { Scenes } from "react-scenes";

import * as all from "./scenes";

let scenes = Object.keys(all).map(key => all[key]);

class Library extends Component {
  render() {
    return (
      <Scenes
        title="My Library"
        config={{
          caching: true
        }}
        scenes={scenes}
      />
    );
  }
}

title string

Library Title.

scenes array

Scenes.

config object

caching boolean

This is the default state of caching, can be enable/disable from UI.

actions array

check for more: custom actions

panels array

check for more: custom panels

devices array

check for more: custom devices


Scene

Example scene

import { controllers } from "react-scenes";

export default {
  title: "Hello",
  target: Bar, // or as function ({ props, state, setState }) => {}
  controllers: [
    {
      key: "title",
      title: "My title",
      controller: controllers.text("hello")
    }
  ],
  events: ["onClick"],
  options: {
    centered: true,
    bg: "light" // light, dark, white, black
  },
  docs: `## Bar
  **Hello World**
  `
};

title string required

Title of your component.
You can also make titles nested like Buttons>Normal.

target React Component or function required

Your Component. You can either give your component directly or you can pass a functions.

target: ({props, state, setState, pushEvent}) => {
  return (
    <div>
      <Button {...props}>{props.title}</Button>
    </div>
)}

controllers array

All the controllers your component need. They will be passed to your component as their props.

events array

Events you want to track.

options object

Two options are available. theme and centered (makes component centered in viewport with flexbox).

docs string

Component documentation or notes.


Built-in Features

Panels

We provide 4 panels; You can also add custom panels check for more: custom panels Every panel can has its own specific actions check for more: custom panel actions

Scenes 🗂

All scenes you have will appear in here.

Controllers 🎚

Conrollers are your main tools to alter your component without direct input.

We provide 10 default controllers; text,textarea,select,boolean,integer,float,range,object,array,color

text

controllers.text("Hello World")

textarea

controllers.textarea("Hello \n World")

select

controllers.select("primary", ["primary", "destructive"])

or you can add as key,value

controllers.select("primary", [
  {key:"Primary, value:"primary"},
  {key:"Positive, value:"positive"}
])
boolean

controllers.boolean(true, true) > if you set second argument it will include null to controller cycle.

integer

controllers.integer(42)

float

controllers.float(42.1)

range

controllers.range(42.1)

object

controllers.object({foo:"bar"})

array

controllers.array([1,2,3])

color

controllers.color("#000","hex" // hex, rgb, rgba)

Events 🚀

Track your components events, just add event props to your scenes as an array.

Code 📤

This converts your components code to string for easy sharing.

Docs 📓

Docs are can be component documentation or any other notes. (markdown supported).


Customize

Custom Panels

We exposed all props internally so you can access to alter anything you like.

<Scenes
  ...
  panels={[
    {
        _id: "my-apples",
        component: MyApples,
        active: ({ get }) => get("active").panel == "my-panel",
        icon: "🍎",
        actions: [
          {
            _id: "toggle-apple-color",
            icon: ({ get })=> get("config").options.apple == "green" ? "🍏" : "🍎",
            active: ({ get }) => get("config").options.apple == "green",
            onClick: ({ set }) => {
              set("config",{
                options:{
                  ...get("config").options,
                  centered: props.options.apple == "green" ? "red" : "green"
                }
              });
            }
          }
        ]
    }
  ]}
/>

Custom Controllers

Example: myApp/.../myCustomController.js

import React, { Component } from "react";

export default (initialValue, foo, bar) => {
  return {
    type: "customController",
    initialValue,
    process: val => val,
    input: (value, set, title, state, setState) => {
      return (
        <div className="custom-controller">
          <input
            value={value}
            onChange={e => set(e.target.value)}
            onFocus={e => setState({ focused: true })}
            onBlur={e => setState({ focused: false })}
          />
          {focused ? "Focused" : "Not Focused"}
        </div>
      );
    }
  };
};

There is 4 props you can use;

  • type string is just and identifier.

  • initialValue anything is the initial value of the input.

  • process function can be use to alter the input value.

  • input function has value, set, title, state, setState to update your data and state of your controller.

Usage

Example: someScene.js

import customController from "../myCustomController";

export default {
  title: "Hello",
  target: Bar,
  controllers: [
    {
      key: "data",
      title: "My Data",
      controller: customController("hello", "foo", "bar")
    }
  ]
};

Custom Devices

to add custom device sizes, inject it to Scenes like below.

<Scenes
  ...
  devices={{
    iphonex: {
      title: "iPhone X",
      width: 375,
      height: 812
    },
    iphoneflex: {
      title: "iPhone Flex",
      width: "375px",
      height: "100%",
      unit: ""
    }
  }}
/>

Contribute

Pull requests are welcome and please submit bugs 🐛.

Contact

Inspirations