1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00
onion/js/components/ascribe_social_share/twitter_share_button.js

57 lines
1.4 KiB
JavaScript
Raw Normal View History

2015-11-09 19:01:27 +01:00
'use strict';
import React from 'react';
2016-05-09 11:12:46 +02:00
import ReactDOM from 'react-dom';
2015-11-09 19:01:27 +01:00
import AppConstants from '../../constants/application_constants';
import { InjectInHeadUtils } from '../../utils/inject_utils';
let TwitterShareButton = React.createClass({
propTypes: {
count: React.PropTypes.string,
counturl: React.PropTypes.string,
hashtags: React.PropTypes.string,
size: React.PropTypes.string,
text: React.PropTypes.string,
url: React.PropTypes.string,
via: React.PropTypes.string
},
getDefaultProps() {
return {
2015-11-10 19:33:08 +01:00
count: 'none',
via: 'ascribeIO'
2015-11-09 19:01:27 +01:00
};
},
componentDidMount() {
InjectInHeadUtils.inject(AppConstants.twitter.sdkUrl).then(this.loadTwitterButton);
},
loadTwitterButton() {
const { count, counturl, hashtags, size, text, url, via } = this.props;
2016-05-09 11:12:46 +02:00
twttr.widgets.createShareButton(url, ReactDOM.findDOMNode(this.refs.twitterShareButton), {
2015-11-09 19:01:27 +01:00
count,
counturl,
hashtags,
size,
text,
via,
dnt: true // Do not track
});
},
render() {
return (
<span
ref="twitterShareButton"
className="btn btn-ascribe-social">
</span>
);
}
});
export default TwitterShareButton;