From c680d42000722bd5c33c3b1742462f7502a61772 Mon Sep 17 00:00:00 2001 From: Samridha0305 Date: Tue, 29 Jul 2025 10:45:22 +0530 Subject: [PATCH 1/3] Add Professional, Elegant Newsletter Popup with Scroll Trigger --- src/components/NewsLetterPopup.tsx | 95 ++++++++++++++++++++++++++++++ src/theme/Layout.tsx | 18 ++++-- 2 files changed, 107 insertions(+), 6 deletions(-) create mode 100644 src/components/NewsLetterPopup.tsx 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 Logo + +

Sanjay’s Substack

+ +

+ 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 +

+ +
{ + e.preventDefault(); + alert('Subscribed! (Integrate with Substack API)'); + handleClose(); + }} + > + + +
+ +

+ By subscribing, I agree to Substack’s{' '} + Terms of Use and acknowledge its{' '} + Information Collection Notice and{' '} + Privacy Policy. +

+ + +
+
+ ); +}; + +export default NewsletterPopup; diff --git a/src/theme/Layout.tsx b/src/theme/Layout.tsx index afccc538..7240a985 100644 --- a/src/theme/Layout.tsx +++ b/src/theme/Layout.tsx @@ -1,12 +1,18 @@ import React from "react"; import Layout from "@theme-original/Layout"; import NavbarFirebaseAuthGithub from "@site/src/components/ui/NavbarFirebaseAuthGithub"; +import NewsletterPopup from "@site/src/components/NewsletterPopup"; + + +export default function CustomLayout({ children, ...props }) { -export default function CustomLayout(props) { return ( - // <> - - // - // - ); + <> + + + {children} + + + +); } \ No newline at end of file From 30a04dc045341ebb8cd6e5d40128bf089eda537f Mon Sep 17 00:00:00 2001 From: Samridha0305 Date: Tue, 29 Jul 2025 16:09:36 +0530 Subject: [PATCH 2/3] fix: correct NewsletterPopup import path) --- src/theme/Layout.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/theme/Layout.tsx b/src/theme/Layout.tsx index 7240a985..f0a1faee 100644 --- a/src/theme/Layout.tsx +++ b/src/theme/Layout.tsx @@ -1,7 +1,8 @@ import React from "react"; import Layout from "@theme-original/Layout"; import NavbarFirebaseAuthGithub from "@site/src/components/ui/NavbarFirebaseAuthGithub"; -import NewsletterPopup from "@site/src/components/NewsletterPopup"; +import NewsletterPopup from '../components/NewsletterPopup'; + export default function CustomLayout({ children, ...props }) { From 0f48562f67575ff63d344596de0435b15d4e58e4 Mon Sep 17 00:00:00 2001 From: Samridha0305 Date: Tue, 29 Jul 2025 20:37:06 +0530 Subject: [PATCH 3/3] removed error --- src/theme/Layout.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/theme/Layout.tsx b/src/theme/Layout.tsx index f0a1faee..74ff1a7a 100644 --- a/src/theme/Layout.tsx +++ b/src/theme/Layout.tsx @@ -1,7 +1,7 @@ import React from "react"; import Layout from "@theme-original/Layout"; import NavbarFirebaseAuthGithub from "@site/src/components/ui/NavbarFirebaseAuthGithub"; -import NewsletterPopup from '../components/NewsletterPopup'; +import NewsletterPopup from '../components/NewsLetterPopup';