diff --git a/src/components/NewsLetterPopup.tsx b/src/components/NewsLetterPopup.tsx new file mode 100644 index 00000000..aef80069 --- /dev/null +++ b/src/components/NewsLetterPopup.tsx @@ -0,0 +1,95 @@ +import React, { useEffect, useState } from 'react'; + +const NewsletterPopup = () => { + const [showPopup, setShowPopup] = useState(false); + + useEffect(() => { + const hasSubscribed = localStorage.getItem('recodehive_newsletter_popup'); + + if (hasSubscribed !== 'true') { + const handleScroll = () => { + const scrollPosition = window.scrollY + window.innerHeight; + const pageHeight = document.body.scrollHeight; + + if ((scrollPosition / pageHeight) >= 0.8) { + setShowPopup(true); + window.removeEventListener('scroll', handleScroll); + } + }; + + window.addEventListener('scroll', handleScroll); + return () => window.removeEventListener('scroll', handleScroll); + } + }, []); + + const handleClose = () => { + setShowPopup(false); + localStorage.setItem('recodehive_newsletter_popup', 'true'); + }; + + if (!showPopup) return null; + + return ( +
+ Recodehive is an inclusive and welcoming platform where everyone can contribute,
+ learn, and grow together. ⚡
+ Check my ✨ Website: https://www.recodehive.com
+ 📮 How to reach me: github.com/sanjay-kv
+ 👫 Join my opensource community
+
+ By Sanjay Viswanathan · Over 31,000 subscribers +
+ + + ++ By subscribing, I agree to Substack’s{' '} + Terms of Use and acknowledge its{' '} + Information Collection Notice and{' '} + Privacy Policy. +
+ + +