docbrown/app/javascript/sidebar-widget/sidebarUser.jsx
Andy Zhao d6e3344da7 [Updated] Suggested Follows Sidebar (#240)
* MVP of follow sidebar

* Prettier linted stuff

* More prettier lint

* Load only one widget

* fix github issue comment liquid tag (#242)

* Adjust Flatiron school copy/link (#241)

Per Flatiron School request, updating the homepage copy and link

* Add sticky sidebar to article show page (#243)

* Add sidebar sticky elements

* Add sticky sidebar to article show page

* Add saved changes check to user

* Fix missing CSS variable in sticky nav file

* Add date joined as default summary

* Remove accidentally-included file

* Add check for published on article sidebar

*  Fix styling issues on side nav (#244)

* Add sidebar sticky elements

* Add sticky sidebar to article show page

* Add saved changes check to user

* Fix missing CSS variable in sticky nav file

* Add date joined as default summary

* Remove accidentally-included file

* Add check for published on article sidebar

* Fix styling issues on side nav

* Ben/article show redesign (#245)

* Add sidebar sticky elements

* Add sticky sidebar to article show page

* Add saved changes check to user

* Fix missing CSS variable in sticky nav file

* Add date joined as default summary

* Remove accidentally-included file

* Add check for published on article sidebar

* Fix styling issues on side nav

* Modify article order

* Fix issue in side bar

* Fix issue in side bar

* Ben/article show redesign (#246)

* Add sidebar sticky elements

* Add sticky sidebar to article show page

* Add saved changes check to user

* Fix missing CSS variable in sticky nav file

* Add date joined as default summary

* Remove accidentally-included file

* Add check for published on article sidebar

* Fix styling issues on side nav

* Modify article order

* Fix issue in side bar

* Fix issue in side bar

* Not show author image as other images

* Remove current article id from potential queried articles (#247)

* Add optimistic rendering for follow buttons

* Remove redundant line

* Fix inline stylesheet issue (#248)

* Remove current article id from potential queried articles

* Fix inline stylesheet issue

* Modify sticky_articles source to be more similar to post

* Move assign sticky nav around

* Modify sticky articles

* Attempt to fix sticky

* Fix article show to call 404

* Fix

* Conditional

* Add tag_line to org admin and add conditional on hiring post (#250)

* Modify sticky_article criteria (#251)

* Add tag_line to org admin and add conditional on hiring post

* Modify sticky_article criteria

* Move suggestions to single route

* Exclude self and already followed from suggestions

* Update readme with new API key instructions (#252)

* Modify query to be more performant and correct

* Add br instead of hr for last element

* Remove code for development woops

* Add user articles to sidebar (#253)

* Add user articles to sidebar

* Add organization save-all functionality

* Adjust articles that show up in side sticky bar (#254)

* Add user articles to sidebar

* Add organization save-all functionality

* Adjust articles that show up in side sticky bar

* Add conditional for @user_stickies to show up

* Misc change to styles (#255)

* Add user articles to sidebar

* Add organization save-all functionality

* Adjust articles that show up in side sticky bar

* Add conditional for @user_stickies to show up

* Misc change to styles

* Slight change

* Modified footer center show stuff

* Remove current article author from sticky sidebar (#256)

* Fix article preview issue (#257)

* Update blackbox's API endpoint (#259)

* Modify user tag follow suggestions
2018-04-30 17:45:01 -04:00

47 lines
1.2 KiB
JavaScript

import { h, Component } from 'preact';
import PropTypes from 'prop-types';
class SidebarUser extends Component {
constructor(props) {
super(props);
this.onClick = this.onClick.bind(this);
}
onClick() {
this.props.followUser(this.props.user);
}
render() {
return (
<div className="widget-list-item__suggestions">
<div className="widget-list-item__content">
<a href={`/${this.props.user.username}`}>
<img
src={this.props.user.profile_image_url}
alt={this.props.user.name}
className="widget-list-item__profile-pic"
/>
{this.props.user.name}
</a>
<button
className="widget-list-item__follow-button"
type="button"
onClick={this.onClick}
id={`widget-list-item__follow-button-${this.props.user.username}`}
>
{this.props.user.following ? '✓ FOLLOWING' : '+ FOLLOW'}
</button>
</div>
{this.props.index === 2 ? <br /> : <hr />}
</div>
);
}
}
SidebarUser.propTypes = {
followUser: PropTypes.func.isRequired,
user: PropTypes.object.isRequired,
index: PropTypes.number.isRequired,
};
export default SidebarUser;