Skip to content

Commit

Permalink
Update with icon follow/unfollow
Browse files Browse the repository at this point in the history
  • Loading branch information
yamadapc committed Oct 12, 2016
1 parent 4894c4b commit 4757bb4
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 25 deletions.
2 changes: 1 addition & 1 deletion bin/www
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

var app = require('../app').app;
var debug = require('debug')('yo:server');
var debug = require('debug')('busy:server');
var http = require('http');

/**
Expand Down
47 changes: 42 additions & 5 deletions src/app/PageActions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,42 @@
let React = require('react'),
{ Link } = require('react-router');
import React, { Component, PropTypes } from 'react';
import classNames from 'classnames';
import { Link } from 'react-router';

export default class PageActions extends Component {
static propTypes = {
// Follow Button
followButton: PropTypes.bool,
isFollowing: PropTypes.bool,
isFollowingIsLoading: PropTypes.bool,
onClickFollow: PropTypes.func,
};

renderFollowButton() {
const {
followButton,
isFollowing,
isFollowingIsLoading,
onClickFollow
} = this.props;

if (!followButton) return null;

// TODO - Add Tooltip
return (
<a
href="#"
className={classNames('trigger', {
disabled: isFollowingIsLoading,
})}
onClick={onClickFollow}
>
<i className="icon icon-person-add material-icons">
{isFollowing ? 'person outline' : 'person_add'}
</i>
</a>
);
}

module.exports = React.createClass({
render() {
let channel = '';
if (this.props.params && this.props.params.name) {
Expand All @@ -12,7 +47,9 @@ module.exports = React.createClass({

return (
<div className="actions">
<div className="triggers">
<div className="triggers">
{this.renderFollowButton()}

{this.props.edit && <Link to="/profile/edit" className="trigger"><i className="icon icon-md material-icons">format_paint</i></Link>}
{this.props.likes && <a href="#replies" className="trigger"><i className="icon icon-md material-icons">thumb_up</i></a>}
{this.props.replies && <a href="#replies" className="trigger"><i className="icon icon-md material-icons">reply</i></a>}
Expand All @@ -22,4 +59,4 @@ module.exports = React.createClass({
</div>
);
}
});
}
32 changes: 13 additions & 19 deletions src/user/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ class Profile extends Component {
});
}

onClickFollow = () => {
onClickFollow = (e) => {
if (e && e.preventDefault) e.preventDefault();
const isFollowing = this.props.following && !!find(this.props.following, (u) => (
u.following === this.props.params.name
));
Expand Down Expand Up @@ -119,7 +120,17 @@ class Profile extends Component {

return (
<div>
<PageActions params={this.props.params} messages={!edit} edit={edit} />
<PageActions
params={this.props.params}
messages={!edit}
edit={edit}

followButton
isFollowingIsLoading={isFollowingIsLoading}
isFollowing={isFollowing}
onClickFollow={this.onClickFollow}
/>

<Header account={username} />
<section
className="align-center bg-green profile-header"
Expand All @@ -129,23 +140,6 @@ class Profile extends Component {
position: 'relative',
}}
>
<div
style={{
position: 'absolute',
right: 15,
top: 15
}}
>
<button
className={classNames('btn btn-primary', {
disabled: isFollowingIsLoading,
})}
onClick={this.onClickFollow}
>
{isFollowing ? 'Unfollow' : 'Follow'}
</button>
</div>

<div className="mvl">
<div className="avatar avatar-xl">
{_.has(account, 'name') && <div className="reputation">{formatter.reputation(account.reputation)}</div>}
Expand Down
53 changes: 53 additions & 0 deletions src/widgets/Tooltip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React, { Component } from 'react';

export default class Tooltip extends Component {
onMouseOver() {
console.log('over')
this.setState({
mouseover: true,
});
}

onMouseLeave() {
console.log('leave')
this.setState({
mouseover: false,
});
}


render() {
return (
<span
style={{
position: 'relative',
display: 'inline-block',
}}
>
<div
style={{
position: 'absolute',
borderRadius: 10,
top: 0,
zIndex: 2000,
backgroundColor: '#3756a0',
width: 'auto',
color: 'white',
padding: 13,
left: '-120%',
visibility: null, // this.state.over ? null : 'hidden',
}}
>
{this.props.overlay}
</div>

<span
onMouseOver={this.onMouseOver.bind(this)}
onMouseLeave={this.onMouseLeave.bind(this)}
>
{this.props.children}
</span>
</span>
);
}
}

0 comments on commit 4757bb4

Please sign in to comment.