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

@genrate/react

v1.0.18

Published

React tools to organize resource and add more plexibility in coding and building react apps

Downloads

37

Readme

GenRate React

npm package Build Status Downloads Issues codecov Commitizen Friendly Semantic Release

GenRate React package aims to organize, expand, add more plexibility on building react web application

Install

npm install @genrate/react

Usage

Design

/**
 * Output
 */
const Output ({  
  // overriden test data
  user = {
    email: '[email protected]', 
    password: 'passsword'
  }
}) => (
  user && <Box>
    {email} {password}
  </Box>
)

/**
 * Input
 */
const Input () => (
  <Box>
    <Typography>
      Sign in 
    </Typography>
    <Box>
      <TextField required label="Email Address" name="email" />
      <TextField label="Password" type="password" id="password" />
      <FormControlLabel
        control={<Checkbox name="remember" value="remember" color="primary" />}
        label="Remember me"
      />
      <Button type="submit" >
        Sign In
      </Button>
    </Box>
    <Output />
  </Box>
)

/**
 * Layout
 */
export const Main = () => (
  <Box>
    <Avatar>
      <LockOutlinedIcon />
    </Avatar>
    <Typography component="h1" variant="h5">
      Sign in
    </Typography>
    <Input />
    <Output />
  </Box>
)

Add Functionality

import { useConnector } from '@genrate/react';

interface Data {
  email: string;
  password: string;
};

/**
 * Input Component
 */
export const SignIn = ({
  onSubmit = (data: Data) => console.log('test', data)
}) => {

  const { view, model, pass, attach } = useConnector<Data>();

  // render only once

  return view(Input, {
    // Select components to manipulate 
    'TextField[required]': model(), // dynamic auto binding of input
    'Box TextField[name=password]': model('password'), // auto binding of input

    // prop level model auto binding
    'FormControlLabel[control]': model(['control'], (e) => e.target.checked),

    // dynamic auto binding base state data
    TextField: ({ input }) => input == 'yes' ? model('input2') : model('input'), 

    // Add on click event to button
    'Button[type=submit]':
      // subscribe to specific data
      ({ email, password }) => 
      () => ({ 
        onClick: () => {
          onSubmit({ email, password, remember })
        }
      }),
  })
}

/**
 * Main Component
 */
export default function () {
  const { view, attach, set, pass, query, each } = useConnector(
    // state
    state: { list: [1,2,3], input: [] },

    // bind react hooks
    hooks: {
      'login|isLoggedIn' => useAuth()
    }
  );

  return view(Main, {
    // Attach othe component and set prop 
    Input: attach(SignIn, { 
      // receive data from other component
      onSubmit: (data) => set('user', data)
    }),

    // search inside an element and apply data changes
    Input: query({
      TextField: model(),
      Button: 
        ({ email, login, isLoggedIn }) => 
        () => ({ 
          onClick: () => isLoggedIn ? logout(email) : login(email)
        })
    }),

    // Iterator
    Input: each(
      ({ list }) => 
      () => list.map((l, i) => {

        if (l == 1) {
          // query iterated element
          return query({
            // array model value
            TextField: model(`input.${i}`)
          })
        } 

        // iterated element props 
        return ({ test: 'value' })
      })
    ),


    // pass data to other component 
    Test: pass('user', 'input')
  })
}