parent
f5e1127894
commit
44e57f64dd
@ -0,0 +1,22 @@
|
||||
const Button = React.createClass({
|
||||
propTypes: {
|
||||
text: React.PropTypes.string.isRequired,
|
||||
onClick: React.PropTypes.func
|
||||
},
|
||||
|
||||
handleClick (e) {
|
||||
e.preventDefault();
|
||||
this.props.onClick();
|
||||
},
|
||||
|
||||
render () {
|
||||
return (
|
||||
<a href='#' onClick={this.handleClick} style={{ display: 'inline-block', position: 'relative', boxSizing: 'border-box', textAlign: 'center', border: '10px none', backgroundColor: '#2b90d9', color: '#fff', fontSize: '14px', fontWeight: '500', letterSpacing: '0', textTransform: 'uppercase', padding: '0 16px', height: '36px', cursor: 'pointer', lineHeight: '36px', borderRadius: '4px', textDecoration: 'none' }}>
|
||||
{this.props.text}
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
export default Button;
|
@ -0,0 +1,16 @@
|
||||
const CharacterCounter = React.createClass({
|
||||
propTypes: {
|
||||
text: React.PropTypes.string.isRequired
|
||||
},
|
||||
|
||||
render () {
|
||||
return (
|
||||
<span style={{ fontSize: '16px', cursor: 'default' }}>
|
||||
{this.props.text.length}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
export default CharacterCounter;
|
@ -0,0 +1,46 @@
|
||||
import CharacterCounter from './character_counter';
|
||||
import Button from './button';
|
||||
import { publish } from '../actions/statuses';
|
||||
|
||||
const ComposerDrawer = React.createClass({
|
||||
|
||||
propTypes: {
|
||||
onSubmit: React.PropTypes.func.isRequired
|
||||
},
|
||||
|
||||
getInitialState() {
|
||||
return {
|
||||
text: ''
|
||||
};
|
||||
},
|
||||
|
||||
handleChange (e) {
|
||||
this.setState({ text: e.target.value });
|
||||
},
|
||||
|
||||
handleKeyUp (e) {
|
||||
if (e.keyCode === 13 && e.ctrlKey) {
|
||||
this.handleSubmit();
|
||||
}
|
||||
},
|
||||
|
||||
handleSubmit () {
|
||||
this.props.onSubmit(this.state.text, null);
|
||||
},
|
||||
|
||||
render () {
|
||||
return (
|
||||
<div style={{ width: '230px', background: '#454b5e', margin: '10px 0', padding: '10px' }}>
|
||||
<textarea placeholder='What is on your mind?' value={this.state.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' }} />
|
||||
|
||||
<div style={{ marginTop: '10px', overflow: 'hidden' }}>
|
||||
<div style={{ float: 'right' }}><Button text='Publish' onClick={this.handleSubmit} /></div>
|
||||
<div style={{ float: 'right', marginRight: '16px', lineHeight: '36px' }}><CharacterCounter text={this.state.text} /></div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
export default ComposerDrawer;
|
@ -0,0 +1,17 @@
|
||||
import { connect } from 'react-redux';
|
||||
import ComposerDrawer from '../components/composer_drawer';
|
||||
import { publish } from '../actions/statuses';
|
||||
|
||||
const mapStateToProps = function (state, props) {
|
||||
return {};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = function (dispatch) {
|
||||
return {
|
||||
onSubmit: function (text, in_reply_to_id) {
|
||||
dispatch(publish(text, in_reply_to_id));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(ComposerDrawer);
|
@ -1,6 +1,7 @@
|
||||
import { createStore } from 'redux';
|
||||
import { createStore, applyMiddleware } from 'redux';
|
||||
import thunk from 'redux-thunk';
|
||||
import appReducer from '../reducers';
|
||||
|
||||
export default function configureStore(initialState) {
|
||||
return createStore(appReducer, initialState);
|
||||
export default function configureStore() {
|
||||
return createStore(appReducer, applyMiddleware(thunk));
|
||||
}
|
||||
|
Loading…
Reference in new issue