Sha256: a0bd5942cab7ecfda49f37e059fd7d81a67eaa142b0ba969b363072c7fad3364

Contents?: true

Size: 1.03 KB

Versions: 840

Compression:

Stored size: 1.03 KB

Contents

import React, { useState } from 'react'
import { Button, Dialog } from 'playbook-ui'

const DialogLoading = () => {
  const [isOpen, setIsOpen] = useState(false)
  const close = () => {
    if (!isLoading) {
      setIsOpen(false)
    }
  }
  const open = () => setIsOpen(true)
  const [isLoading, setIsLoading] = useState(false)
  const submit = async () => {
    setIsLoading(true)

    try {
      await new Promise((r) => setTimeout(r, 3000))
      setIsOpen(false)
    } catch (error) {
      console.error("An error occurred.")
    } finally {
      setIsLoading(false)
    }
  }

  return (
    <>
      <Button onClick={open}>{'Open Dialog'}</Button>
      <Dialog
          cancelButton="Cancel"
          className="wrapper"
          confirmButton="Okay"
          loading={isLoading}
          onCancel={close}
          onClose={close}
          onConfirm={submit}
          opened={isOpen}
          size="sm"
          text="Make a 3 second request?"
          title="Loading Example"
      />
    </>
  )
}

export default DialogLoading

Version data entries

840 entries across 840 versions & 2 rubygems

Version Path
playbook_ui-14.11.0.pre.rc.17 app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.jsx
playbook_ui-14.11.0 app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.jsx
playbook_ui_docs-14.11.0.pre.rc.16 app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.jsx
playbook_ui-14.11.0.pre.rc.16 app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.jsx
playbook_ui_docs-14.10.0.pre.alpha.play16825301 app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.jsx
playbook_ui-14.10.0.pre.alpha.play16825301 app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.jsx
playbook_ui_docs-14.11.0.pre.rc.15 app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.jsx
playbook_ui-14.11.0.pre.rc.15 app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.jsx
playbook_ui_docs-14.11.0.pre.rc.14 app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.jsx
playbook_ui-14.11.0.pre.rc.14 app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.jsx
playbook_ui_docs-14.11.0.pre.rc.13 app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.jsx
playbook_ui-14.11.0.pre.rc.13 app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.jsx
playbook_ui_docs-14.11.0.pre.rc.12 app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.jsx
playbook_ui-14.11.0.pre.rc.12 app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.jsx
playbook_ui_docs-14.10.0.pre.alpha.PLAY1774timelinelabelstepspacing5274 app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.jsx
playbook_ui-14.10.0.pre.alpha.PLAY1774timelinelabelstepspacing5274 app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.jsx
playbook_ui_docs-14.10.0.pre.alpha.play1465attempt25272 app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.jsx
playbook_ui-14.10.0.pre.alpha.play1465attempt25272 app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.jsx
playbook_ui_docs-14.10.0.pre.alpha.play16825244 app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.jsx
playbook_ui-14.10.0.pre.alpha.play16825244 app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.jsx