From 6df0299d28057937afb1b7e5468fc3ad629beccb Mon Sep 17 00:00:00 2001 From: "sadaf H." <69013037+saddafdev@users.noreply.github.com> Date: Sat, 2 Dec 2023 18:43:12 +0500 Subject: [PATCH] Add social media share buttons to Quote component --- src/App.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/App.js b/src/App.js index 92b83a316..4533f826b 100644 --- a/src/App.js +++ b/src/App.js @@ -36,7 +36,31 @@ const App = () => { > ) -} + const Quote = ({ quote, author }) => { + const shareOnWhatsApp = () => { + const text = encodeURIComponent(`"${quote}" - ${author}`); + window.open(`https://api.whatsapp.com/send?text=${text}`); + }; + + const shareOnTwitter = () => { + const text = encodeURIComponent(`"${quote}" - ${author}`); + window.open(`https://twitter.com/intent/tweet?text=${text}`); + }; + + return ( +
+ ); + }; + } + export default App;