diff options
author | Soreine <nicolas@gitbook.com> | 2016-10-05 21:41:43 +0200 |
---|---|---|
committer | Soreine <nicolas@gitbook.com> | 2016-10-05 21:41:43 +0200 |
commit | 0614613b8414d62a6150e58f55a53c985a83937c (patch) | |
tree | defbf03c61a6e32e8baf80871b49791371d514ab | |
parent | 6faf6a53f08d65f7e51724911473ad1832dcb2ba (diff) | |
download | gitbook-0614613b8414d62a6150e58f55a53c985a83937c.zip gitbook-0614613b8414d62a6150e58f55a53c985a83937c.tar.gz gitbook-0614613b8414d62a6150e58f55a53c985a83937c.tar.bz2 |
Starting gitbook-plugin-sharing
-rw-r--r-- | packages/gitbook-plugin-sharing/.gitignore | 2 | ||||
-rw-r--r-- | packages/gitbook-plugin-sharing/.npmignore | 2 | ||||
-rw-r--r-- | packages/gitbook-plugin-sharing/package.json | 8 | ||||
-rw-r--r-- | packages/gitbook-plugin-sharing/src/index.js | 30 | ||||
-rw-r--r-- | packages/gitbook/package.json | 2 |
5 files changed, 35 insertions, 9 deletions
diff --git a/packages/gitbook-plugin-sharing/.gitignore b/packages/gitbook-plugin-sharing/.gitignore index 7c6f0eb..ef47881 100644 --- a/packages/gitbook-plugin-sharing/.gitignore +++ b/packages/gitbook-plugin-sharing/.gitignore @@ -28,4 +28,4 @@ node_modules *.swp # Plugin assets -_assets +_assets/plugin.js diff --git a/packages/gitbook-plugin-sharing/.npmignore b/packages/gitbook-plugin-sharing/.npmignore index 7bc36b7..a0e53cf 100644 --- a/packages/gitbook-plugin-sharing/.npmignore +++ b/packages/gitbook-plugin-sharing/.npmignore @@ -1,2 +1,2 @@ # Publish assets on NPM -!_assets +!_assets/plugin.js diff --git a/packages/gitbook-plugin-sharing/package.json b/packages/gitbook-plugin-sharing/package.json index 1519136..21fc038 100644 --- a/packages/gitbook-plugin-sharing/package.json +++ b/packages/gitbook-plugin-sharing/package.json @@ -1,9 +1,9 @@ { "name": "gitbook-plugin-sharing", - "description": "Sharing button in the toolbar", + "description": "Sharing buttons in the toolbar", "main": "index.js", - "browser": "./_assets/theme.js", - "version": "0.0.0", + "browser": "./_assets/plugin.js", + "version": "4.0.0", "dependencies": { "gitbook-core": "^0.0.0" }, @@ -14,7 +14,7 @@ "gitbook": ">=3.0.0" }, "scripts": { - "build-js": "gitbook-plugin build ./src/index.js ./_assets/theme.js", + "build-js": "gitbook-plugin build ./src/index.js ./_assets/plugin.js", "prepublish": "npm run build-js" }, "homepage": "https://github.com/GitbookIO/gitbook", 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 } +}) diff --git a/packages/gitbook/package.json b/packages/gitbook/package.json index 1b6c0ef..12b190a 100644 --- a/packages/gitbook/package.json +++ b/packages/gitbook/package.json @@ -29,7 +29,7 @@ "gitbook-plugin-livereload": "0.0.1", "gitbook-plugin-lunr": "1.2.0", "gitbook-plugin-search": "2.2.1", - "gitbook-plugin-sharing": "1.0.2", + "gitbook-plugin-sharing": "4.0.0", "gitbook-plugin-theme-default": "1.0.5", "gitbook-plugin-hints": "2.0.0", "github-slugid": "1.0.1", |