0.1.1 • Published 6 years ago

folio-forms v0.1.1

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

Folio

Dynamic Form Built With React & CSS Grid layout

live example

Build Status Codecov npm npm GitHub

Overview

Folio has two major bases Cells for data and Grid for layout. With these components, making a form should be easier than ever. See full examples of folio :point_right: https://jalal246.github.io/folio/.

Installation

Run locally:

Using npm:

npm install --save folio-forms

folio depends on react and prop-types. Please make sure you have those installed as well.

unpkg

https://unpkg.com/folio-forms/dist/

Usage

Example

const myForm = ({ mySubmitFunc }) => (
  <Folio>
    <Form onSubmit={mySubmitFunc}>
      <Grid>
        <GridItem row={1} col={1}>
          <Cell valueKey="myFullName" type="text" />
        </GridItem>
        <GridItem row={2} col={1}>
          <Cell valueKey="myEmail" type="email" />
        </GridItem>
        <button type="submit">submit</button>
      </Grid>
    </Form>
  </Folio>
);

// mySubmitFunc will return: (event, {myFullName: "" myEmail: ""})

Components

import Folio, { Form, Grid, Cell, CellItem, GridItem } from "folio-forms";

Components Props

All components accept custom props + children which is required in all except Cell

Form

propertytypedescriptiondefault
componentnode/functioncustom render-componentform
onSubmitfunctionsubmit function returns values in all cells (event, {...values})() {}

Grid

propertytypedescriptiondefault
componentnode/functioncustom render-componentdiv
colnumbernumber of columns in grid
colWidthstringfixed column width
colMinWidthstringcolumn minimum widthauto
colMaxWidthstringcolumn maximum width1fr
rownumbernumber of rows in grid
rowWidthstringfixed row width
rowMinWidthstringrow minimum widthauto
rowMaxWidthstringrow maximum width1fr

GridItem

Used for implicit grid layout.

propertytypedescriptiondefault
componentnode/functioncustom render-componentdiv
rownumbernumber of columns in grid
toRownumbercolumn width
colnumbercolumn minimum width0
toColnumbercolumn maximum width
isCenterBooleannumber of rows in gridfalse
isHorizontalBooleantrue

Cell

Essential to register values in the store, return values it when submit.

propertytypedescriptiondefault
componentnode/functioncustom render-componentdiv
valueKeystringkey used to store value in values objecttype + id + groupname (if any)
idstringauto generated by function
valuestringif type not button""
checkedBooleanif type buttonfalse
typeBooleantext
groupNamestringonly for button toggle

CellItem

Used with list to wrap children.

propertytypedescriptiondefault
componentnode/functioncustom render-componentoption

What's next?

Enable end-user to create, design and shape forms.

License

This project is licensed under the MIT License