blob: 5a6cd6ebdd2f001be4a746b8e9fe182c8a6396ac (
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
|
const GitBook = require('gitbook-core');
const { React, Dropdown } = GitBook;
const SITES = require('../SITES');
// Share button with dropdown list of sites
const ShareButton = React.createClass({
propTypes: {
siteIds: React.PropTypes.arrayOf(React.PropTypes.string).isRequired,
onShare: React.PropTypes.func.isRequired
},
getInitialState() {
return { open: false };
},
onToggle() {
this.setState({ open: !this.state.open });
},
render() {
const { siteIds, onShare } = this.props;
const items = siteIds.map((id) => (
<Dropdown.Item onClick={() => onShare(SITES[id])} key={id}>
{SITES[id].label}
</Dropdown.Item>
));
return (
<Dropdown.Container>
<GitBook.Button onClick={this.onToggle}>
<GitBook.Icon id="share-alt" />
</GitBook.Button>
<Dropdown.Menu open={this.state.open}>
{items}
</Dropdown.Menu>
</Dropdown.Container>
);
}
});
module.exports = ShareButton;
|