0.0.5 • Published 3 years ago

mui-masked v0.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

mui-masked

A library of React components

Installation

npm install mui-masked

and also include stylesheet file in your global .css file

@import "mui-masked/dist/style.css"

Usage

import React, { useState } from 'react'
import { makeStyles } from '@material-ui/core'
import {
  MaskedInputPhone,
  MaskedInputCode,
  Button,
  isValidForm,
} from 'mui-masked'
const useStyles = makeStyles(() => ({
  root: {
    margin: '10px 0',
  },
}))
const App = () => {
  const classes = useStyles()
  const [values, setValues] = useState({})
  const [errorCode, setErrorCode] = useState(false)
  const [isLoading, setIsLoading] = useState(false)
  const handleChange = (value, name) => {
    setValues({ ...values, [name]: value })
  }
  const handleSubmit = (e) => {
    e.preventDefault()
    // If all fields are valid
    if (isValidForm(e)) {
      setIsLoading(true)
      setTimeout(() => {
        setErrorCode(true)
        setIsLoading(false)
      }, 3000)
    }
  }
  return (
    <form onSubmit={handleSubmit}>
      <MaskedInputPhone
        onChange={handleChange}
        fullWidth
        className={classes.root}
        name='phone'
        label='Phone number'
        placeholder='Enter phone number'
      />
      <MaskedInputCode
        onChange={handleChange}
        fullWidth
        className={classes.root}
        name='code'
        lang='en'
        incorrect={errorCode}
        setIncorrect={setErrorCode}
        label='OTP'
        placeholder='Enter one time password'
      />
      <Button
        color='#fff'
        backgroundColor='rgb(73, 167, 255)'
        circleColor='white'
        isLoading={isLoading}
      />
    </form>
  )
}
export default App

Component props

<Button />
proptypedefaultdefinition
isLoadingbooleanfalse- if true, circular progress is shown inside button
typestringsubmit- button type (button,submit, reset)
classNamestringnone- class name for button
onClickfunctionnone- onClick event listener function
innerstringSubmit- default inner text inside button
backgroundColorstring#49a7ff- background color of button
circleColorstring#fff- color of circular progress
colorstring#fff- color of text inside buttton
0.0.5

3 years ago

0.0.42

3 years ago

0.0.41

3 years ago

0.0.4

3 years ago

0.0.38

3 years ago

0.0.37

3 years ago

0.0.36

3 years ago

0.0.35

3 years ago

0.0.34

3 years ago

0.0.33

3 years ago

0.0.32

3 years ago

0.0.31

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago