11import { Button , Modal , Stack } from '@iqss/dataverse-design-system'
22import { Facebook , Linkedin , TwitterX } from 'react-bootstrap-icons'
3- import styles from './ShareButton .module.scss'
3+ import styles from './ShareCollection .module.scss'
44
5- interface ShareModalProps {
5+ interface ShareCollectionModalProps {
66 show : boolean
77 handleClose : ( ) => void
88}
99
10- export const ShareModal = ( { show, handleClose } : ShareModalProps ) => {
10+ // TODO:ME - Add storybook
11+ // TODO:ME - Add component test to check url is correct
12+
13+ export const ShareCollectionModal = ( { show, handleClose } : ShareCollectionModalProps ) => {
14+ const currentUrl = window . location . href
15+
16+ const shareOnLinkedInURL = `https://www.linkedin.com/shareArticle?url=${ encodeURIComponent (
17+ currentUrl
18+ ) } `
19+
20+ const shareOnXURL = `https://twitter.com/intent/tweet?url=${ encodeURIComponent ( currentUrl ) } `
21+
22+ const shareOnFacebookURL = `https://www.facebook.com/sharer/sharer.php?u=${ encodeURIComponent (
23+ currentUrl
24+ ) } `
25+
1126 return (
1227 < Modal show = { show } onHide = { handleClose } centered >
1328 < Modal . Header >
@@ -19,27 +34,34 @@ export const ShareModal = ({ show, handleClose }: ShareModalProps) => {
1934 </ p >
2035
2136 < Stack direction = "horizontal" >
22- < button
23- type = "button"
24- aria-label = "LinkedIn"
37+ < a
38+ href = { shareOnLinkedInURL }
39+ target = "_blank"
40+ rel = "noreferrer"
2541 title = "LinkedIn"
42+ aria-label = "LinkedIn"
2643 className = { `${ styles [ 'social-btn' ] } ${ styles . linkedin } ` } >
2744 < Linkedin size = { 18 } />
28- </ button >
29- < button
30- type = "button"
31- aria-label = "X, formerly Twitter"
45+ </ a >
46+
47+ < a
48+ href = { shareOnXURL }
49+ target = "_blank"
50+ rel = "noreferrer"
3251 title = "X, formerly Twitter"
52+ aria-label = "X, formerly Twitter"
3353 className = { `${ styles [ 'social-btn' ] } ${ styles . x } ` } >
3454 < TwitterX size = { 18 } />
35- </ button >
36- < button
37- type = "button"
38- aria-label = "Facebook"
55+ </ a >
56+ < a
57+ href = { shareOnFacebookURL }
58+ target = "_blank"
59+ rel = "noreferrer"
3960 title = "Facebook"
61+ aria-label = "Facebook"
4062 className = { `${ styles [ 'social-btn' ] } ${ styles . fb } ` } >
4163 < Facebook size = { 18 } />
42- </ button >
64+ </ a >
4365 </ Stack >
4466 </ Modal . Body >
4567 < Modal . Footer >
0 commit comments