-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from CoderSwarup/sharepost
feat: create a Share Post Feature
- Loading branch information
Showing
5 changed files
with
213 additions
and
18 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,134 @@ | ||
import { | ||
EmailShareButton, | ||
EmailIcon, | ||
FacebookShareButton, | ||
FacebookIcon, | ||
WhatsappShareButton, | ||
WhatsappIcon, | ||
TwitterShareButton, | ||
TwitterIcon, | ||
TelegramShareButton, | ||
TelegramIcon, | ||
} from "react-share"; | ||
import { | ||
Dialog, | ||
DialogContent, | ||
DialogHeader, | ||
DialogTitle, | ||
DialogTrigger, | ||
} from "@/components/ui/dialog"; | ||
import { Button } from "./button"; | ||
|
||
type ShareProps = { | ||
shareurl: string; | ||
handleShare: () => void; | ||
}; | ||
|
||
const Share = ({ shareurl, handleShare }: ShareProps) => { | ||
const data = [ | ||
{ | ||
label: "Facebook", | ||
icon: ( | ||
<FacebookShareButton url={shareurl}> | ||
<FacebookIcon size={30} round /> | ||
</FacebookShareButton> | ||
), | ||
}, | ||
|
||
{ | ||
label: "Whatsapp", | ||
icon: ( | ||
<WhatsappShareButton url={shareurl}> | ||
<WhatsappIcon size={30} round /> | ||
</WhatsappShareButton> | ||
), | ||
}, | ||
{ | ||
label: "Twitter", | ||
icon: ( | ||
<TwitterShareButton url={shareurl}> | ||
<TwitterIcon size={30} round /> | ||
</TwitterShareButton> | ||
), | ||
}, | ||
{ | ||
label: "Telegram", | ||
icon: ( | ||
<TelegramShareButton url={shareurl}> | ||
<TelegramIcon size={30} round /> | ||
</TelegramShareButton> | ||
), | ||
}, | ||
{ | ||
label: "Email", | ||
icon: ( | ||
<EmailShareButton url={shareurl}> | ||
<EmailIcon size={30} round /> | ||
</EmailShareButton> | ||
), | ||
}, | ||
]; | ||
|
||
return ( | ||
<Dialog> | ||
<DialogTrigger> | ||
<img | ||
className=" cursor-pointer" | ||
src={"/assets/icons/share.svg"} | ||
alt="share" | ||
width={24} | ||
height={24} | ||
tabIndex={0} | ||
onClick={handleShare} | ||
/> | ||
</DialogTrigger> | ||
<DialogContent> | ||
<DialogHeader> | ||
<DialogTitle>Share Link</DialogTitle> | ||
</DialogHeader> | ||
<div> | ||
<p className="text-md mb-4">Share this Post via</p> | ||
<div className="flex justify-between items-center flex-wrap gap-4"> | ||
{data.map((ele) => { | ||
return ( | ||
<div className="flex flex-col justify-between items-center gap-2 cursor-pointer"> | ||
{ele.icon} | ||
<span className="text-sm capitalize">{ele.label}</span> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
</div>{" "} | ||
<div> | ||
<p className="text-md mb-2">Or copy link</p> | ||
<p className="text-md mb-2 text-gray-500"> | ||
Anyone who has this link will be able to view this | ||
</p> | ||
<div className="flex justify-center align-center gap-1"> | ||
<input | ||
readOnly | ||
className=" border border-white-800 rounded-sm w-[100%] p-2 bg-[#000] outline-none" | ||
value={shareurl} | ||
></input> | ||
<Button | ||
className="bg-white" | ||
onClick={() => { | ||
window.navigator.clipboard.writeText(shareurl); | ||
}} | ||
> | ||
<img | ||
src={"/assets/icons/copy.svg"} | ||
alt="edit" | ||
width={20} | ||
height={20} | ||
className=" invert" // Add consistent spacing after the img tag | ||
/> | ||
</Button> | ||
</div> | ||
</div> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
}; | ||
|
||
export default Share; |