Skip to content

Commit ebb5b6c

Browse files
committed
2 parents fa6f013 + 26fabe8 commit ebb5b6c

File tree

5 files changed

+81
-32
lines changed

5 files changed

+81
-32
lines changed

package-lock.json

Lines changed: 4 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"eslint": "^8.57.0",
3030
"eslint-config-next": "14.2.5",
3131
"postcss": "^8.5.6",
32+
"typescript": "5.9.3",
3233
"tailwindcss": "^3.4.18",
3334
"tailwindcss-animate": "^1.0.7"
3435
}
13.4 KB
Loading

src/components/sections/HeroSection.jsx

Lines changed: 74 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,61 @@ import { EXTERNAL_LINKS, IMAGE_PATHS } from '@/lib/constants';
55
import { motion, useScroll, useTransform } from 'framer-motion';
66
import { Sparkles } from 'lucide-react';
77
import Image from 'next/image';
8+
import { useEffect, useRef, useState } from 'react';
89

910
export 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

src/components/ui/Button.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ const Button = React.forwardRef(
1818
const variants = {
1919
default:
2020
'bg-gradient-to-r from-[#9B87FE] to-[#8A76ED] text-black hover:shadow-lg hover:shadow-[#9B87FE]/50 active:scale-95',
21+
devfolio:
22+
'bg-[#3770FF] text-white hover:bg-[#2f63e0] active:scale-95 shadow-lg shadow-[#3770FF]/40 border border-white/5',
2123
outline:
2224
'border-2 border-[#9B87FE] text-white hover:bg-[#9B87FE]/10 hover:border-[#8A76ED]',
2325
ghost: 'hover:bg-white/10 text-white',

0 commit comments

Comments
 (0)