Personal Dashboard

DialogButton.jsx 1.0KB

123456789101112131415161718192021222324
  1. import React from 'react'
  2. import { Dialog, Button } from '@blueprintjs/core'
  3. import Control from '../Control'
  4. const DialogButtonTemplate = (props, state) =>
  5. <Button iconName={props.iconName} className={props.className}
  6. onClick={() => props.toggle(true)} text={props.buttonText}>
  7. <Dialog isOpen={state.open} onClose={() => props.toggle(false)} title={props.title}>
  8. <div className="pt-dialog-body">
  9. {props.children}
  10. </div>
  11. <div className="pt-dialog-footer">
  12. <div className="pt-dialog-footer-actions">
  13. <Button text={props.cancelButtonText} onClick={() => props.toggle(false)}/>
  14. <Button intent={props.intent} onClick={props.confirm} text={props.confirmButtonText} />
  15. </div>
  16. </div>
  17. </Dialog>
  18. </Button>
  19. export const DialogButton = Control({ open: false }, {
  20. toggle: ({ setState }, open) => setState({ open }),
  21. confirm: ({ props }) => props.onConfirm()
  22. })(DialogButtonTemplate)