summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-plugin-sharing/src
diff options
context:
space:
mode:
authorSoreine <nicolas@gitbook.com>2016-10-05 21:41:43 +0200
committerSoreine <nicolas@gitbook.com>2016-10-05 21:41:43 +0200
commit0614613b8414d62a6150e58f55a53c985a83937c (patch)
treedefbf03c61a6e32e8baf80871b49791371d514ab /packages/gitbook-plugin-sharing/src
parent6faf6a53f08d65f7e51724911473ad1832dcb2ba (diff)
downloadgitbook-0614613b8414d62a6150e58f55a53c985a83937c.zip
gitbook-0614613b8414d62a6150e58f55a53c985a83937c.tar.gz
gitbook-0614613b8414d62a6150e58f55a53c985a83937c.tar.bz2
Starting gitbook-plugin-sharing
Diffstat (limited to 'packages/gitbook-plugin-sharing/src')
-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 }
+})