Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions apps/www/src/components/Teams.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from "react";
import { useEffect, useRef, useState } from "react";
import designCar from "../assets/designCar.png";
import developersCar from "../assets/developersCar.png";
import financeCar from "../assets/financeCar.png";
Expand Down Expand Up @@ -71,9 +71,16 @@ export default function Teams() {
};

const handleCarHover = (carName: string | null) => {
setSelectedCar(carName);
if (!isMobile) setSelectedCar(carName);
};


const handleCarClick = (carName: string) => {
if (isMobile) {
setSelectedCar(prev => (prev === carName ? null : carName));
}
};

const carsRef = useRef<HTMLDivElement | null>(null);
const cars = [
{ name: "Development", src: developersCar.src, alt: "Developer Car" },
{ name: "Marketing", src: marketingCar.src, alt: "Marketing Car" },
Expand Down Expand Up @@ -102,6 +109,22 @@ export default function Teams() {
return () => cancelAnimationFrame(frame);
}, [cars.length]);

useEffect(() => {
if (!isMobile) return;

const handleClickOutside = (e: MouseEvent) => {
if (
carsRef.current &&
!carsRef.current.contains(e.target as Node)
) {
setSelectedCar(null);
}
};

document.addEventListener("click", handleClickOutside);
return () => document.removeEventListener("click", handleClickOutside);
}, [isMobile]);

const teamMembers = [
// Chair and Team Leads
{ name: "Adrian Mathew", teams: ["Finance"], role: ["Treasurer", "Finance Team Lead"], image: adrianMathew, level: 5 },
Expand Down Expand Up @@ -273,7 +296,10 @@ export default function Teams() {
</div>

{/* Cars at the bottom */}
<div className="w-full overflow-hidden relative">
<div
ref={carsRef}
className="w-full overflow-hidden relative"
>
<div
className="inline-flex items-end gap-8 md:gap-12 lg:gap-16 car-scroll"
style={{
Expand All @@ -287,6 +313,7 @@ export default function Teams() {
type="button"
onMouseEnter={() => handleCarHover(car.name)}
onMouseLeave={() => handleCarHover(null)}
onClick={() => handleCarClick(car.name)}
className={`flex-shrink-0 w-[clamp(12rem,25vw,50rem)] transition-transform duration-200 hover:scale-110 cursor-pointer z-10 ${
selectedCar === car.name ? "scale-110" : ""
}`}
Expand Down