Skip to content

Commit 8d8f631

Browse files
committed
feat: use links instead of buttons
1 parent 22f8b3e commit 8d8f631

File tree

5 files changed

+46
-21
lines changed

5 files changed

+46
-21
lines changed

index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
<link rel="apple-touch-icon" href="/logo192.png" />
1010
<link rel="manifest" href="/manifest.json" />
1111
<title>Dataverse</title>
12+
13+
<!-- TODO:ME Basics meta tags for socials x, linkdin, facebook -->
14+
<!-- TODO:ME Check page that analyse metadata tags -->
1215
</head>
1316
<body>
1417
<noscript>You need to enable JavaScript to run this app.</noscript>

src/sections/collection/Collection.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { CollectionSkeleton } from './CollectionSkeleton'
1414
import { PageNotFound } from '../page-not-found/PageNotFound'
1515
import { CreatedAlert } from './CreatedAlert'
1616
import { PublishCollectionButton } from './publish-collection/PublishCollectionButton'
17-
import { ShareButton } from './share-button/ShareButton'
17+
import { ShareCollectionButton } from './share-collection/ShareCollectionButton'
1818
import styles from './Collection.module.scss'
1919

2020
interface CollectionProps {
@@ -82,7 +82,7 @@ export function Collection({
8282
{/* 👇 Here should go Contact button also */}
8383
{/* <ContactButton /> */}
8484

85-
<ShareButton />
85+
<ShareCollectionButton />
8686
</div>
8787

8888
{showPublishButton && (

src/sections/collection/share-button/ShareButton.module.scss renamed to src/sections/collection/share-collection/ShareCollection.module.scss

File renamed without changes.

src/sections/collection/share-button/ShareButton.tsx renamed to src/sections/collection/share-collection/ShareCollectionButton.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { useState } from 'react'
22
import { Button, Tooltip } from '@iqss/dataverse-design-system'
33
import { ShareFill } from 'react-bootstrap-icons'
4-
import { ShareModal } from './ShareModal'
5-
import styles from './ShareButton.module.scss'
4+
import { ShareCollectionModal } from './ShareCollectionModal'
5+
import styles from './ShareCollection.module.scss'
66

7-
export const ShareButton = () => {
7+
export const ShareCollectionButton = () => {
88
const [showShareModal, setShowShareModal] = useState(false)
99

1010
const openShareModal = () => setShowShareModal(true)
@@ -22,7 +22,7 @@ export const ShareButton = () => {
2222
</Button>
2323
</Tooltip>
2424

25-
<ShareModal show={showShareModal} handleClose={closeShareModal} />
25+
<ShareCollectionModal show={showShareModal} handleClose={closeShareModal} />
2626
</>
2727
)
2828
}

src/sections/collection/share-button/ShareModal.tsx renamed to src/sections/collection/share-collection/ShareCollectionModal.tsx

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
11
import { Button, Modal, Stack } from '@iqss/dataverse-design-system'
22
import { 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

Comments
 (0)