diff --git a/client/.eslintrc.json b/client/.eslintrc.json index 1144f985d..5735a91a1 100644 --- a/client/.eslintrc.json +++ b/client/.eslintrc.json @@ -4,21 +4,20 @@ "es6": true, "mocha": true }, - "extends": "../.eslintrc.json", "parserOptions": { + "sourceType": "module", "ecmaFeatures": { "experimentalObjectRestSpread": true, "jsx": true - }, - "sourceType": "module" + } }, "parser": "babel-eslint", "plugins": [ "react" ], "rules": { - "react/jsx-uses-react": "error", - "react/jsx-uses-vars": "error", - "no-console": ["warn", { "allow": ["warn", "error"] }] + "react/jsx-uses-react": "error", + "react/jsx-uses-vars": "error", + "no-console": ["warn", { "allow": ["warn", "error"] }] } } diff --git a/client/coral-framework/components/index.js b/client/coral-framework/components/index.js new file mode 100644 index 000000000..b7aaef665 --- /dev/null +++ b/client/coral-framework/components/index.js @@ -0,0 +1 @@ +export {default as Slot} from './Slot'; diff --git a/client/coral-framework/helpers/camelize.js b/client/coral-framework/helpers/camelize.js new file mode 100644 index 000000000..ffc09cebb --- /dev/null +++ b/client/coral-framework/helpers/camelize.js @@ -0,0 +1,16 @@ +const regExp = /[-\s]+(.)?/g; + +/** + * Convert dash separated strings to camel case. + * + * @param {String} str + * @return {String} + */ + +export default function camelize(str) { + return str.replace(regExp, toUpper); +} + +function toUpper(match, c) { + return c ? c.toUpperCase() : ''; +} diff --git a/client/coral-plugin-api/index.js b/client/coral-plugin-api/index.js deleted file mode 100644 index f0f5ad9cc..000000000 --- a/client/coral-plugin-api/index.js +++ /dev/null @@ -1 +0,0 @@ -export {withReaction} from '../coral-framework/hocs'; diff --git a/plugin-api/.babelrc b/plugin-api/.babelrc new file mode 100644 index 000000000..63b1c53de --- /dev/null +++ b/plugin-api/.babelrc @@ -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" + ] +} diff --git a/plugin-api/.eslintrc.json b/plugin-api/.eslintrc.json new file mode 100644 index 000000000..5735a91a1 --- /dev/null +++ b/plugin-api/.eslintrc.json @@ -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"] }] + } +} diff --git a/plugin-api/alpha/client/actions/index.js b/plugin-api/alpha/client/actions/index.js new file mode 100644 index 000000000..e523f2e35 --- /dev/null +++ b/plugin-api/alpha/client/actions/index.js @@ -0,0 +1,2 @@ +export {addTag, removeTag} from 'coral-plugin-commentbox/actions'; +export {addCommentClassName, removeCommentClassName} from 'coral-embed-stream/src/actions/comment'; diff --git a/plugin-api/client/actions/index.js b/plugin-api/client/actions/index.js new file mode 100644 index 000000000..e69de29bb diff --git a/plugin-api/client/components/index.js b/plugin-api/client/components/index.js new file mode 100644 index 000000000..5d76732fc --- /dev/null +++ b/plugin-api/client/components/index.js @@ -0,0 +1 @@ +export {Slot} from 'coral-framework/components'; diff --git a/plugin-api/client/hocs/index.js b/plugin-api/client/hocs/index.js new file mode 100644 index 000000000..7ec875656 --- /dev/null +++ b/plugin-api/client/hocs/index.js @@ -0,0 +1 @@ +export {withReaction} from 'coral-framework/hocs'; diff --git a/plugins/coral-plugin-offtopic/client/containers/OffTopicCheckbox.js b/plugins/coral-plugin-offtopic/client/containers/OffTopicCheckbox.js index 8566b10e4..2241f0510 100644 --- a/plugins/coral-plugin-offtopic/client/containers/OffTopicCheckbox.js +++ b/plugins/coral-plugin-offtopic/client/containers/OffTopicCheckbox.js @@ -1,6 +1,6 @@ import {connect} from 'react-redux'; import {bindActionCreators} from 'redux'; -import {addTag, removeTag} from 'coral-plugin-commentbox/actions'; +import {addTag, removeTag} from 'plugin-api/alpha/client/actions'; import OffTopicCheckbox from '../components/OffTopicCheckbox'; const mapStateToProps = ({commentBox}) => ({commentBox}); diff --git a/plugins/coral-plugin-offtopic/client/containers/OffTopicFilter.js b/plugins/coral-plugin-offtopic/client/containers/OffTopicFilter.js index 7870dab00..d334bec05 100644 --- a/plugins/coral-plugin-offtopic/client/containers/OffTopicFilter.js +++ b/plugins/coral-plugin-offtopic/client/containers/OffTopicFilter.js @@ -1,14 +1,16 @@ import {connect} from 'react-redux'; import {bindActionCreators} from 'redux'; import {toggleCheckbox} from '../actions'; +import OffTopicFilter from '../components/OffTopicFilter'; +import { + closeViewingOptions +} from 'plugins/coral-plugin-viewing-options/client/actions'; import { addCommentClassName, removeCommentClassName -} from 'coral-embed-stream/src/actions/comment'; -import OffTopicFilter from '../components/OffTopicFilter'; -import {closeViewingOptions} from 'plugins/coral-plugin-viewing-options/client/actions'; +} from 'plugin-api/alpha/client/actions'; -const mapStateToProps = ({comment, ['coral-plugin-offtopic'] : offTopic}) => ({ +const mapStateToProps = ({comment, ['coral-plugin-offtopic']: offTopic}) => ({ commentClassNames: comment.commentClassNames, checked: offTopic.checked }); diff --git a/plugins/coral-plugin-viewing-options/client/components/ViewingOptions.js b/plugins/coral-plugin-viewing-options/client/components/ViewingOptions.js index f76006c4e..5effa156b 100644 --- a/plugins/coral-plugin-viewing-options/client/components/ViewingOptions.js +++ b/plugins/coral-plugin-viewing-options/client/components/ViewingOptions.js @@ -2,7 +2,7 @@ import React from 'react'; import cn from 'classnames'; import {Icon} from 'coral-ui'; import styles from './ViewingOptions.css'; -import Slot from 'coral-framework/components/Slot'; +import {Slot} from 'plugin-api/client/components'; const ViewingOptions = (props) => { const toggleOpen = () => { diff --git a/webpack.config.js b/webpack.config.js index ddd2f9577..ce1e0bd29 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -154,6 +154,7 @@ const config = { }, resolve: { alias: { + 'plugin-api': path.resolve(__dirname, 'plugin-api/'), plugins: path.resolve(__dirname, 'plugins/'), pluginsConfig: pluginsConfigPath },