-
Notifications
You must be signed in to change notification settings - Fork 372
Feature/341 social share #367
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| 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 ( | ||
| <div className={Style.share}> | ||
|
|
||
| <i | ||
| onClick={() => this.onClickPopup(`https://www.facebook.com/sharer/sharer.php?u=${surahUrl}`, 'Facebook')} | ||
| className={Style.facebook} | ||
| data-metrics-event-name="Share:Facebook" | ||
| title="Share on Facebook" | ||
| > | ||
| </i> | ||
|
|
||
| <i | ||
| onClick={() => this.onClickPopup(`https://twitter.com/intent/tweet?url=${surahUrl}&text=Surat ${name.simple}`, 'Twitter')} | ||
| className={Style.twitter} | ||
| data-metrics-event-name="Share:Twitter" | ||
| title="Share on Twitter" | ||
| > | ||
| </i> | ||
|
|
||
| </div> | ||
| ); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| .share { | ||
| position: relative; | ||
| bottom: 2px; | ||
| left: 5px; | ||
| } | ||
|
|
||
| .facebook { | ||
| background-image: url(../../../static/images/FB-grn.png); | ||
|
||
| background-repeat: no-repeat; | ||
| padding-right: 30px; | ||
| background-size: 12px; | ||
| padding-bottom: 10px; | ||
| 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; | ||
| padding-right: 30px; | ||
| background-size: 21px; | ||
| padding-bottom: 10px; | ||
|
|
||
| &:hover { | ||
| background-image: url(../../../static/images/Twitter-beige.png); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+0
It's great that U did not use any useless css attribute/property but we can improve code by using DRY principle and module specific css selector(that support future extension)
Some benefits of above approach:
.facebookselector.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
greats tips bro. I have since update the code to introduce font-awesome as @mmahalwy suggested. Please review again and let me know.
The project uses css-module, which doesn't lend it self to nested css.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, i did not get " css-module", i am thinking that we are using SCSS that support nesting, right?
http://sass-lang.com/guide#topic-3