Skip to content

Commit 14b1afb

Browse files
committed
fixed unresponsive overlay cards in info.tsx
1 parent d91bcf9 commit 14b1afb

File tree

1 file changed

+62
-26
lines changed

1 file changed

+62
-26
lines changed

src/components/Info.tsx

Lines changed: 62 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { useState, useEffect } from 'react';
22
import { Carousel } from 'react-responsive-carousel';
33
import 'react-responsive-carousel/lib/styles/carousel.min.css';
44
import { motion } from 'framer-motion';
@@ -11,6 +11,20 @@ import {
1111
} from '@/styles/Animations';
1212

1313
const Info: React.FC = () => {
14+
const [windowWidth, setWindowWidth] = useState(0);
15+
16+
useEffect(() => {
17+
const handleResize = () => {
18+
setWindowWidth(window.innerWidth);
19+
};
20+
// Set initial width
21+
handleResize();
22+
// Add event listener
23+
window.addEventListener('resize', handleResize);
24+
// Cleanup event listener
25+
return () => window.removeEventListener('resize', handleResize);
26+
}, []);
27+
1428
const renderImageCard = (key: string, image: ImageConfig) => (
1529
<motion.div
1630
key={key}
@@ -214,39 +228,61 @@ const Info: React.FC = () => {
214228
/>
215229

216230
{/* Card on Top Left */}
217-
<motion.div
218-
className="absolute top-2 left-2 bg-black/60
231+
{windowWidth >= 270 && (
232+
<motion.div
233+
className="absolute top-2 left-2 bg-black/60
219234
backdrop-blur-sm rounded-lg sm:rounded-xl p-2.5 sm:p-4 md:p-6 shadow-lg
220235
max-w-[180px] sm:max-w-[220px] md:max-w-xs transform hover:scale-105
221236
transition-all duration-300 ease-out z-10 border border-white/50"
222-
whileHover={{ scale: 1.05 }}
223-
>
224-
<h3 className="text-base sm:text-lg md:text-xl font-bold mb-1 md:mb-2 text-gray-100 font-AnonymousPro">
225-
Project Based Learning
226-
</h3>
227-
<p className="text-white text-xs sm:text-sm leading-tight sm:leading-snug">
228-
Empowering learners and educators with hands-on
229-
project-based tools that enable creation and real-world
230-
problem-solving.
231-
</p>
232-
</motion.div>
237+
whileHover={{ scale: 1.05 }}
238+
>
239+
{windowWidth >= 355 && (
240+
<>
241+
<h3 className="text-base sm:text-lg md:text-xl font-bold mb-1 md:mb-2 text-gray-100 font-AnonymousPro">
242+
Project Based Learning
243+
</h3>
244+
<p className="text-white text-xs sm:text-sm leading-tight sm:leading-snug">
245+
Empowering learners and educators with hands-on
246+
project-based tools that enable creation and
247+
real-world problem-solving.
248+
</p>
249+
</>
250+
)}
251+
{windowWidth < 355 && windowWidth >= 250 && (
252+
<h3 className="text-base sm:text-lg md:text-xl font-bold text-gray-100 font-AnonymousPro">
253+
Project Based Learning
254+
</h3>
255+
)}
256+
</motion.div>
257+
)}
233258

234259
{/* Card on Bottom Right */}
235-
<motion.div
236-
className="absolute bottom-2 right-2 bg-black/60
260+
{windowWidth >= 270 && (
261+
<motion.div
262+
className="absolute bottom-2 right-2 bg-black/60
237263
backdrop-blur-sm rounded-lg sm:rounded-xl p-2.5 sm:p-4 md:p-6 shadow-lg
238264
max-w-[180px] sm:max-w-[220px] md:max-w-xs transform hover:scale-105
239265
transition-all duration-300 ease-out z-10 border border-white/50"
240-
whileHover={{ scale: 1.05 }}
241-
>
242-
<h3 className="text-base sm:text-lg font-bold mb-1 text-amber-100 font-AnonymousPro">
243-
Challenge and Fun: It's hard fun.
244-
</h3>
245-
<p className="text-white text-xs sm:text-sm leading-tight sm:leading-snug">
246-
Bringing interactive, meaningful experiences that make
247-
education exciting and impactful.
248-
</p>
249-
</motion.div>
266+
whileHover={{ scale: 1.05 }}
267+
>
268+
{windowWidth >= 355 && (
269+
<>
270+
<h3 className="text-base sm:text-lg font-bold mb-1 text-amber-100 font-AnonymousPro">
271+
Challenge and Fun: It's hard fun.
272+
</h3>
273+
<p className="text-white text-xs sm:text-sm leading-tight sm:leading-snug">
274+
Bringing interactive, meaningful experiences that make
275+
education exciting and impactful.
276+
</p>
277+
</>
278+
)}
279+
{windowWidth < 355 && windowWidth >= 270 && (
280+
<h3 className="text-base sm:text-lg font-bold text-amber-100 font-AnonymousPro">
281+
Challenge and Fun: It's hard fun.
282+
</h3>
283+
)}
284+
</motion.div>
285+
)}
250286
</div>
251287
</motion.div>
252288
</motion.section>

0 commit comments

Comments
 (0)