diff --git a/src/components/Share/index.js b/src/components/Share/index.js new file mode 100644 index 000000000..aa26cc3c8 --- /dev/null +++ b/src/components/Share/index.js @@ -0,0 +1,42 @@ +import React, { Component, PropTypes } from 'react'; +const Style = require('./style.scss'); +export default class Share extends Component { + + + static propTypes = { + surah: PropTypes.object.isRequired + }; + + + onClickPopup(url, title) { + window.open(url, title, 'width=670,height=540,scrollbars=no,toolbar=0'); + } + + render() { + + const {surahId, name} = this.props.surah; + const surahUrl = encodeURIComponent(`http://quran.com/${surahId}`); + + return ( +
+ + this.onClickPopup(`https://www.facebook.com/sharer/sharer.php?u=${surahUrl}`, 'Facebook')} + className={`${Style.iconContainer} ${Style.facebook}`} + data-metrics-event-name="Share:Facebook" + title="Share on Facebook" + > + + + this.onClickPopup(`https://twitter.com/intent/tweet?url=${surahUrl}&text=Surat ${name.simple}`, 'Twitter')} + className={`${Style.iconContainer} ${Style.twitter}`} + data-metrics-event-name="Share:Twitter" + title="Share on Twitter" + > + + +
+ ); + } +} diff --git a/src/components/Share/style.scss b/src/components/Share/style.scss new file mode 100644 index 000000000..00aaec617 --- /dev/null +++ b/src/components/Share/style.scss @@ -0,0 +1,34 @@ +.shareContainer { + position: relative; + bottom: 2px; + left: 5px; + + .iconContainer { + padding: 0 30px 10px 0; + } + + .facebook { + background-image: url(../../../static/images/FB-grn.png); + background-repeat: no-repeat; + + background-size: 12px; + padding-top: 1px; + + &:hover { + background-image: url(../../../static/images/FB-beige.png); + } + } + + .twitter { + background-image: url(../../../static/images/Twitter-grn.png); + background-repeat: no-repeat; + background-size: 21px; + + &:hover { + background-image: url(../../../static/images/Twitter-beige.png); + } + } + +} + + diff --git a/src/containers/Surah/index.js b/src/containers/Surah/index.js index 7e01fc4ef..9ec3a2a89 100644 --- a/src/containers/Surah/index.js +++ b/src/containers/Surah/index.js @@ -24,6 +24,7 @@ import Ayah from 'components/Ayah'; import Line from 'components/Line'; import SearchInput from 'components/SearchInput'; import Bismillah from 'components/Bismillah'; +import Share from 'components/Share'; // utils import scroller from 'utils/scroller'; @@ -407,7 +408,7 @@ export default class Surah extends Component { } renderTopOptions() { - const { toggleReadingMode, options } = this.props; // eslint-disable-line no-shadow + const { toggleReadingMode, options, surah } = this.props; // eslint-disable-line no-shadow return ( @@ -433,6 +434,9 @@ export default class Surah extends Component { onReadingModeToggle={toggleReadingMode} /> +
  • |
  • +
  • +
    diff --git a/src/helpers/Html.js b/src/helpers/Html.js index f2dc1b551..7160ebb24 100644 --- a/src/helpers/Html.js +++ b/src/helpers/Html.js @@ -18,6 +18,9 @@ const Html = ({ store, component, assets }) => { {head.script.toComponent()} {head.style.toComponent()} +