summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-plugin-sharing/src/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/gitbook-plugin-sharing/src/index.js')
-rw-r--r--packages/gitbook-plugin-sharing/src/index.js30
1 files changed, 28 insertions, 2 deletions
diff --git a/packages/gitbook-plugin-sharing/src/index.js b/packages/gitbook-plugin-sharing/src/index.js
index e3ffdfb..4821de2 100644
--- a/packages/gitbook-plugin-sharing/src/index.js
+++ b/packages/gitbook-plugin-sharing/src/index.js
@@ -1,8 +1,34 @@
const GitBook = require('gitbook-core');
+const { React } = GitBook;
module.exports = GitBook.createPlugin({
- activate: (dispatch, getState) => {
-
+ activate: (dispatch, getState, { Components }) => {
+ // Dispatch initialization actions
+ dispatch(Components.registerComponent(SharingButton, { role: 'toolbar:buttons:right' }))
+ },
+ deactivate: (dispatch, getState) => {
+ // Dispatch cleanup actions
},
reduce: (state, action) => state
});
+
+let SharingButton = React.createClass({
+ propTypes: {
+ page: GitBook.Shapes.Page
+ },
+
+ onClick() {
+ alert(this.props.page.title)
+ },
+
+ render() {
+ return (
+ <GitBook.Button onClick={this.onClick}>
+ <GitBook.Icon id="facebook"/>
+ </GitBook.Button>
+ )
+ }
+})
+SharingButton = GitBook.connect(SharingButton, function mapStateToProps(state) {
+ return { page: state.page }
+})