1.0.2 • Published 4 years ago

react-feedback-modal v1.0.2

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

react-feedback-modal

A beautiful and simple react feedback dialog components.

NPM JavaScript Style Guide

default figure

Install

npm install react-feedback-modal

If you are using yarn

yarn add react-feedback-modal

Import

import { Feedback } from 'react-feedback-modal'

Parameters

ParametersDefaultDescriptionType
showtrueDisplay the modal. e.g. true will display.boolean
imgUrl'/assets/emoji_happy.png'The icon of the modal.string
status'Success'Information about the status of the modalstring
msg'Project created successfully~'Details about the modal messagestring
okText'OK'Primary ok button display textstring
cancelText'Cancel'Secondary cancel button display textstring
confirmfalseEnable will display the cancel buttonboolean
savehandleReloadFunction when click the ok button, default will reload the pagefunction:void
cancelhandleReloadFunction when click the cancel button, default will reload the pagefunction:void
width'400px'The width of the modalstring
height'200px'The hight of the modalstring
backgroundColor'#fff'The background color of the modalstring
borderRadisu'25px'The border radius of the modalstring

Usage

Default Feedback Modal

By default, the page will reload once the button being fired.

import React from 'react'
import { Feedback } from 'react-feedback-modal'

export default function App() {
  return <Feedback show={true} />
}

Binding the display with your hooks

We could create our own method that we want after click the button. The code below will disable the modal if click cancel, and reload if click ok.

default figure

import React, { useState } from 'react'
import { Feedback } from 'react-feedback-modal'

export default function App() {
  const [show, setShow] = useState < boolean > false

  const offFeedback = (): void => {
    setShow(false)
  }

  const showFeedback = (): void => {
    setShow(true)
  }

  return (
    <div>
      <button onClick={showFeedback}>Submit Form</button>

      <Feedback show={show} confirm={true} cancel={offFeedback} />
    </div>
  )
}

Uninstall

In your project directory, run

npm uninstall react-feedback-modal

If you are using yarn

yarn remove react-feedback-modal

ChangeLog

  • 2020/06/23 version 1.0.1 publish

License

MIT © yang052513