Adds subscriber plugin

This commit is contained in:
Belen Curcio
2017-10-02 01:06:08 -03:00
parent 43cb0efe7e
commit 7aaad6ccd9
12 changed files with 136 additions and 0 deletions
@@ -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,23 @@
{
"env": {
"browser": true,
"es6": true,
"mocha": true
},
"parserOptions": {
"sourceType": "module",
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
}
},
"parser": "babel-eslint",
"plugins": [
"react"
],
"rules": {
"react/jsx-uses-react": "error",
"react/jsx-uses-vars": "error",
"no-console": ["warn", { "allow": ["warn", "error"] }]
}
}
@@ -0,0 +1,12 @@
.badge {
background-color: #616161;
color: white;
display: inline-block;
margin: 0px 5px;
padding: 5px 5px;
border-radius: 2px;
font-size: 12px;
text-transform: uppercase;
letter-spacing: 0.6px;
font-weight: bold;
}
@@ -0,0 +1,9 @@
import React from 'react';
import styles from './SubscriberBadge.css';
import {t} from 'plugin-api/beta/client/services';
export default () =>(
<span className={styles.badge}>
{t('talk-plugin-subscriber.subscriber')}
</span>
);
@@ -0,0 +1,24 @@
import React from 'react';
import SubscriberBadge from '../components/SubscriberBadge';
import {compose, gql} from 'react-apollo';
import {withFragments, excludeIf} from 'plugin-api/beta/client/hocs';
const isSubscriber = (tags = []) => tags.some((t) => t.tag.name === 'SUBSCRIBER');
const enhance = compose(
withFragments({
comment: gql`
fragment TalkSubscriberBadge_SubscriberBadge_comment on Comment {
user {
tags {
tag {
name
}
}
}
}`
}),
excludeIf(({comment}) => !isSubscriber(comment.user.tags))
);
export default enhance(SubscriberBadge);
@@ -0,0 +1,10 @@
import SubscriberBadge from './containers/SubscriberBadge';
import translations from './translations.yml';
import {gql} from 'react-apollo';
export default {
translations,
slots: {
commentAuthorTags: [SubscriberBadge]
}
};
@@ -0,0 +1,6 @@
en:
talk-plugin-subscriber:
subscriber: "Subscriber"
es:
talk-plugin-subscriber:
subscriber: "Subscriptor"