diff --git a/src/components/StaffSection.tsx b/src/components/StaffSection.tsx index 078728f..69563f7 100644 --- a/src/components/StaffSection.tsx +++ b/src/components/StaffSection.tsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useState, useRef } from "react"; import { motion, AnimatePresence } from "framer-motion"; import { STAFF } from "@/data/event-data"; import { Instagram, User, ChevronLeft, ChevronRight } from "lucide-react"; @@ -23,6 +23,7 @@ const filterActiveClass: Record = { const StaffSection = () => { const { t } = useTranslation(); const [filter, setFilter] = useState<"all" | "teachers" | "djs" | "specials">("all"); + const scrollerRef = useRef(null); const filteredStaff = STAFF.filter((member) => { if (filter === "all") return true; @@ -31,16 +32,23 @@ const StaffSection = () => { if (filter === "specials") return member.role === "Specials"; return true; }); - // simple ref + helpers for horizontal scroll + + const staffCounts = { + all: STAFF.length, + teachers: STAFF.filter((m) => m.role === "Teacher").length, + djs: STAFF.filter((m) => m.role === "DJ").length, + specials: STAFF.filter((m) => m.role === "Specials").length, + }; + const onPrev = () => { - const scroller = document.getElementById("staff-scroller"); + const scroller = scrollerRef.current; if (!scroller) return; const card = scroller.querySelector("[data-staff-card]") as HTMLElement | null; - const delta = card ? card.offsetWidth + 24 : 320; // 24 ~ gap-x-6 + const delta = card ? card.offsetWidth + 24 : 320; scroller.scrollBy({ left: -delta, behavior: "smooth" }); }; const onNext = () => { - const scroller = document.getElementById("staff-scroller"); + const scroller = scrollerRef.current; if (!scroller) return; const card = scroller.querySelector("[data-staff-card]") as HTMLElement | null; const delta = card ? card.offsetWidth + 24 : 320; @@ -106,13 +114,18 @@ const StaffSection = () => { ))} @@ -124,18 +137,18 @@ const StaffSection = () => {
- {filteredStaff.map((member, i) => ( + {filteredStaff.map((member) => ( diff --git a/src/data/event-data.ts b/src/data/event-data.ts index 358a492..8f97024 100644 --- a/src/data/event-data.ts +++ b/src/data/event-data.ts @@ -252,7 +252,7 @@ export const STAFF = [ { id: "25", name: "Xavi & Laura", - role: "Teachers" as const, + role: "Teacher" as const, image: xavilau, }, {