From 267d6c4aa1128bc48cb77fc83614e3e87abdf3bb Mon Sep 17 00:00:00 2001 From: Yash Sehgal Date: Mon, 27 Jun 2022 12:05:41 +0000 Subject: [PATCH] feat(#1): dot-slider feature added --- src/Onboarding.jsx | 50 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/src/Onboarding.jsx b/src/Onboarding.jsx index d812efd..7fbaae6 100644 --- a/src/Onboarding.jsx +++ b/src/Onboarding.jsx @@ -86,13 +86,13 @@ export default function Onboarding() { }} > {/* start: progress bar animation section wrapper */} -
+ {/*
-
+
*/} {/* end: progress bar animation section wrapper */}
@@ -130,12 +130,12 @@ export default function Onboarding() { currently, it's not working but saving it for future references */} - {/* + - */} +
@@ -211,4 +211,46 @@ function manageOnboardingContent_onSlide(currentState=0) { ]; return { content: onboardingContent[currentState], totalSlideCount: onboardingContent.length - 1}; +} + +// ShowSlideNavigation - method to render dot-sliding component +function ShowSlideNavigation({totalSlideCount, activeSlideIndex}) { + const [activeDotIndexRef, setActiveDotIndex] = useState(activeSlideIndex); + let dotSliderRef = []; + useEffect(() => { + setActiveDotIndex(activeSlideIndex); + }, [activeSlideIndex]); + // rendering html-DOM elements as dots inside the dotSlideRef array + for (let dotCount = 0; dotCount <= totalSlideCount; dotCount++) { + dotSliderRef.push( + +
+ + ) + } + return ( + +
+ {dotSliderRef.map((dot, dotIndex) => { + if (dotIndex === activeDotIndexRef-1) { + return ( + + + {dot} + + + ) + } else { + return ( + + + {dot} + + + ) + } + })} +
+
+ ) } \ No newline at end of file