mirror of
https://github.com/wassname/talk.git
synced 2026-08-13 12:40:11 +08:00
Plugin now support statefull components
This commit is contained in:
@@ -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>
|
||||
);
|
||||
};
|
||||
@@ -11,4 +11,4 @@
|
||||
"transform-async-to-generator",
|
||||
"transform-react-jsx"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user