about summary refs log tree commit diff
path: root/app/assets/javascripts/components/features
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-10-15 12:06:30 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-10-15 12:06:30 +0200
commit20f581f79669118a1a4052408078d53c7bbe83f2 (patch)
tree4fa86d90bdb0b92ce300b95fa9f3661d16b154b7 /app/assets/javascripts/components/features
parente21a3fe0cd91dfeae76bce4d58c7611e78b60fbf (diff)
Display follow suggestions
Diffstat (limited to 'app/assets/javascripts/components/features')
-rw-r--r--app/assets/javascripts/components/features/compose/components/suggestions_box.jsx76
-rw-r--r--app/assets/javascripts/components/features/compose/containers/suggestions_container.jsx9
-rw-r--r--app/assets/javascripts/components/features/compose/index.jsx14
3 files changed, 98 insertions, 1 deletions
diff --git a/app/assets/javascripts/components/features/compose/components/suggestions_box.jsx b/app/assets/javascripts/components/features/compose/components/suggestions_box.jsx
new file mode 100644
index 000000000..289260f12
--- /dev/null
+++ b/app/assets/javascripts/components/features/compose/components/suggestions_box.jsx
@@ -0,0 +1,76 @@
+import PureRenderMixin    from 'react-addons-pure-render-mixin';
+import ImmutablePropTypes from 'react-immutable-proptypes';
+import Avatar             from '../../../components/avatar';
+import DisplayName        from '../../../components/display_name';
+import { Link }           from 'react-router';
+
+const outerStyle = {
+  marginBottom: '10px',
+  borderTop: '1px solid #616b86'
+};
+
+const headerStyle = {
+  fontSize: '14px',
+  fontWeight: '500',
+  display: 'block',
+  padding: '10px',
+  color: '#9baec8',
+  background: '#454b5e',
+  width: '120px',
+  marginTop: '-18px'
+};
+
+const itemStyle = {
+  display: 'block',
+  padding: '10px',
+  color: '#9baec8',
+  overflow: 'hidden',
+  textDecoration: 'none'
+};
+
+const displayNameStyle = {
+  display: 'block',
+  fontWeight: '500'
+};
+
+const acctStyle = {
+  display: 'block'
+};
+
+const SuggestionsBox = React.createClass({
+
+  propTypes: {
+    accounts: ImmutablePropTypes.list.isRequired
+  },
+
+  mixins: [PureRenderMixin],
+
+  render () {
+    const accounts = this.props.accounts.take(2);
+
+    return (
+      <div style={outerStyle}>
+        <strong style={headerStyle}>Who to follow</strong>
+
+        {accounts.map(account => {
+          let displayName = account.get('display_name');
+
+          if (displayName.length === 0) {
+            displayName = account.get('username');
+          }
+
+          return (
+            <Link key={account.get('id')} style={itemStyle} to={`/accounts/${account.get('id')}`}>
+              <div style={{ float: 'left', marginRight: '10px' }}><Avatar src={account.get('avatar')} size={36} /></div>
+              <strong style={displayNameStyle}>{displayName}</strong>
+              <span style={acctStyle}>{account.get('acct')}</span>
+            </Link>
+          )
+        })}
+      </div>
+    );
+  }
+
+});
+
+export default SuggestionsBox;
diff --git a/app/assets/javascripts/components/features/compose/containers/suggestions_container.jsx b/app/assets/javascripts/components/features/compose/containers/suggestions_container.jsx
new file mode 100644
index 000000000..7163cb100
--- /dev/null
+++ b/app/assets/javascripts/components/features/compose/containers/suggestions_container.jsx
@@ -0,0 +1,9 @@
+import { connect }           from 'react-redux';
+import { getSuggestions }    from '../../../selectors';
+import SuggestionsBox        from '../components/suggestions_box';
+
+const mapStateToProps = (state) => ({
+  accounts: getSuggestions(state)
+});
+
+export default connect(mapStateToProps)(SuggestionsBox);
diff --git a/app/assets/javascripts/components/features/compose/index.jsx b/app/assets/javascripts/components/features/compose/index.jsx
index 4be938158..d76afc437 100644
--- a/app/assets/javascripts/components/features/compose/index.jsx
+++ b/app/assets/javascripts/components/features/compose/index.jsx
@@ -4,11 +4,22 @@ import FollowFormContainer  from '../ui/containers/follow_form_container';
 import UploadFormContainer  from '../ui/containers/upload_form_container';
 import NavigationContainer  from '../ui/containers/navigation_container';
 import PureRenderMixin      from 'react-addons-pure-render-mixin';
+import SuggestionsContainer from './containers/suggestions_container';
+import { fetchSuggestions } from '../../actions/suggestions';
+import { connect }          from 'react-redux';
 
 const Compose = React.createClass({
 
+  propTypes: {
+    dispatch: React.PropTypes.func.isRequired
+  },
+
   mixins: [PureRenderMixin],
 
+  componentDidMount () {
+    this.props.dispatch(fetchSuggestions());
+  },
+
   render () {
     return (
       <Drawer>
@@ -18,6 +29,7 @@ const Compose = React.createClass({
           <UploadFormContainer />
         </div>
 
+        <SuggestionsContainer />
         <FollowFormContainer />
       </Drawer>
     );
@@ -25,4 +37,4 @@ const Compose = React.createClass({
 
 });
 
-export default Compose;
+export default connect()(Compose);