diff --git a/devcon/src/pages/road-to-devcon.tsx b/devcon/src/pages/road-to-devcon.tsx index c89fc92f0..5b1c53831 100644 --- a/devcon/src/pages/road-to-devcon.tsx +++ b/devcon/src/pages/road-to-devcon.tsx @@ -63,9 +63,9 @@ const useWindowWidth = (cssVariableName: string) => { }, [cssVariableName]) } -const useIntersectionRatio = (options?: any) => { +const useIntersectionRatio = (ref: any, options?: any) => { const [intersectionRatio, setIntersectionRatio] = useState(0) - const ref = useRef(null) + // const ref = useRef(null) useEffect(() => { const observerOptions = { @@ -266,7 +266,7 @@ const useHorizontalParallax = (onChange: (progress: number) => void) => { } const Hero = (props: any) => { - const { controlsRef, sections, goToSection } = props + const { controlsRef, sectionRefs, goToSection } = props useWindowWidth('window-width') @@ -302,7 +302,7 @@ const Hero = (props: any) => { -
+
{/* Desktop version first slide */}
@@ -417,7 +417,7 @@ const Hero = (props: any) => {

Why Devcon is for You

-

+

Devcon is the Ethereum conference for developers, thinkers, and makers. You’ll meet the smartest and kindest people in the Ethereum ecosystem IRL, and gain insight into a unique culture that is challenging to fully understand just online. @@ -474,7 +474,7 @@ const Hero = (props: any) => {

What is the Road to Devcon?

-

+

The Road to Devcon (RTD) is a series of Ethereum events and educational initiatives leading up to Devcon, organized by the active local communities in Southeast Asia.

@@ -527,7 +527,7 @@ const Hero = (props: any) => { Become a leader: Organize an event or start a community

-

+

If you're in SEA, community-driven, and passionate about Ethereum's positive impact, we're here to support you! This is your call to adventure, to be part of something bigger, something wilder.

@@ -652,35 +652,40 @@ const Gallery = React.memo(() => { // title="ROAD TO DEVCON" images={[ { - alt: 'About 1', + alt: 'Community 1', src: Gal1, }, { - alt: 'About 2', + alt: 'Community 2', src: Gal2, }, { - alt: 'About 3', + alt: 'Community 3', src: Gal3, }, { - alt: 'About 4', + alt: 'Community 4', src: Gal4, }, + { + alt: 'Community 5', + src: Gal5, + }, ]} />
) }) -export default pageHOC(function RoadToDevcon(props: any) { - const { data } = useTina(props.cms) - const { data: grantsData } = useTina(props.grantsCms) - const pages = data.pages as PagesRoad_To_Devcon - const grantsPages = grantsData.pages as PagesIndex - const controlsRef = useRef() +const SlideControls = ({ sectionRefs, controlsRef, goToSection }: any) => { const [showDragIndicator, setShowDragIndicator] = React.useState(true) + const sections = sectionRefs.map((ref: any) => { + return useIntersectionRatio(ref, { + root: 'intersection-root', + }) + }) + useEffect(() => { controlsRef.current.subscribeX((x: any) => { if (x > 100) { @@ -691,46 +696,86 @@ export default pageHOC(function RoadToDevcon(props: any) { }) }, [controlsRef.current]) - const sections = [ - useIntersectionRatio({ - root: 'intersection-root', - }), - useIntersectionRatio({ - root: 'intersection-root', - }), - useIntersectionRatio({ - root: 'intersection-root', - }), - useIntersectionRatio({ - root: 'intersection-root', - }), - ] - const ratios = sections.map(section => parseFloat(section.intersectionRatio)) const highestRatio = Math.max(...ratios) const currentSlide = highestRatio === 0 ? -1 : sections.findIndex(section => section.intersectionRatio === highestRatio) - const goToSection = (index: number) => { - if (!sections[index]) return + useKeyBinding(() => goToSection(currentSlide - 1), ['ArrowLeft']) + useKeyBinding(() => goToSection(currentSlide + 1), ['ArrowRight']) - window.scrollTo(0, 0) + return ( +
+
+
+
goToSection(currentSlide - 1)} + > + +
- // We need to know how far the element is from the side of the screen to align with the rest of the content - // The calculations are quite complicated so we'll left curve it and look at a piece of content that respects the layout and match its padding to the side - const padding = (() => { - const randomBoundedElement = document.getElementById('dont-remove-me-the-hero-needs-me') +

+ 0{currentSlide + 1} / 0{sections.length} +

- return randomBoundedElement?.offsetLeft || 0 - })() +
goToSection(currentSlide + 1)} + > + +
+
- const offsetLeft = sections[index].ref.current.offsetLeft + +

+ Drag or use arrow keys to continue + Swipe to continue +

+ +
+
+
+ ) +} - controlsRef.current.setX(offsetLeft - padding) - } +export default pageHOC(function RoadToDevcon(props: any) { + const { data } = useTina(props.cms) + const { data: grantsData } = useTina(props.grantsCms) + const pages = data.pages as PagesRoad_To_Devcon + const grantsPages = grantsData.pages as PagesIndex + const controlsRef = useRef() + const sections: any = [useRef(), useRef(), useRef(), useRef()] - useKeyBinding(() => goToSection(currentSlide - 1), ['ArrowLeft']) - useKeyBinding(() => goToSection(currentSlide + 1), ['ArrowRight']) + const goToSection = React.useMemo(() => { + return (index: number) => { + if (!sections[index]) return + + window.scrollTo(0, 0) + + // We need to know how far the element is from the side of the screen to align with the rest of the content + // The calculations are quite complicated so we'll left curve it and look at a piece of content that respects the layout and match its padding to the side + const padding = (() => { + const randomBoundedElement = document.getElementById('dont-remove-me-the-hero-needs-me') + + return randomBoundedElement?.offsetLeft || 0 + })() + + const offsetLeft = sections[index].current.offsetLeft + + controlsRef.current.setX(offsetLeft - padding) + } + }, []) + + const showDragIndicator = true + + const SlideControlsMemo = React.useMemo(() => { + return () => + }, [...sections]) return ( <> @@ -739,47 +784,7 @@ export default pageHOC(function RoadToDevcon(props: any) { Get Involved }, { text: 'Road To Devcon' }]} - renderCustomNavigation={() => { - return ( -
-
-
-
goToSection(currentSlide - 1)} - > - -
- -

- 0{currentSlide + 1} / 0{sections.length} -

- -
goToSection(currentSlide + 1)} - > - -
-
- - -

- Drag or use arrow keys to continue - Swipe to continue -

- -
-
-
- ) - }} + renderCustomNavigation={SlideControlsMemo} navigation={[ { title: 'Journey', @@ -823,7 +828,7 @@ export default pageHOC(function RoadToDevcon(props: any) { >