1- import React from 'react' ;
1+ import React , { SyntheticEvent } from 'react' ;
22import {
33 socialShareContent ,
44 shareButton ,
@@ -9,20 +9,21 @@ import {
99 listShareButton ,
1010 listSocialShareContent ,
1111 headerText ,
12+ customShareButton ,
1213} from './social-share.module.scss' ;
1314import { withWindowSize } from 'react-fns' ;
1415import { pxToNumber } from '../../helpers/styles-helper/styles-helper' ;
1516import { breakpointLg } from '../../variables.module.scss' ;
16- import { FacebookShareButton , TwitterShareButton , LinkedinShareButton , RedditShareButton , EmailShareButton } from 'react-share' ;
17- import globalConstants from '../../helpers/constants' ;
1817import Analytics from '../../utils/analytics/analytics' ;
1918import ShareButtonContent from './share-button-content/share-button-content' ;
2019import { FunctionComponent } from 'react' ;
2120import { ISocialShareComponent } from '../../models/ISocialShareComponent' ;
2221import SocialMetaData from './social-metadata/social-metadata' ;
2322import Heading from '../heading/heading' ;
24-
25- const baseUrl = globalConstants . BASE_SITE_URL ;
23+ import { redirectModalState } from '../../components/modal/redirect-modal/redirect-modal-helper' ;
24+ import { useSetRecoilState } from 'recoil' ;
25+ import { getLinkedInParams , getFacebookParams , getTwitterParams , getRedditParams } from './social-share-helper' ;
26+ import { EmailShareButton } from 'react-share' ;
2627
2728const analyticsClickHandler = ( page : string , social : string , explainer : boolean ) => {
2829 let gaCategory : string ;
@@ -53,6 +54,7 @@ export const SocialShareComponent: FunctionComponent<ISocialShareComponent> = ({
5354 explainer,
5455} ) => {
5556 const { title, description, body, emailSubject, emailBody, url, image } = copy ;
57+ const setModal = useSetRecoilState ( redirectModalState ) ;
5658
5759 let contentStyle = socialShareContent ;
5860 let containerStyle = shareButtonContainer ;
@@ -75,42 +77,73 @@ export const SocialShareComponent: FunctionComponent<ISocialShareComponent> = ({
7577 }
7678 } ;
7779
80+ const openModal = ( e : SyntheticEvent , url : string ) => {
81+ e . preventDefault ( ) ;
82+ setModal ( {
83+ open : true ,
84+ url,
85+ after : ( ) => {
86+ window . open ( url , '_blank' , 'noreferrer, noopener, width=650,height=600' ) ;
87+ } ,
88+ } ) ;
89+ } ;
90+
7891 return (
7992 < >
8093 < SocialMetaData image = { image } title = { title } description = { description } url = { url } />
81- < div className = { `${ contentStyle } socialShareContent` } >
94+ < div className = { `${ contentStyle } socialShareContent facebook ` } >
8295 { displayStyle === 'responsive' && width >= pxToNumber ( breakpointLg ) && (
8396 < Heading headingLevel = { headerLevel } className = { headerText } >
8497 Share this page
8598 </ Heading >
8699 ) }
87100 < div className = { containerStyle } >
88- < FacebookShareButton className = { `${ buttonStyle } facebookShare` } url = { url } quote = { body } beforeOnClick = { ( ) => handleClick ( 'Facebook' ) } >
101+ < button
102+ className = { `${ buttonStyle } ${ customShareButton } facebookShare` }
103+ aria-label = { 'facebook' }
104+ onClick = { e => {
105+ handleClick ( 'Facebook' ) ;
106+ openModal ( e , getFacebookParams ( 'facebook' , url ) ) ;
107+ } }
108+ >
89109 < ShareButtonContent name = "facebook" width = { width } displayStyle = { displayStyle } />
90- </ FacebookShareButton >
110+ </ button >
91111 </ div >
92112 < div className = { containerStyle } >
93- < TwitterShareButton className = { `${ buttonStyle } twitterShare` } url = { url } title = { body } beforeOnClick = { ( ) => handleClick ( 'Twitter' ) } >
113+ < button
114+ className = { `${ buttonStyle } ${ customShareButton } twitterShare` }
115+ aria-label = { 'twitter' }
116+ onClick = { e => {
117+ handleClick ( 'Twitter' ) ;
118+ openModal ( e , getTwitterParams ( 'twitter' , url , title ) ) ;
119+ } }
120+ >
94121 < ShareButtonContent name = "twitter" width = { width } displayStyle = { displayStyle } />
95- </ TwitterShareButton >
122+ </ button >
96123 </ div >
97124 < div className = { containerStyle } >
98- < LinkedinShareButton
99- className = { `${ buttonStyle } linkedInShare` }
100- url = { url }
101- title = { title }
102- summary = { body }
103- source = { baseUrl }
104- windowHeight = { 650 }
105- beforeOnClick = { ( ) => handleClick ( 'LinkedIn' ) }
125+ < button
126+ className = { `${ buttonStyle } ${ customShareButton } linkedInShare` }
127+ aria-label = { 'linkedin' }
128+ onClick = { e => {
129+ handleClick ( 'LinkedIn' ) ;
130+ openModal ( e , getLinkedInParams ( 'linkedin' , url , title ) ) ;
131+ } }
106132 >
107133 < ShareButtonContent name = "linkedin" width = { width } displayStyle = { displayStyle } />
108- </ LinkedinShareButton >
134+ </ button >
109135 </ div >
110136 < div className = { containerStyle } >
111- < RedditShareButton className = { `${ buttonStyle } redditShare` } url = { url } title = { title } beforeOnClick = { ( ) => handleClick ( 'Reddit' ) } >
137+ < button
138+ className = { `${ buttonStyle } ${ customShareButton } redditShare` }
139+ aria-label = { 'reddit' }
140+ onClick = { e => {
141+ handleClick ( 'Reddit' ) ;
142+ openModal ( e , getRedditParams ( 'reddit' , url , title ) ) ;
143+ } }
144+ >
112145 < ShareButtonContent name = "reddit" width = { width } displayStyle = { displayStyle } />
113- </ RedditShareButton >
146+ </ button >
114147 </ div >
115148 < div className = { containerStyle } >
116149 < EmailShareButton
0 commit comments