0.3.1 • Published 2 years ago

pzl-react-reusable-components v0.3.1

Weekly downloads
45
License
ISC
Repository
github
Last release
2 years ago

React Reusable Components version

Installation

npm install pzl-react-reusable-components

Components

ConfirmDialog

Dialog used to confirm actions. Also contains React hook useConfirmationDialog.

Import

Import in the following way:

import { useConfirmationDialog } from 'pzl-react-reusable-components/lib/ConfirmDialog'

Using the hook

const [dialog, getResponse] = useConfirmationDialog()

async function deleteItem() {
  let response = getResponse({
    title: 'Delete item',
    subText: 'Are you sure you want to delete the item?'
  })
  if(response) {
    // Delete item
  }
}

return (
    <div>
      <div>
        <button text="Delete" onClick={deleteItem} />
      </div>
      {dialog}
    </div>
)

UserMessage

Display a message to the user. Uses a MessageBar from office-ui-fabric-react and supports markdown using react-markdown.

Import

Import in the following way:

import { UserMessage } from 'pzl-react-reusable-components/lib/UserMessage'

Using the hook

const [message, setMessage] = useMessage(5000)

async function deleteItem() {
  setMessage({ text: 'Item was deleted' , type: MessageBarType.success })
}

return (
    <div>
      <div>
        <button text="Delete" onClick={deleteItem} />
      </div>
      {dialog}
    </div>
)

Progress

Display progress to the user using the ProgressIndicator component from office-ui-fabric-react.

Import

Import in the following way:

import { Progress } from 'pzl-react-reusable-components/lib/Progress'

Using the hook

const [progress, startProgress, endProgress] = useProgress()

async function deleteItem() {
  startProgress('Deleting item', 'Please wait...')
  ....
  endProgress()
}

return (
    <div>
      <div>
        <button text="Delete" onClick={deleteItem} />
      </div>
      {progress}
    </div>
)

Toast

Display a temporarily message to the user using the MessageBar component from office-ui-fabric-react.

Import

Import in the following way:

import { Toast } from 'pzl-react-reusable-components/lib/Toast'

Using the hook

const [toast, setToast] = useToast(800)

async function deleteItem() {
  ....
  toast("Item was successfully deleted.")
}

return (
    <div>
      <div>
        <button text="Delete" onClick={deleteItem} />
      </div>
      {toast}
    </div>
)
0.3.0

2 years ago

0.3.1

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.2.6

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.0.14

4 years ago

0.0.11

4 years ago

0.0.12

4 years ago

0.0.13

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.5

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago