-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Related to #1899 - social shares on Buyer's Guide product pages
- Loading branch information
Showing
2 changed files
with
56 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
source/js/buyers-guide/components/social-share/social-share.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react'; | ||
|
||
const SocialShareLink = (props) => { | ||
let classes = `social-button`; | ||
let srLabel = ``; | ||
let link = `PrivacyNotINcluded.org`; | ||
let shareText = `I think this product is ${props.creepType}. What do you think? Check out the Creep-O-Meter over on @mozilla’s ${link} holiday buyer’s guide.`; | ||
|
||
switch (props.type) { | ||
case 'facebook': | ||
classes += " social-button-fb"; | ||
srLabel = `Facebook`; | ||
link = `https://www.facebook.com/sharer/sharer.php?u=https://${link}`; | ||
|
||
break; | ||
case 'twitter': | ||
classes += " social-button-twitter"; | ||
srLabel = `Twitter`; | ||
link = `https://twitter.com/intent/tweet?text=${encodeURIComponent(shareText)}`; | ||
|
||
break; | ||
case 'email': | ||
classes += " social-button-email"; | ||
srLabel = `Email`; | ||
link = `mailto:?&body=${encodeURIComponent(shareText)}`; | ||
|
||
break; | ||
} | ||
|
||
return <a className={classes} href={link}><span class="sr-only">{srLabel}</span></a>; | ||
}; | ||
|
||
const SocialShare = (props) => { | ||
return <div class="social d-flex justify-content-center mt-3"> | ||
<SocialShareLink type="facebook" creepType={props.creepType} /> | ||
<SocialShareLink type="twitter" creepType={props.creepType} /> | ||
<SocialShareLink type="email" creepType={props.creepType} /> | ||
</div> | ||
} | ||
|
||
export default SocialShare; |