0.3.5-2 • Published 5 months ago

pzl-react-reusable-components v0.3.5-2

Weekly downloads
45
License
ISC
Repository
github
Last release
5 months 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.5-2

5 months ago

0.3.5-1

5 months ago

0.3.5-0

5 months ago

0.3.2

5 months ago

0.3.4

5 months ago

0.3.3

5 months ago

0.3.0

3 years ago

0.3.1

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.2.6

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.0.14

5 years ago

0.0.11

5 years ago

0.0.12

5 years ago

0.0.13

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.5

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago