blob: 4f5ada913e67837e3c0e0bca209178be56a61241 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
const GitBook = require('gitbook-core');
const { React } = GitBook;
const SITES = require('../SITES');
const optionsShape = require('../shapes/options');
const SiteButton = require('./SiteButton');
const ShareButton = require('./ShareButton');
/**
* Displays the group of sharing buttons
*/
const SharingButtons = React.createClass({
propTypes: {
options: optionsShape.isRequired,
page: GitBook.PropTypes.Page.isRequired
},
onShare(site) {
site.onShare(location.href, this.props.page.title);
},
render() {
const { options } = this.props;
// Highlighted sites
const mainButtons = SITES
.ALL
.filter(id => options[id])
.map(id => <SiteButton key={id} onShare={this.onShare} site={SITES[id]} />);
// Other sites
let shareButton = undefined;
if (options.all.length > 0) {
shareButton = (
<ShareButton siteIds={options.all}
onShare={this.onShare} />
);
}
return (
<GitBook.ButtonGroup>
{ mainButtons }
{ shareButton }
</GitBook.ButtonGroup>
);
}
});
function mapStateToProps(state) {
let options = state.config.getIn(['pluginsConfig', 'sharing']);
if (options) {
options = options.toJS();
} else {
options = { all: [] };
}
return {
page: state.page,
options
};
}
module.exports = GitBook.connect(SharingButtons, mapStateToProps);
|