@@ -5,12 +5,61 @@ import { EXTERNAL_LINKS, IMAGE_PATHS } from '@/lib/constants';
55import { motion , useScroll , useTransform } from 'framer-motion' ;
66import { Sparkles } from 'lucide-react' ;
77import Image from 'next/image' ;
8+ import { useEffect , useRef , useState } from 'react' ;
89
910export default function HeroSection ( ) {
1011 const { scrollY } = useScroll ( ) ;
1112 const yText = useTransform ( scrollY , [ 0 , 500 ] , [ 0 , 150 ] ) ;
1213 const yImg = useTransform ( scrollY , [ 0 , 500 ] , [ 0 , - 80 ] ) ;
1314 const opacity = useTransform ( scrollY , [ 0 , 300 ] , [ 1 , 0 ] ) ;
15+ const devfolioContainerRef = useRef ( null ) ;
16+ const [ devfolioButtonVisible , setDevfolioButtonVisible ] = useState ( false ) ;
17+
18+ // Load Devfolio apply button SDK on this page
19+ useEffect ( ( ) => {
20+ const existing = document . querySelector (
21+ 'script[src="https://apply.devfolio.co/v2/sdk.js"]'
22+ ) ;
23+ const script = existing || document . createElement ( 'script' ) ;
24+ script . src = 'https://apply.devfolio.co/v2/sdk.js' ;
25+ script . async = true ;
26+ script . defer = true ;
27+
28+ if ( ! existing ) {
29+ document . body . appendChild ( script ) ;
30+ }
31+
32+ return ( ) => {
33+ if ( ! existing && script . parentNode ) {
34+ script . parentNode . removeChild ( script ) ;
35+ }
36+ } ;
37+ } , [ ] ) ;
38+
39+ // Detect when Devfolio widget renders and fall back to native button if it doesn't
40+ useEffect ( ( ) => {
41+ if ( ! devfolioContainerRef . current ) return undefined ;
42+
43+ const target = devfolioContainerRef . current ;
44+ const observer = new MutationObserver ( ( ) => {
45+ if ( target . childElementCount > 0 ) {
46+ setDevfolioButtonVisible ( true ) ;
47+ }
48+ } ) ;
49+
50+ observer . observe ( target , { childList : true } ) ;
51+
52+ const timeout = setTimeout ( ( ) => {
53+ if ( target . childElementCount > 0 ) {
54+ setDevfolioButtonVisible ( true ) ;
55+ }
56+ } , 2000 ) ;
57+
58+ return ( ) => {
59+ observer . disconnect ( ) ;
60+ clearTimeout ( timeout ) ;
61+ } ;
62+ } , [ ] ) ;
1463
1564 return (
1665 < section
@@ -30,7 +79,7 @@ export default function HeroSection() {
3079 aria-hidden = { false }
3180 >
3281 < a
33- href = "https://ethindia-villa.devfolio.co/overview "
82+ href = "https://ethindia.org "
3483 target = "_blank"
3584 rel = "noopener noreferrer"
3685 aria-label = "ETHIndia"
@@ -45,7 +94,7 @@ export default function HeroSection() {
4594 />
4695 </ a >
4796
48- { /* <div className="w-px h-6 bg-white/10" aria-hidden="true" />
97+ < div className = "w-px h-6 bg-white/10" aria-hidden = "true" />
4998
5099 < a
51100 href = "https://devfolio.co"
@@ -61,7 +110,7 @@ export default function HeroSection() {
61110 height = { 26 }
62111 className = "object-contain"
63112 />
64- </a> */ }
113+ </ a >
65114 </ div >
66115
67116 < div className = "grid grid-cols-1 lg:grid-cols-2 gap-16 items-center" >
@@ -103,20 +152,28 @@ export default function HeroSection() {
103152
104153 < div className = "grid grid-cols-1 sm:grid-cols-2 gap-3 max-w-md" >
105154 < div className = "sm:col-span-2" >
106- < Button
107- size = "default"
108- className = "group w-full"
109- onClick = { ( ) => window . open ( EXTERNAL_LINKS . devfolio , '_blank' ) }
110- >
111- Apply with Devfolio
112- < motion . span
113- className = "ml-2"
114- animate = { { x : [ 0 , 5 , 0 ] } }
115- transition = { { duration : 1.5 , repeat : Infinity } }
116- >
117- →
118- </ motion . span >
119- </ Button >
155+ < div className = "w-full flex justify-center" >
156+ < div
157+ ref = { devfolioContainerRef }
158+ className = "apply-button"
159+ data-hackathon-slug = "opencode25"
160+ data-button-theme = "dark"
161+ style = { { height : '44px' , width : '312px' } }
162+ aria-label = "Apply with Devfolio"
163+ />
164+ { ! devfolioButtonVisible && (
165+ < Button
166+ variant = "devfolio"
167+ size = "default"
168+ className = "absolute w-[312px] h-[44px] font-semibold gap-1.5"
169+ onClick = { ( ) =>
170+ window . open ( EXTERNAL_LINKS . devfolio , '_blank' )
171+ }
172+ >
173+ Apply with Devfolio
174+ </ Button >
175+ ) }
176+ </ div >
120177 </ div >
121178
122179 < Button
0 commit comments