about summary refs log tree commit diff
path: root/app/assets/javascripts/components/components
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-08-31 16:15:12 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-08-31 16:15:12 +0200
commit72591cc6d59d774e66d1d42af44bdc00f71f99f8 (patch)
treee2ab1fba6e9b446b92f065af920483b998a2c2ab /app/assets/javascripts/components/components
parent92afd296509de82e7550f67064b032db916b1f63 (diff)
Cleaning up action names and compose drawer
Diffstat (limited to 'app/assets/javascripts/components/components')
-rw-r--r--app/assets/javascripts/components/components/avatar.jsx4
-rw-r--r--app/assets/javascripts/components/components/button.jsx13
-rw-r--r--app/assets/javascripts/components/components/character_counter.jsx5
-rw-r--r--app/assets/javascripts/components/components/column.jsx7
-rw-r--r--app/assets/javascripts/components/components/column_header.jsx8
-rw-r--r--app/assets/javascripts/components/components/columns_area.jsx8
-rw-r--r--app/assets/javascripts/components/components/composer_drawer.jsx26
-rw-r--r--app/assets/javascripts/components/components/display_name.jsx4
-rw-r--r--app/assets/javascripts/components/components/frontend.jsx8
-rw-r--r--app/assets/javascripts/components/components/nav_bar.jsx12
-rw-r--r--app/assets/javascripts/components/components/relative_timestamp.jsx6
-rw-r--r--app/assets/javascripts/components/components/status.jsx5
-rw-r--r--app/assets/javascripts/components/components/status_list.jsx7
13 files changed, 76 insertions, 37 deletions
diff --git a/app/assets/javascripts/components/components/avatar.jsx b/app/assets/javascripts/components/components/avatar.jsx
index 7db3eeff7..abbef72f8 100644
--- a/app/assets/javascripts/components/components/avatar.jsx
+++ b/app/assets/javascripts/components/components/avatar.jsx
@@ -1,9 +1,13 @@
+import PureRenderMixin from 'react-addons-pure-render-mixin';
+
 const Avatar = React.createClass({
 
   propTypes: {
     src: React.PropTypes.string.isRequired
   },
 
+  mixins: [PureRenderMixin],
+
   render () {
     return (
       <div style={{ width: '48px', height: '48px', flex: '0 0 auto' }}>
diff --git a/app/assets/javascripts/components/components/button.jsx b/app/assets/javascripts/components/components/button.jsx
index b2d7ba9a9..e70382142 100644
--- a/app/assets/javascripts/components/components/button.jsx
+++ b/app/assets/javascripts/components/components/button.jsx
@@ -1,12 +1,21 @@
+import PureRenderMixin from 'react-addons-pure-render-mixin';
+
 const Button = React.createClass({
+
   propTypes: {
     text: React.PropTypes.string.isRequired,
-    onClick: React.PropTypes.func
+    onClick: React.PropTypes.func,
+    disabled: React.PropTypes.boolean
   },
 
+  mixins: [PureRenderMixin],
+
   handleClick (e) {
     e.preventDefault();
-    this.props.onClick();
+
+    if (!this.props.disabled) {
+      this.props.onClick();
+    }
   },
 
   render () {
diff --git a/app/assets/javascripts/components/components/character_counter.jsx b/app/assets/javascripts/components/components/character_counter.jsx
index b58d9fe32..dd9218844 100644
--- a/app/assets/javascripts/components/components/character_counter.jsx
+++ b/app/assets/javascripts/components/components/character_counter.jsx
@@ -1,8 +1,13 @@
+import PureRenderMixin from 'react-addons-pure-render-mixin';
+
 const CharacterCounter = React.createClass({
+
   propTypes: {
     text: React.PropTypes.string.isRequired
   },
 
+  mixins: [PureRenderMixin],
+
   render () {
     return (
       <span style={{ fontSize: '16px', cursor: 'default' }}>
diff --git a/app/assets/javascripts/components/components/column.jsx b/app/assets/javascripts/components/components/column.jsx
index c1f5b84a2..b347ee3a8 100644
--- a/app/assets/javascripts/components/components/column.jsx
+++ b/app/assets/javascripts/components/components/column.jsx
@@ -1,12 +1,16 @@
 import StatusListContainer from '../containers/status_list_container';
 import ColumnHeader        from './column_header';
+import PureRenderMixin     from 'react-addons-pure-render-mixin';
 
 const Column = React.createClass({
+
   propTypes: {
     type: React.PropTypes.string
   },
 
-  render: function() {
+  mixins: [PureRenderMixin],
+
+  render () {
     return (
       <div style={{ width: '380px', flex: '0 0 auto', background: '#282c37', margin: '10px', marginRight: '0', display: 'flex', flexDirection: 'column' }}>
         <ColumnHeader type={this.props.type} />
@@ -14,6 +18,7 @@ const Column = React.createClass({
       </div>
     );
   }
+
 });
 
 export default Column;
diff --git a/app/assets/javascripts/components/components/column_header.jsx b/app/assets/javascripts/components/components/column_header.jsx
index e2f7d7c1c..15a195898 100644
--- a/app/assets/javascripts/components/components/column_header.jsx
+++ b/app/assets/javascripts/components/components/column_header.jsx
@@ -1,15 +1,21 @@
+import PureRenderMixin from 'react-addons-pure-render-mixin';
+
 const ColumnHeader = React.createClass({
+
   propTypes: {
     type: React.PropTypes.string
   },
 
-  render: function() {
+  mixins: [PureRenderMixin],
+
+  render () {
     return (
       <div style={{ padding: '15px', fontSize: '16px', background: '#2f3441', flex: '0 0 auto' }}>
         {this.props.type}
       </div>
     );
   }
+
 });
 
 export default ColumnHeader;
diff --git a/app/assets/javascripts/components/components/columns_area.jsx b/app/assets/javascripts/components/components/columns_area.jsx
index 1c46f722d..149fdfcf4 100644
--- a/app/assets/javascripts/components/components/columns_area.jsx
+++ b/app/assets/javascripts/components/components/columns_area.jsx
@@ -1,8 +1,11 @@
-import Column from './column';
+import Column          from './column';
+import PureRenderMixin from 'react-addons-pure-render-mixin';
 
 const ColumnsArea = React.createClass({
 
-  render: function() {
+  mixins: [PureRenderMixin],
+
+  render () {
     return (
       <div style={{ display: 'flex', flexDirection: 'row', flex: '1' }}>
         <Column type='home' />
@@ -10,6 +13,7 @@ const ColumnsArea = React.createClass({
       </div>
     );
   }
+
 });
 
 export default ColumnsArea;
diff --git a/app/assets/javascripts/components/components/composer_drawer.jsx b/app/assets/javascripts/components/components/composer_drawer.jsx
index 7b742f64e..71455967f 100644
--- a/app/assets/javascripts/components/components/composer_drawer.jsx
+++ b/app/assets/javascripts/components/components/composer_drawer.jsx
@@ -1,42 +1,40 @@
 import CharacterCounter from './character_counter';
 import Button           from './button';
-import { publish }      from '../actions/statuses';
+import PureRenderMixin  from 'react-addons-pure-render-mixin';
 
 const ComposerDrawer = React.createClass({
 
   propTypes: {
+    text: React.PropTypes.string.isRequired,
+    isSubmitting: React.PropTypes.boolean,
+    onChange: React.PropTypes.func.isRequired,
     onSubmit: React.PropTypes.func.isRequired
   },
 
-  getInitialState() {
-    return {
-      text: ''
-    };
-  },
+  mixins: [PureRenderMixin],
 
   handleChange (e) {
-    this.setState({ text: e.target.value });
+    this.props.onChange(e.target.value);
   },
 
   handleKeyUp (e) {
     if (e.keyCode === 13 && e.ctrlKey) {
-      this.handleSubmit();
+      this.props.onSubmit();
     }
   },
 
   handleSubmit () {
-    this.props.onSubmit(this.state.text, null);
-    this.setState({ text: '' });
+    this.props.onSubmit();
   },
 
   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={{ width: '380px', boxSizing: 'border-box', background: '#454b5e', margin: '10px', marginRight: '0', padding: '10px' }}>
+        <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' }} />
 
         <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 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>
         </div>
       </div>
     );
diff --git a/app/assets/javascripts/components/components/display_name.jsx b/app/assets/javascripts/components/components/display_name.jsx
index 9faefba67..b63bfa5e3 100644
--- a/app/assets/javascripts/components/components/display_name.jsx
+++ b/app/assets/javascripts/components/components/display_name.jsx
@@ -1,10 +1,14 @@
 import ImmutablePropTypes from 'react-immutable-proptypes';
+import PureRenderMixin    from 'react-addons-pure-render-mixin';
 
 const DisplayName = React.createClass({
+
   propTypes: {
     account: ImmutablePropTypes.map.isRequired
   },
 
+  mixins: [PureRenderMixin],
+
   render () {
     var displayName = this.props.account.get('display_name', this.props.account.get('username'));
     var acct        = this.props.account.get('acct');
diff --git a/app/assets/javascripts/components/components/frontend.jsx b/app/assets/javascripts/components/components/frontend.jsx
index 01ad3490a..90ad02dd5 100644
--- a/app/assets/javascripts/components/components/frontend.jsx
+++ b/app/assets/javascripts/components/components/frontend.jsx
@@ -1,18 +1,20 @@
-import NavBar                  from './nav_bar';
 import ColumnsArea             from './columns_area';
 import ComposerDrawerContainer from '../containers/composer_drawer_container';
+import PureRenderMixin         from 'react-addons-pure-render-mixin';
 
 const Frontend = React.createClass({
 
-  render: function() {
+  mixins: [PureRenderMixin],
+
+  render () {
     return (
       <div style={{ flex: '0 0 auto', display: 'flex', width: '100%', height: '100%', background: '#1a1c23' }}>
-        <NavBar />
         <ComposerDrawerContainer />
         <ColumnsArea />
       </div>
     );
   }
+
 });
 
 export default Frontend;
diff --git a/app/assets/javascripts/components/components/nav_bar.jsx b/app/assets/javascripts/components/components/nav_bar.jsx
deleted file mode 100644
index f3f6768e6..000000000
--- a/app/assets/javascripts/components/components/nav_bar.jsx
+++ /dev/null
@@ -1,12 +0,0 @@
-const NavBar = React.createClass({
-
-  render: function() {
-    return (
-      <div style={{ background: '#2f3441', width: '60px', margin: '10px', marginRight: '0' }}>
-
-      </div>
-    );
-  }
-});
-
-export default NavBar;
diff --git a/app/assets/javascripts/components/components/relative_timestamp.jsx b/app/assets/javascripts/components/components/relative_timestamp.jsx
index 49158ee13..0b541c0cf 100644
--- a/app/assets/javascripts/components/components/relative_timestamp.jsx
+++ b/app/assets/javascripts/components/components/relative_timestamp.jsx
@@ -1,4 +1,5 @@
-import moment from 'moment';
+import moment          from 'moment';
+import PureRenderMixin from 'react-addons-pure-render-mixin';
 
 moment.updateLocale('en', {
   relativeTime : {
@@ -19,6 +20,7 @@ moment.updateLocale('en', {
 });
 
 const RelativeTimestamp = React.createClass({
+
   getInitialState () {
     return {
       text: ''
@@ -29,6 +31,8 @@ const RelativeTimestamp = React.createClass({
     timestamp: React.PropTypes.string.isRequired
   },
 
+  mixins: [PureRenderMixin],
+
   componentWillMount () {
     this._updateMomentText();
     this.interval = setInterval(this._updateMomentText, 6000);
diff --git a/app/assets/javascripts/components/components/status.jsx b/app/assets/javascripts/components/components/status.jsx
index bb518a9e1..c6d57aced 100644
--- a/app/assets/javascripts/components/components/status.jsx
+++ b/app/assets/javascripts/components/components/status.jsx
@@ -2,12 +2,16 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
 import Avatar             from './avatar';
 import DisplayName        from './display_name';
 import RelativeTimestamp  from './relative_timestamp';
+import PureRenderMixin    from 'react-addons-pure-render-mixin';
 
 const Status = React.createClass({
+
   propTypes: {
     status: ImmutablePropTypes.map.isRequired
   },
 
+  mixins: [PureRenderMixin],
+
   render () {
     var content = { __html: this.props.status.get('content') };
     var status  = this.props.status;
@@ -30,6 +34,7 @@ const Status = React.createClass({
       </div>
     );
   }
+
 });
 
 export default Status;
diff --git a/app/assets/javascripts/components/components/status_list.jsx b/app/assets/javascripts/components/components/status_list.jsx
index c986c773b..9ba08fb70 100644
--- a/app/assets/javascripts/components/components/status_list.jsx
+++ b/app/assets/javascripts/components/components/status_list.jsx
@@ -1,12 +1,16 @@
 import Status             from './status';
 import ImmutablePropTypes from 'react-immutable-proptypes';
+import PureRenderMixin    from 'react-addons-pure-render-mixin';
 
 const StatusList = React.createClass({
+
   propTypes: {
     statuses: ImmutablePropTypes.list.isRequired
   },
 
-  render: function() {
+  mixins: [PureRenderMixin],
+
+  render () {
     return (
       <div style={{ overflowY: 'scroll', flex: '1 1 auto' }}>
         <div>
@@ -17,6 +21,7 @@ const StatusList = React.createClass({
       </div>
     );
   }
+
 });
 
 export default StatusList;