2.0.2 • Published 1 year ago

release-contracts-ui-components v2.0.2

Weekly downloads
-
License
MIT
Repository
bitbucket
Last release
1 year ago

release-contracts-ui-components

This little library is meant to speed up the UI development process of react applications. It contains a set of self contained UI elements which can be used for any project via NPM.

NPM JavaScript Style Guide npm version

Install ui library and it's peer dependencies

yarn add --save release-contracts-ui-components @material-ui/icons @material-ui/core formik 

Add the fonts and icons of material-ui to your index.html

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />

setup seed data to build up a form inside a /seed/index.jx file with correct structure

// ./seed/index.js

import * as yup from 'yup'

const seed = [{ <-- important: each object in the array represents an input field in the form
  id: 'identifier', <-- important: this name is being used to setup the initial values for formik state
  name: 'identifier',
  label: 'Email',
  type: 'email',
  placeholder: 'Email',
  autoComplete: 'email'
}, {
  id: 'password',
  name: 'password',
  label: 'Wachtwoord',
  type: 'password',
  placeholder: '********',
  autoComplete: 'current-password',
  helperText: 'Wachtwoord vergeten?'
}]

const loginValidationSchema = yup.object().shape({
  identifier: yup
    .string()
    .email()
    .required('Email must be filled in'),
  password: yup
    .string()
    .min(0)
    .required('Password is required')
})

export { seed, validationSchema }

Currently we are only supporting input type text fields. In the next release more to come

Usage

import React, { Component } from 'react'

import { CustomForm } from 'release-contracts-ui-components'
import { seed } from './seed'

class Example extends Component {
  render () {
    return (
      {/* This creates a form with 2 fields: username and password. It also contains a custom onSubmit callback */}
      <Form title='form title' fields={seed} validationSchema={validationSchema} onSubmit={() => console.log('submitting')} />
    )
  }
}

Supported Components


PropsTypeLimitationsisRequired
Titlestringonly-stringstrue
subTitlestringonly-stringsfales
fieldsobjectonly-objecttrue
validationSchemaobjectonly-objecttrue
onSubmitfunconly-functiontrue

PropsTypeLimitationsisRequired
Titlestringonly-stringstrue
colorstringonly-stringsfalse
inhertis all material-ui propsmaterial-ui APIsee docsfalse

PropsTypeLimitationsisRequired
Titlestringonly-stringstrue
loadingboolonly-booleantrue
typestringonly-stringtrue (will change in next major)
disabledboolonly-booleanfalse
colorstringonly-stringfalse

PropsTypeLimitationsisRequired
Titlestringonly-stringstrue
inhertis all material-ui propsmaterial-ui APIsee docsfalse

License

MIT © Kevin Vugts(https://github.com/Kevin Vugts)