2016-08-26 02:52:55 +09:00
import CharacterCounter from './character_counter' ;
import Button from './button' ;
2016-08-31 23:15:12 +09:00
import PureRenderMixin from 'react-addons-pure-render-mixin' ;
2016-08-26 02:52:55 +09:00
const ComposerDrawer = React . createClass ( {
propTypes : {
2016-08-31 23:15:12 +09:00
text : React . PropTypes . string . isRequired ,
isSubmitting : React . PropTypes . boolean ,
onChange : React . PropTypes . func . isRequired ,
2016-08-26 02:52:55 +09:00
onSubmit : React . PropTypes . func . isRequired
} ,
2016-08-31 23:15:12 +09:00
mixins : [ PureRenderMixin ] ,
2016-08-26 02:52:55 +09:00
handleChange ( e ) {
2016-08-31 23:15:12 +09:00
this . props . onChange ( e . target . value ) ;
2016-08-26 02:52:55 +09:00
} ,
handleKeyUp ( e ) {
if ( e . keyCode === 13 && e . ctrlKey ) {
2016-08-31 23:15:12 +09:00
this . props . onSubmit ( ) ;
2016-08-26 02:52:55 +09:00
}
} ,
handleSubmit ( ) {
2016-08-31 23:15:12 +09:00
this . props . onSubmit ( ) ;
2016-08-26 02:52:55 +09:00
} ,
render ( ) {
return (
2016-08-31 23:48:21 +09:00
< div style = { { width : '280px' , boxSizing : 'border-box' , background : '#454b5e' , margin : '10px' , marginRight : '0' , padding : '10px' } } >
2016-08-31 23:15:12 +09:00
< textarea disabled = { this . props . isSubmitting } placeholder = 'What is on your mind?' value = { this . props . text } onKeyUp = { this . handleKeyUp } onChange = { this . handleChange } style = { { display : 'block' , boxSizing : 'border-box' , width : '100%' , height : '100px' , background : '#fff' , resize : 'none' , border : 'none' , color : '#282c37' , padding : '10px' , fontFamily : 'Roboto' , fontSize : '14px' } } / >
2016-08-26 02:52:55 +09:00
< div style = { { marginTop : '10px' , overflow : 'hidden' } } >
2016-08-31 23:15:12 +09:00
< div style = { { float : 'right' } } > < Button text = 'Publish' onClick = { this . handleSubmit } disabled = { this . props . isSubmitting } / > < / div >
< div style = { { float : 'right' , marginRight : '16px' , lineHeight : '36px' } } > < CharacterCounter text = { this . props . text } / > < / div >
2016-08-26 02:52:55 +09:00
< / div >
< / div >
) ;
}
} ) ;
export default ComposerDrawer ;