1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 17:33:14 +01:00

Add Twitter button

This commit is contained in:
Brett Sun 2015-11-09 19:01:27 +01:00
parent d972da935a
commit 8dc0470007
6 changed files with 68 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import Glyphicon from 'react-bootstrap/lib/Glyphicon';
import MediaPlayer from './../ascribe_media/media_player';
import FacebookShareButton from '../ascribe_social_share/facebook_share_button';
import TwitterShareButton from '../ascribe_social_share/twitter_share_button';
import CollapsibleButton from './../ascribe_collapsible/collapsible_button';
@ -98,6 +99,7 @@ let MediaContainer = React.createClass({
</Button>
</AclProxy>
<FacebookShareButton />
<TwitterShareButton />
{embed}
</p>
</div>

View File

@ -40,8 +40,7 @@ let FacebookShareButton = React.createClass({
return (
<span
ref="fbShareButton"
style={{width: '56px', height: '24px'}}
className="fb-share-button btn btn-xs"
className="fb-share-button btn btn-ascribe-social"
data-href={this.props.url}
data-layout={this.props.type}>
</span>

View File

@ -0,0 +1,54 @@
'use strict';
import React from 'react';
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 {
count: 'none'
};
},
componentDidMount() {
InjectInHeadUtils.inject(AppConstants.twitter.sdkUrl).then(this.loadTwitterButton);
},
loadTwitterButton() {
const { count, counturl, hashtags, size, text, url, via } = this.props;
twttr.widgets.createShareButton(url, this.refs.twitterShareButton.getDOMNode(), {
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;

View File

@ -79,6 +79,9 @@ let constants = {
'appId': '420813844732240',
'sdkUrl': '//connect.facebook.net/en_US/sdk.js'
},
'twitter': {
'sdkUrl': 'https://platform.twitter.com/widgets.js'
},
'copyrightAssociations': ['ARS', 'DACS', 'Bildkunst', 'Pictoright', 'SODRAC', 'Copyright Agency/Viscopy', 'SAVA',
'Bildrecht GmbH', 'SABAM', 'AUTVIS', 'CREAIMAGEN', 'SONECA', 'Copydan', 'EAU', 'Kuvasto', 'GCA', 'HUNGART',
'IVARO', 'SIAE', 'JASPAR-SPDA', 'AKKA/LAA', 'LATGA-A', 'SOMAAP', 'ARTEGESTION', 'CARIER', 'BONO', 'APSAV',

View File

@ -0,0 +1,7 @@
.btn-ascribe-social {
height: 20px;
width: 56px;
box-sizing: content-box; /* We want to ignore padding in these calculations as we use the sdk buttons' height and width */
margin-left: 5px;
padding: 1px 0;
}

View File

@ -31,6 +31,7 @@ $BASE_URL: '<%= BASE_URL %>';
@import 'offset_right';
@import 'ascribe_settings';
@import 'ascribe_slides_container';
@import 'ascribe_social_share';
@import 'ascribe_property';
@import 'ascribe_form';
@import 'ascribe_panel';