summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-plugin-sharing/src/components/SiteButton.js
blob: e03720d69f111fcb69a62e6bf1299e1984b01359 (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
const GitBook = require('gitbook-core');
const { React } = GitBook;

const siteShape = require('../shapes/site');

// An individual site sharing button
const SiteButton = React.createClass({
    propTypes: {
        site: siteShape.isRequired,
        onShare: React.PropTypes.func.isRequired
    },

    onClick(e) {
        e.preventDefault();
        this.props.onShare(this.props.site);
    },

    render() {
        const { site } = this.props;

        return (
            <GitBook.Button onClick={this.onClick}>
                <GitBook.Icon id={site.icon}/>
            </GitBook.Button>
        );
    }
});

module.exports = SiteButton;