ldx-widgets
Version:
widgets
73 lines (54 loc) • 1.59 kB
text/coffeescript
###
Confirm User Action Props
NOTE: this widget is intended to be passed as the element prop to the pvr widget
.onOkay
callback to be executed when the user clicks the 'OK' button
.confirmText - default 'Are you sure?'
String to display to the user
.confirmBtnLabel - default 'OK'
String to display on the button that executes the callback
.cancelBtnLabel - default 'Cancel'
String to display on the button that dismisses the pvr w/ no action
###
React = require 'react'
{div, button} = React.DOM
ConfirmUserAction = React.createClass
displayName: 'ConfirmUserAction'
propTypes:
close: React.PropTypes.func.isRequired
onOkay: React.PropTypes.func.isRequired
getDefaultProps: ->
{
confirmText: 'Are you sure?'
confirmBtnLabel: 'OK'
cancelBtnLabel: 'Cancel'
}
handleButtonClick: (e) ->
if e.target.value is 'okay' then .onOkay()
else .close()
render: ->
{confirmText, confirmBtnLabel, cancelBtnLabel} =
div {
key: 'inner'
className: 'inner confirm'
}, [
div {
key: 'message'
className: 'message'
}, confirmText
button {
key: 'okay-btn'
type: 'button'
className: 'okay-btn'
onClick:
value: 'okay'
}, confirmBtnLabel
button {
key: 'cancel-btn'
type: 'button'
className: 'cancel-btn'
onClick:
value: 'cancel'
}, cancelBtnLabel
]
module.exports = ConfirmUserAction