Personal Dashboard

AlertButton.jsx 738B

1234567891011121314151617
  1. import React from 'react'
  2. import { Button, Alert, Intent } from '@blueprintjs/core'
  3. import Control from '../Control'
  4. const AlertButtonTemplate = (props, state) =>
  5. <Button iconName={props.iconName} className={props.className} onClick={() => props.toggle(true)}>
  6. <Alert intent={props.intent} isOpen={state.open}
  7. confirmButtonText={props.confirmButtonText} cancelButtonText={props.cancelButtonText}
  8. onConfirm={props.confirm} onCancel={() => props.toggle(false)} >
  9. {props.children}
  10. </Alert>
  11. </Button>
  12. export const AlertButton = Control({ open: false }, {
  13. toggle: ({ setState }, open) => setState({ open }),
  14. confirm: ({ props }) => props.onConfirm()
  15. })(AlertButtonTemplate)