Plugin now support statefull components

This commit is contained in:
Belen Curcio
2017-03-30 22:10:24 -03:00
parent 1ee49f76f6
commit e1c4b69038
10 changed files with 64 additions and 25 deletions
+14
View File
@@ -0,0 +1,14 @@
{
"presets": [
"es2015"
],
"plugins": [
"add-module-exports",
"transform-class-properties",
"transform-decorators-legacy",
"transform-object-assign",
"transform-object-rest-spread",
"transform-async-to-generator",
"transform-react-jsx"
]
}
@@ -0,0 +1,4 @@
{
"name": "Coral Plugin Love",
"slot": "Comment.Detail"
}
@@ -0,0 +1,7 @@
import React from 'react';
export default () => {
return (
<div>Love</div>
);
};
View File
+1 -1
View File
@@ -11,4 +11,4 @@
"transform-async-to-generator",
"transform-react-jsx"
]
}
}
+26 -17
View File
@@ -4,27 +4,36 @@ import Icon from './components/Icon';
import {getActionSummary} from 'coral-framework/utils';
export default (props) => {
const {comment} = props.context;
class RespectButton extends React.Component {
constructor(props) {
super(props);
}
const handleClick = () => {
props.context.postRespect({
handleClick = () => {
const {comment} = this.props.context;
this.props.context.postRespect({
item_id: comment.id,
item_type: 'COMMENTS'
});
};
}
render() {
const {comment} = this.props.context;
const respectActionSummary = getActionSummary('RespectActionSummary', comment);
const respectActionSummary = getActionSummary('RespectActionSummary', comment);
return (
<div className={styles.Respect}>
<button
onClick={this.handleClick}>
Respect
<Icon />
{respectActionSummary ? <span>{respectActionSummary.count}</span> : null}
</button>
</div>
);
}
}
return (
<div className={styles.Respect} key={props.key}>
<button
onClick={handleClick}>
Respect
<Icon />
{respectActionSummary ? <span>{respectActionSummary.count}</span> : null}
</button>
</div>
);
};
export default RespectButton;