This commit is contained in:
Belen Curcio
2017-05-01 11:45:23 -03:00
parent f3980a03b2
commit 1250054fb7
@@ -1,22 +1,24 @@
import React, {Component} from 'react';
import React, { Component } from 'react';
import styles from './style.css';
import Icon from './Icon';
import {I18n} from 'coral-framework';
import { I18n } from 'coral-framework';
import cn from 'classnames';
import translations from '../translations.json';
import {getMyActionSummary, getTotalActionCount} from 'coral-framework/utils';
import { getMyActionSummary, getTotalActionCount } from 'coral-framework/utils';
const lang = new I18n(translations);
const name = 'coral-plugin-like';
class LikeButton extends Component {
handleClick = () => {
const {postLike, showSignInDialog, deleteAction} = this.props;
const {root: {me}, comment} = this.props;
const { postLike, showSignInDialog, deleteAction } = this.props;
const { root: { me }, comment } = this.props;
const myLikeActionSummary = getMyActionSummary('LikeActionSummary', comment);
const myLikeActionSummary = getMyActionSummary(
'LikeActionSummary',
comment
);
// If the current user does not exist, trigger sign in dialog.
if (!me) {
@@ -37,10 +39,10 @@ class LikeButton extends Component {
item_type: 'COMMENTS'
});
}
}
};
render() {
const {comment} = this.props;
const { comment } = this.props;
if (!comment) {
return null;
@@ -52,10 +54,27 @@ class LikeButton extends Component {
return (
<div className={cn(styles.like, `${name}-container`)}>
<button
className={cn(styles.button, {[styles.liked]: myLike}, `${name}-button`)}
onClick={this.handleClick} >
<span className={`${name}-button-text`}>{lang.t(myLike ? 'liked' : 'like')}</span>
<i className={cn(styles.icon, 'material-icons', {[styles.liked]: myLike}, `${name}-icon`)} aria-hidden={true}>thumb_up</i>
className={cn(
styles.button,
{ [styles.liked]: myLike },
`${name}-button`
)}
onClick={this.handleClick}
>
<span className={`${name}-button-text`}>
{lang.t(myLike ? 'liked' : 'like')}
</span>
<i
className={cn(
styles.icon,
'material-icons',
{ [styles.liked]: myLike },
`${name}-icon`
)}
aria-hidden={true}
>
thumb_up
</i>
<span className={`${name}-count`}>{count > 0 && count}</span>
</button>
</div>