diff --git a/src/app/(site)/events/page.tsx b/src/app/(site)/events/page.tsx index 72824cc..177f371 100644 --- a/src/app/(site)/events/page.tsx +++ b/src/app/(site)/events/page.tsx @@ -1,4 +1,4 @@ -import EventCard from "@/components/events/event-card"; +import { CustomCarousel } from "@/components/CustomCarousel"; import SlideShow from "@/components/events/slide-show"; import { BackgroundGradient } from "@/components/ui/background-gradient"; import Image from "next/image"; @@ -32,12 +32,10 @@ const Events = async ({}: Props) => { builds a strong tech community.
- {eventList.map((event, idx: number) => ( - - ))} +
- Our Gallary + Our Gallery . @@ -47,49 +45,4 @@ const Events = async ({}: Props) => { ); }; -// const eventList = [ -// { -// title: "Make things float in air", -// slug: "make-things-float-in-air", -// description: "Hover over this card to unleash the power of CSS perspective", -// image: "/events/event.png", -// }, -// { -// title: "Make things float in air", -// slug: "make-things-float-in-air", -// description: "Hover over this card to unleash the power of CSS perspective", -// image: "/events/event.png", -// }, -// { -// title: "Make things float in air", -// slug: "make-things-float-in-air", -// description: "Hover over this card to unleash the power of CSS perspective", -// image: "/events/event.png", -// }, -// { -// title: "Make things float in air", -// slug: "make-things-float-in-air", -// description: "Hover over this card to unleash the power of CSS perspective", -// image: "/events/event.png", -// }, -// { -// title: "Make things float in air", -// slug: "make-things-float-in-air", -// description: "Hover over this card to unleash the power of CSS perspective", -// image: "/events/event.png", -// }, -// { -// title: "Make things float in air", -// slug: "make-things-float-in-air", -// description: "Hover over this card to unleash the power of CSS perspective", -// image: "/events/event.png", -// }, -// { -// title: "Make things float in air", -// slug: "make-things-float-in-air", -// description: "Hover over this card to unleash the power of CSS perspective", -// image: "/events/event.png", -// }, -// ]; - -export default Events; +export default Events; \ No newline at end of file diff --git a/src/app/(site)/page.tsx b/src/app/(site)/page.tsx index 3db8730..8b20f60 100644 --- a/src/app/(site)/page.tsx +++ b/src/app/(site)/page.tsx @@ -1,7 +1,7 @@ import AboutUs from "@/components/home/about-us"; import Domains from "@/components/home/domains"; import Landing from "@/components/home/landing"; -import OurEvents from "@/components/home/our-events"; +import CustomCarousel from "@/components/CustomCarousel"; import { getAllEvents } from "@/sanity/data/home-data"; export default async function Home() { @@ -11,7 +11,7 @@ export default async function Home() { - +
); } diff --git a/src/components/CustomCarousel.tsx b/src/components/CustomCarousel.tsx new file mode 100644 index 0000000..0fa75b7 --- /dev/null +++ b/src/components/CustomCarousel.tsx @@ -0,0 +1,100 @@ +"use client"; + +import React, { useEffect, useState, useRef } from "react"; +import Image from "next/image"; +import Link from "next/link"; +import { Event } from "@/sanity/schemas/event-schema"; +import { CardContainer, CardBody, CardItem } from "./ui/3d-card"; + +type Props = { + event: Event[]; +}; + +const CustomCarousel: React.FC = ({ event }) => { + const [activeIndex, setActiveIndex] = useState(0); + const [isHovered, setIsHovered] = useState(null); + const intervalRef = useRef(null); + + const startCarousel = () => { + intervalRef.current = setInterval(() => { + setActiveIndex((prevIndex) => + prevIndex === event.length - 1 ? 0 : prevIndex + 1 + ); + }, 1000); + }; + + const stopCarousel = () => { + if (intervalRef.current) { + clearInterval(intervalRef.current); + } + }; + + const handleMouseEnter = (index: number) => { + setIsHovered(index); + stopCarousel(); + }; + + const handleMouseLeave = () => { + setIsHovered(null); + startCarousel(); + }; + + useEffect(() => { + startCarousel(); + return () => stopCarousel(); + }, []); + + return ( + <> +
+
+

+ Our Events +

+ Hero Separator +
+
+
+ {event.map((evt, index) => ( + handleMouseEnter(index)} + onMouseLeave={handleMouseLeave} + > + + + {evt.title} + + {evt.title} + + + + + ))} +
+ + ); +}; + +export default CustomCarousel; diff --git a/src/components/events/event-card.tsx b/src/components/events/event-card.tsx index 6decb85..97a5804 100644 --- a/src/components/events/event-card.tsx +++ b/src/components/events/event-card.tsx @@ -4,7 +4,6 @@ import Image from "next/image"; import React from "react"; import { CardBody, CardContainer, CardItem } from "../ui/3d-card"; import Link from "next/link"; -import { Meteors } from "../ui/meteors"; import { Event } from "@/sanity/schemas/event-schema"; type Props = { @@ -13,21 +12,26 @@ type Props = { export default function EventCard({ event }: Props) { return ( - -
- + + {/* Highlighted Change: Updated the background scale effect */} +
+ + - {`${event.title} +
+ {/* Highlighted Change: Updated the image scale effect */} + {`${event.title} +
- -
- {/* */}
); diff --git a/src/components/ui/3d-card.tsx b/src/components/ui/3d-card.tsx index aa868ac..3893983 100644 --- a/src/components/ui/3d-card.tsx +++ b/src/components/ui/3d-card.tsx @@ -9,6 +9,7 @@ import React, { useEffect, } from "react"; +// Context to manage whether the mouse is hovering over a card const MouseEnterContext = createContext< [boolean, React.Dispatch>] | undefined >(undefined); @@ -17,10 +18,14 @@ export const CardContainer = ({ children, className, containerClassName, + onMouseEnter, // Highlight: Added prop to handle mouse enter + onMouseLeave, // Highlight: Added prop to handle mouse leave }: { children?: React.ReactNode; className?: string; containerClassName?: string; + onMouseEnter?: () => void; // Highlight: Added prop to handle mouse enter + onMouseLeave?: () => void; // Highlight: Added prop to handle mouse leave }) => { const containerRef = useRef(null); const [isMouseEntered, setIsMouseEntered] = useState(false); @@ -36,14 +41,17 @@ export const CardContainer = ({ const handleMouseEnter = (e: React.MouseEvent) => { setIsMouseEntered(true); + if (onMouseEnter) onMouseEnter(); // Highlight: Trigger the passed onMouseEnter callback if (!containerRef.current) return; }; const handleMouseLeave = (e: React.MouseEvent) => { + if (onMouseLeave) onMouseLeave(); // Highlight: Trigger the passed onMouseLeave callback if (!containerRef.current) return; setIsMouseEntered(false); containerRef.current.style.transform = `rotateY(0deg) rotateX(0deg)`; }; + return (
{ return (
*]:[transform-style:preserve-3d] shadow-2xl border-2 text-justify border-gray-800", - className - )} + className={cn( + "h-80 w-80 [transform-style:preserve-3d] [&>*]:[transform-style:preserve-3d] shadow-2xl border-2 text-justify border-gray-800", + className + )} > {children}