polyform-generator

1.2.1 • Public • Published

Polyform-generator

Generate your beautify forms

NPM JavaScript Style Guide

Install

npm install --save polyform-generator

Usage

You can generate a form object from Polyform Builder

Copy your form object as pass it as prop and let Polyform do the magic

import React, { Component } from 'react'

import { Polyform } from 'polyform-generator'
import 'polyform-generator/dist/index.css'

const formObject = {
  container: {
    backgroudColor: 'white',
    title: 'Registration form for GIS',
    about: 'Please fill the form',
    tintColor: '#0390fc'
  },
  questions: [
    {
      type: 'short-text',
      key: 94107,
      question: 'What is your name?'
    },
    {
      type: 'short-text',
      key: 21264,
      question: 'Where do you live?'
    },
    {
      type: 'phone-number',
      key: 20866,
      question: 'Enter your phone number'
    },
    {
      type: 'long-text',
      key: 82271,
      question: 'Describe your self'
    },
    {
      type: 'multiple-choice',
      key: 65759,
      question: 'What do you do at your free time?'
    }
  ],
  selections: [
    {
      questionIndex: 4,
      selections: ['Sleep', 'Watch Movies', 'Play game'],
      key: 44428
    }
  ]
}

function onComplete(e) {
  console.log(e)
}

class Example extends Component {
  render() {
    return <Polyform form={formObject} onComplete={onComplete} />
  }
}

Props

Prop name Description Default value Example values
form An form object to generate the form { container: { backgroundColor: 'white', title: 'Sample Form',about: 'A sample description',tintColor: '#0390fc'}}
onComplete(e) A callback function when form is completed, return an array of answers to questions (e) => onComplete(e) [answers]

License

MIT © Mushud

Thank you

Readme

Keywords

none

Package Sidebar

Install

npm i polyform-generator

Weekly Downloads

0

Version

1.2.1

License

MIT

Unpacked Size

3.72 MB

Total Files

7

Last publish

Collaborators

  • mushud