-
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.
Social shares on Buyer's Guide product pages (#1975)
Related to #1899 Covers - social shares on Buyer's Guide product pages Based on specs in #1899 (comment) but we might want to update the pre-populated text a bit though... /cc @kristinashu
- Loading branch information
Showing
4 changed files
with
49 additions
and
9 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
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
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 ${props.productName} is ${props.creepType.toUpperCase()}. 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" {...props} /> | ||
<SocialShareLink type="twitter" {...props} /> | ||
<SocialShareLink type="email" {...props} /> | ||
</div> | ||
}; | ||
|
||
export default SocialShare; |