From aabaaec6996a7fe5881bb511a7a72252d0f74499 Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Tue, 1 Jul 2025 16:57:15 +0100 Subject: [PATCH] Banner should be visible on top --- src/components/SQLCourseVariant/PurchaseBanner.tsx | 13 ++++++++----- src/components/SQLCourseVariant/ReviewCarousel.tsx | 2 +- .../SQLCourseVariant/SQLCourseVariantPage.tsx | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/components/SQLCourseVariant/PurchaseBanner.tsx b/src/components/SQLCourseVariant/PurchaseBanner.tsx index ab1a9bcbd..c8a2f7b11 100644 --- a/src/components/SQLCourseVariant/PurchaseBanner.tsx +++ b/src/components/SQLCourseVariant/PurchaseBanner.tsx @@ -7,17 +7,20 @@ import { useEffect, useRef, useState } from 'react'; export function PurchaseBanner() { const bannerRef = useRef(null); - const [isOutOfView, setIsOutOfView] = useState(false); + const [isFullyInView, setIsFullyInView] = useState(false); useEffect(() => { const handleScroll = () => { if (!bannerRef.current) return; const bannerRect = bannerRef.current.getBoundingClientRect(); + const bannerTop = bannerRect.top; const bannerBottom = bannerRect.bottom; + const scrollTop = window.scrollY; - // Banner is out of view when its bottom is above the viewport - setIsOutOfView(bannerBottom < 0); + // Banner is fully in view when both top and bottom are within viewport + const fullyVisible = bannerTop >= 0 && bannerBottom <= window.innerHeight; + setIsFullyInView(fullyVisible || scrollTop > bannerRect.top); }; window.addEventListener('scroll', handleScroll); @@ -36,7 +39,7 @@ export function PurchaseBanner() {
@@ -77,7 +80,7 @@ export function PurchaseBanner() { diff --git a/src/components/SQLCourseVariant/ReviewCarousel.tsx b/src/components/SQLCourseVariant/ReviewCarousel.tsx index 6412ad1de..03c368867 100644 --- a/src/components/SQLCourseVariant/ReviewCarousel.tsx +++ b/src/components/SQLCourseVariant/ReviewCarousel.tsx @@ -179,7 +179,7 @@ export function ReviewCarousel() { }, []); return ( -
+

What other learners said

diff --git a/src/components/SQLCourseVariant/SQLCourseVariantPage.tsx b/src/components/SQLCourseVariant/SQLCourseVariantPage.tsx index bf6aeb12b..efb05dafa 100644 --- a/src/components/SQLCourseVariant/SQLCourseVariantPage.tsx +++ b/src/components/SQLCourseVariant/SQLCourseVariantPage.tsx @@ -20,7 +20,7 @@ import { sqlCourseChapters } from '../SQLCourse/SQLCoursePage'; export function SQLCourseVariantPage() { return ( -
+
@@ -43,7 +43,7 @@ export function SQLCourseVariantPage() {
-

+

Get certified for SQL queries and ready to deploy your newly-gained skill in 30 days. Perfect for developers, data analysts, and anyone working with data. Level up risk-free with a 7-day money-back