diff --git a/src/common/playlists/PlayCard.jsx b/src/common/playlists/PlayCard.jsx index cd53dbd32f..f4ad450e19 100644 --- a/src/common/playlists/PlayCard.jsx +++ b/src/common/playlists/PlayCard.jsx @@ -2,6 +2,7 @@ import React from 'react'; import { Link } from 'react-router-dom'; import { BsPlayCircleFill } from 'react-icons/bs'; import { BiLogoTypescript, BiLogoJavascript } from 'react-icons/bi'; +import PlayShare from './PlayShare.jsx'; import Shimmer from 'react-shimmer-effect'; import Like from 'common/components/Like/Like'; @@ -42,11 +43,17 @@ function PlayCard({ play, cover, likeObject }) {
- {play.language === 'ts' ? ( - - ) : ( - - )} +
+ + {play.language === 'ts' ? ( + + ) : ( + + )} +
diff --git a/src/common/playlists/PlayShare.jsx b/src/common/playlists/PlayShare.jsx new file mode 100644 index 0000000000..63f9498157 --- /dev/null +++ b/src/common/playlists/PlayShare.jsx @@ -0,0 +1,124 @@ +import { useState } from 'react'; +import Box from '@mui/material/Box'; +import Modal from '@mui/material/Modal'; +import { IoShareOutline } from 'react-icons/io5'; +import { RxCross2 } from 'react-icons/rx'; +import { RiTwitterXLine } from 'react-icons/ri'; +import { LiaLinkedinIn } from 'react-icons/lia'; +import { PiCopySimpleDuotone, PiCopySimpleFill } from 'react-icons/pi'; + +const style = { + position: 'absolute', + top: '50%', + left: '50%', + transform: 'translate(-50%, -50%)', + width: '90%', + maxWidth: 488, + minHeight: 480, + maxHeight: '85%', + aspectRatio: 0.71, + bgcolor: 'white', + border: '1px solid #000', + borderRadius: '12px', + boxShadow: 24, + overflow: 'hidden' +}; + +function PlayShare({ cover, link }) { + const [showModal, setShowModal] = useState(false); + const [copied, setCopied] = useState(false); + + const closeHandler = (event) => { + event.preventDefault(); + setShowModal(false); + }; + + const linkOnClick = async (socialMedia) => { + const shareUrl = window.location.origin + link; + + switch (socialMedia) { + case 'x': + window + .open( + `https://x.com/intent/post?url=${shareUrl}&text=Check out my new React project built with learning from @ReactPlayIO!`, + '_blank' + ) + .focus(); + + break; + + case 'linkedin': + window + .open( + `https://www.linkedin.com/feed/?linkOrigin=LI_BADGE&shareActive=true&shareUrl=${shareUrl}&text=Check out my new React project built with learning from @ReactPlay!`, + '_blank' + ) + .focus(); + + break; + + case 'copy': + await navigator.clipboard.writeText(shareUrl); + setCopied(true); + + setTimeout(() => setCopied(false), 3000); + + break; + } + }; + + return ( +
e.preventDefault()}> + + +
+
+ +
+
+ +
+
+
+

+ Let others know through your social platforms +

+
+
linkOnClick('x')} + > + +
+
linkOnClick('linkedin')} + > + +
+
await linkOnClick('copy')} + > + {copied ? : } +
+
+
+
+
+ +
+ ); +} + +export default PlayShare;