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-drip-form-components

v0.0.2

Published

Official UI Components for react-drip-form. styling by styled-components.

Downloads

21

Readme

react-drip-form-components

Build Status Codecov npm version

Official UI Components for react-drip-form. styling by styled-components.

https://tsuyoshiwada.github.io/react-drip-form-components/

Table of Contents

DEMO

Screenshot

See Live Demo.

Getting Started

Installation

react-drip-form must also be installed.

$ npm install --save react-drip-form
$ npm install --save react-drip-form-components

Usage

import React from 'react';
import { dripForm } from 'react-drip-form';
import {
  Checkbox,
  FieldGroup,
  Input,
  Radio,
  Select,
  Textarea,
} from 'react-drip-form-components';

export default dripForm({/* form options */})(({ handlers }) => (
  <form onSubmit={handlers.onSubmit}>
    {/* Input field */}
    <Input name="username" type="text" />

    {/* Select field */}
    <Select name="color">
      <option value="#fff">White</option>
      <option value="#ccc">Gray</option>
      <option value="#000">Black</option>
    </Select>

    {/* Checkbox with FieldGroup field */}
    <FieldGroup name="library" multiple>
      <Checkbox value="react">React</Checkbox>
      <Checkbox value="angular">Angular</Checkbox>
      <Checkbox value="vue">Vue</Checkbox>
    </FieldGroup>

    {/* Radio with FieldGroup field */}
    <FieldGroup name="gender">
      <Radio name="female">Female</Radio>
      <Radio name="male">Male</Radio>
      <Radio name="other">Other</Radio>
    </FieldGroup>

    {/* Textarea field */}
    <Textarea name="message" />

    {/* Checkbox only */}
    <Checkbox name="confirm" value="yes">
      I agree to the <a href="/foo/bar/">Terms of Use</a>
    </Checkbox>

    <button type="submit" onClick={handlers.onSubmit}>Submit</button>
  </form>
));

For actual use, demo/components/SampleForm.js source code may be helpful!

API

The APIs listed below are proprietary properties other than the field properties of react-drip-form.
Please refer to the document for react-drip-form field properties.

shouldDisplayError

This function accepts the properties of the field and makes a decision whether to display an error.
If you want to display an error you need to return true.

By default the following code is used.

({ meta }) => !!(meta.error && meta.dirty && meta.touched)

shouldDisplaySpinner

This function determines the display of the spinner used for asynchronous verification and so on.
If you want to display a spinner you need to return true.

By default the following code is used.

({ meta }) => meta.validating

Checkbox

It is a component that wraps type="checkbox" with dripFormField().

| key | description | |:-----------------------|:---------------------------------------------------| | children | Child element to display on label. | | disabled | Specify whether the field is disabled. | | shouldDisplayError | ref: shouldDisplayError | | shouldDisplaySpinner | ref: shouldDisplaySpinner |

Input

It is a component that wraps input with dripFormField(). mainly used for text control.

| key | description | |:-----------------------|:-----------------------------------------------------------------------------------| | type | Specify an InputType other than checkbox and radio. (Text or email etc...) | | disabled | Specify whether the field is disabled. | | shouldDisplayError | ref: shouldDisplayError | | shouldDisplaySpinner | ref: shouldDisplaySpinner |

Radio

It is a component that wraps type="radio" with dripFormField().

| key | description | |:-----------------------|:---------------------------------------------------| | children | Child element to display on label. | | disabled | Specify whether the field is disabled. | | shouldDisplayError | ref: shouldDisplayError | | shouldDisplaySpinner | ref: shouldDisplaySpinner |

Select

It is a component that wraps select with dripFormField().

| key | description | |:-----------------------|:------------------------------------------------------------------------------| | children | Specify the <option> element. | | multiple | Whether multiple selection is enabled or not. Specify true if it is enable. | | disabled | Specify whether the field is disabled. | | shouldDisplayError | ref: shouldDisplayError | | shouldDisplaySpinner | ref: shouldDisplaySpinner |

Textarea

It is a component that wraps textarea with dripFormField().

| key | description | |:-----------------------|:---------------------------------------------------| | disabled | Specify whether the field is disabled. | | shouldDisplayError | ref: shouldDisplayError | | shouldDisplaySpinner | ref: shouldDisplaySpinner |

FieldGroup

It is a component wrapped in dripFormGroup().

| key | description | |:---------------------|:-----------------------------------------------| | children | Specify the enclosing child element. | | shouldDisplayError | ref: shouldDisplayError |

Customize Theme

You can customize the theme by using extendTheme as follows.

import React from 'react';
import { ThemeProvider } from 'styled-components';
import { extendTheme } from 'react-drip-form-components';

const originalTheme = {
  /* ... Your theme variables */

  // The `rdf` namespace is the theme of `react-drip-form`.
  rdf: extendTheme({
    /* Specify a custom theme here */
  }),
};

export default () => (
  <ThemeProvider theme={originalTheme}>
    {/* Here is your components. */}
  </ThemeProvider>
);

See src/theme.js for customizable variables.

Related projects

Contribute

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Bugs, feature requests and comments are more than welcome in the issues.

License

MIT © tsuyoshiwada