forked from hodcroftlab/covariants
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add social media sharing buttons
- Loading branch information
1 parent
5567153
commit aa5373a
Showing
5 changed files
with
166 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import React from 'react' | ||
|
||
import urljoin from 'url-join' | ||
import { useRouter } from 'next/router' | ||
|
||
import { | ||
EmailIcon, | ||
EmailShareButton, | ||
FacebookIcon, | ||
FacebookShareButton, | ||
LinkedinIcon, | ||
LinkedinShareButton, | ||
TwitterIcon, | ||
TwitterShareButton, | ||
VKIcon, | ||
VKShareButton, | ||
WeiboIcon, | ||
WeiboShareButton, | ||
WhatsappIcon, | ||
WhatsappShareButton, | ||
} from 'react-share' | ||
|
||
import { | ||
DOMAIN, | ||
FACEBOOK_HASHTAG, | ||
PROJECT_NAME, | ||
TWITTER_HASHTAGS, | ||
TWITTER_RELATED, | ||
TWITTER_USERNAME_RAW, | ||
} from 'src/constants' | ||
import styled from 'styled-components' | ||
import { Col, Row } from 'reactstrap' | ||
|
||
const SOCIAL_ICON_SIZE = 30 | ||
|
||
const SharingPanelH1 = styled.h1` | ||
font-size: 1.33rem; | ||
margin: 15px auto; | ||
` | ||
|
||
const SharingPanelWrapper = styled.aside` | ||
margin: 0 auto 15px; | ||
` | ||
|
||
const SharingButton = styled.span` | ||
margin: 3px; | ||
& > button, | ||
& > button > svg { | ||
width: ${SOCIAL_ICON_SIZE}px; | ||
height: ${SOCIAL_ICON_SIZE}px; | ||
border-radius: ${SOCIAL_ICON_SIZE / 2}px; | ||
} | ||
` | ||
|
||
export function SharingPanel() { | ||
const { asPath } = useRouter() | ||
const url = urljoin(DOMAIN, asPath) | ||
|
||
return ( | ||
<Row noGutters> | ||
<Col> | ||
<Row noGutters> | ||
<Col className="d-flex text-center"> | ||
<SharingPanelH1>{'Share'}</SharingPanelH1> | ||
</Col> | ||
</Row> | ||
|
||
<Row noGutters> | ||
<Col className="d-flex"> | ||
<SharingPanelWrapper> | ||
<SharingButton title={'Send in an Email'}> | ||
<EmailShareButton url={url} subject={PROJECT_NAME} body={`\n${url}\n`}> | ||
<EmailIcon size={SOCIAL_ICON_SIZE} /> | ||
</EmailShareButton> | ||
</SharingButton> | ||
|
||
<SharingButton title={'Share on Twitter'}> | ||
<TwitterShareButton | ||
url={url} | ||
title={PROJECT_NAME} | ||
via={TWITTER_USERNAME_RAW} | ||
hashtags={TWITTER_HASHTAGS} | ||
related={TWITTER_RELATED} | ||
> | ||
<TwitterIcon size={SOCIAL_ICON_SIZE} /> | ||
</TwitterShareButton> | ||
</SharingButton> | ||
|
||
<SharingButton title={'Share on Facebook'}> | ||
<FacebookShareButton url={url} quote={PROJECT_NAME} hashtag={FACEBOOK_HASHTAG}> | ||
<FacebookIcon size={SOCIAL_ICON_SIZE} /> | ||
</FacebookShareButton> | ||
</SharingButton> | ||
|
||
<SharingButton title={'Share on WhatsApp'}> | ||
<WhatsappShareButton url={url} title={PROJECT_NAME}> | ||
<WhatsappIcon size={SOCIAL_ICON_SIZE} /> | ||
</WhatsappShareButton> | ||
</SharingButton> | ||
|
||
<SharingButton title={'Share on LinkedIn'}> | ||
<LinkedinShareButton url={url} title={PROJECT_NAME}> | ||
<LinkedinIcon size={SOCIAL_ICON_SIZE} /> | ||
</LinkedinShareButton> | ||
</SharingButton> | ||
|
||
<SharingButton title={'Share on VK'}> | ||
<VKShareButton url={url} title={PROJECT_NAME}> | ||
<VKIcon size={SOCIAL_ICON_SIZE} /> | ||
</VKShareButton> | ||
</SharingButton> | ||
|
||
<SharingButton title={'Share on Weibo'}> | ||
<WeiboShareButton url={url} title={PROJECT_NAME}> | ||
<WeiboIcon size={SOCIAL_ICON_SIZE} /> | ||
</WeiboShareButton> | ||
</SharingButton> | ||
</SharingPanelWrapper> | ||
</Col> | ||
</Row> | ||
</Col> | ||
</Row> | ||
) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2318,6 +2318,11 @@ | |
resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.3.tgz#9c088679876f374eb5983f150d4787aa6fb32d7e" | ||
integrity sha512-FvUupuM3rlRsRtCN+fDudtmytGO6iHJuuRKS1Ss0pG5z8oX0diNEw94UEL7hgDbpN94rgaK5R7sWm6RrSkZuAQ== | ||
|
||
"@types/[email protected]": | ||
version "4.0.0" | ||
resolved "https://registry.yarnpkg.com/@types/url-join/-/url-join-4.0.0.tgz#72eff71648a429c7d4acf94e03780e06671369bd" | ||
integrity sha512-awrJu8yML4E/xTwr2EMatC+HBnHGoDxc2+ImA9QyeUELI1S7dOCIZcyjki1rkwoA8P2D2NVgLAJLjnclkdLtAw== | ||
|
||
"@types/webpack-sources@*": | ||
version "2.1.0" | ||
resolved "https://registry.yarnpkg.com/@types/webpack-sources/-/webpack-sources-2.1.0.tgz#8882b0bd62d1e0ce62f183d0d01b72e6e82e8c10" | ||
|
@@ -4734,7 +4739,7 @@ data-urls@^2.0.0: | |
whatwg-mimetype "^2.3.0" | ||
whatwg-url "^8.0.0" | ||
|
||
[email protected], debug@^2.2.0, debug@^2.3.3, debug@^2.6.9: | ||
[email protected], debug@^2.1.3, debug@^2.2.0, debug@^2.3.3, debug@^2.6.9: | ||
version "2.6.9" | ||
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" | ||
integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== | ||
|
@@ -8266,6 +8271,13 @@ jsonfile@^6.0.1: | |
optionalDependencies: | ||
graceful-fs "^4.1.6" | ||
|
||
jsonp@^0.2.1: | ||
version "0.2.1" | ||
resolved "https://registry.yarnpkg.com/jsonp/-/jsonp-0.2.1.tgz#a65b4fa0f10bda719a05441ea7b94c55f3e15bae" | ||
integrity sha1-pltPoPEL2nGaBUQep7lMVfPhW64= | ||
dependencies: | ||
debug "^2.1.3" | ||
|
||
jsprim@^1.2.2: | ||
version "1.4.1" | ||
resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" | ||
|
@@ -10795,6 +10807,14 @@ react-resize-detector@^4.2.1: | |
raf-schd "^4.0.2" | ||
resize-observer-polyfill "^1.5.1" | ||
|
||
[email protected]: | ||
version "4.3.1" | ||
resolved "https://registry.yarnpkg.com/react-share/-/react-share-4.3.1.tgz#2eac80bc5e3f1c6d83c7315342db1fd2f21009d3" | ||
integrity sha512-ikh0y8NKxhU7dQBXh1Jccd1ANLb9WNYaSonln33yLyNYo2HTBRp9D6HkTsFlgX/2J9GPsGLqhzzpDNiVKx3WVA== | ||
dependencies: | ||
classnames "^2.2.5" | ||
jsonp "^0.2.1" | ||
|
||
react-side-effect@^2.1.0: | ||
version "2.1.1" | ||
resolved "https://registry.yarnpkg.com/react-side-effect/-/react-side-effect-2.1.1.tgz#66c5701c3e7560ab4822a4ee2742dee215d72eb3" | ||
|
@@ -13139,6 +13159,11 @@ urix@^0.1.0: | |
resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72" | ||
integrity sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI= | ||
|
||
[email protected]: | ||
version "4.0.1" | ||
resolved "https://registry.yarnpkg.com/url-join/-/url-join-4.0.1.tgz#b642e21a2646808ffa178c4c5fda39844e12cde7" | ||
integrity sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA== | ||
|
||
[email protected]: | ||
version "4.1.0" | ||
resolved "https://registry.yarnpkg.com/url-loader/-/url-loader-4.1.0.tgz#c7d6b0d6b0fccd51ab3ffc58a78d32b8d89a7be2" | ||
|