ldx-widgets
Version:
widgets
75 lines (53 loc) • 1.46 kB
text/coffeescript
React = require 'react'
TransitionGroup = React.createFactory require('react-addons-transition-group')
DialogueBox = React.createFactory(require './dialogue_box')
_ = require 'lodash'
{div} = React.DOM
###
Dialogue Box Props
@props.message - String
message to display
@props.confirmText - String - default: 'OK'
text to display in okay/confirm button
@props.cancelText - String - default: 'Cancel'
text gto display in the cancel button
@props.width - Number - default: 400
width in pixels of the dialogue
@props.confirmCallback - method
method to call when the 'ok' button is clicked or enter is pressed
@props.cancelCallBack - method
method to call when the cancel button is clicked
###
Dialogue = React.createClass
displayName: 'Dialogue'
getDefaultProps: ->
{
message: ''
confirmText: 'OK'
cancelText: 'Cancel'
confirmCallback: ->
cancelCallback: ->
width: 400
}
render: ->
{showDialogue} = @state
props = _.clone(@props)
dialogue = DialogueBox _.assign props, {
transitionOut: @transitionOut
} if showDialogue
TransitionGroup {
transitionName: 'dialogue'
component: 'div'
className: 'dialogue-container'
}, dialogue
getInitialState: ->
{
showDialogue: no
}
componentDidMount: ->
@setState
showDialogue: yes
transitionOut: ->
@setState
showDialogue: no
module.exports = Dialogue