This commit is contained in:
2026-05-28 21:56:15 +07:00
parent e152bfcde1
commit 37e159bd8e
80 changed files with 436 additions and 213 deletions
+196 -93
View File
@@ -13,15 +13,21 @@ type EventItem = {
date: string;
description: string;
images: string[];
googleDriveUrl: string;
};
export default function GalleryPageClient() {
const { gallery } = useTranslation();
const { gallery, lang } = useTranslation();
// Active Event Index (0: latest event, 7: oldest event)
const [activeEventIndex, setActiveEventIndex] = useState(0);
// Lightbox State
const [lightboxEventId, setLightboxEventId] = useState<number | null>(null);
const [lightboxImageIndex, setLightboxImageIndex] = useState<number | null>(null);
// Active event object
const activeEvent = gallery.events[activeEventIndex] as EventItem;
// Helper to format image source path
const getImgSrc = (src: string) => {
if (src.startsWith("http")) return src;
@@ -30,10 +36,7 @@ export default function GalleryPageClient() {
// Keyboard navigation for Lightbox
useEffect(() => {
if (lightboxEventId === null || lightboxImageIndex === null) return;
const activeEvent = gallery.events.find((e: EventItem) => e.id === lightboxEventId);
if (!activeEvent) return;
if (lightboxImageIndex === null || !activeEvent) return;
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key === "Escape") {
@@ -49,28 +52,63 @@ export default function GalleryPageClient() {
return () => {
window.removeEventListener("keydown", handleKeyDown);
};
}, [lightboxEventId, lightboxImageIndex, gallery.events]);
}, [lightboxImageIndex, activeEvent]);
const openLightbox = (eventId: number, imgIndex: number) => {
setLightboxEventId(eventId);
const openLightbox = (imgIndex: number) => {
setLightboxImageIndex(imgIndex);
document.body.style.overflow = "hidden";
};
const closeLightbox = () => {
setLightboxEventId(null);
setLightboxImageIndex(null);
document.body.style.overflow = "";
};
// Find active lightbox image and event
const activeEvent = lightboxEventId !== null
? gallery.events.find((e: EventItem) => e.id === lightboxEventId)
: null;
const goToNewerEvent = () => {
if (activeEventIndex > 0) {
setActiveEventIndex(activeEventIndex - 1);
}
};
const goToOlderEvent = () => {
if (activeEventIndex < gallery.events.length - 1) {
setActiveEventIndex(activeEventIndex + 1);
}
};
const activeImage = activeEvent && lightboxImageIndex !== null
? activeEvent.images[lightboxImageIndex]
: null;
// Helper to determine CSS classes for the dynamic mosaic
const getMosaicClasses = (i: number, total: number) => {
// If very few images, keep it simple
if (total < 3) {
return "h-[240px] sm:h-[320px]";
}
// Dynamic grid classes
switch (i) {
case 0:
// Spotlight spans 2 columns & 2 rows on desktop
return "md:col-span-2 md:row-span-2 h-[260px] sm:h-[360px] md:h-[500px]";
default:
// Adjust the last image to prevent layout gaps
if (i === total - 1) {
if (total === 4 || total === 7) {
return "md:col-span-2 h-[180px] sm:h-[240px]";
}
if (total === 5 || total === 8) {
return "md:col-span-2 h-[180px] sm:h-[240px]";
}
if (total === 10) {
return "md:col-span-3 h-[200px] sm:h-[280px]";
}
}
return "h-[180px] sm:h-[240px]";
}
};
return (
<main className="pt-16 lg:pt-20 min-h-screen bg-background text-on-surface">
{/* Hero Header */}
@@ -88,93 +126,158 @@ export default function GalleryPageClient() {
</div>
</section>
{/* Visual Gallery section */}
{/* Gallery Section */}
<section className="py-12 lg:py-20 px-[var(--spacing-gutter)] max-w-hd mx-auto">
<div className="flex flex-col gap-16 lg:gap-24">
{gallery.events.map((event: EventItem) => (
{/* Step Timeline Navigation */}
<div className="mb-10 max-w-4xl mx-auto px-4">
<div className="relative flex justify-between items-center">
{/* Timeline track behind steps */}
<div className="absolute left-0 right-0 h-[2px] bg-white/10 -z-10" />
<div
key={event.id}
className="glass-panel p-6 sm:p-8 lg:p-12 rounded-3xl border border-primary/20 hover:border-primary/40 shadow-xl transition-all duration-300"
>
{/* Event details */}
<div className="flex flex-col lg:flex-row lg:items-start lg:justify-between mb-8 gap-4">
<div className="max-w-2xl">
<h2 className="text-xl sm:text-2xl lg:text-3xl font-[var(--font-display-lg)] text-primary mb-3">
{event.title}
</h2>
<p className="text-sm sm:text-base text-on-surface-variant/80 leading-relaxed font-sans">
{event.description}
</p>
className="absolute left-0 h-[2px] bg-primary transition-all duration-500 -z-10"
style={{ width: `${(activeEventIndex / (gallery.events.length - 1)) * 100}%` }}
/>
{gallery.events.map((event: EventItem, idx: number) => {
const isActive = idx === activeEventIndex;
const isPassed = idx < activeEventIndex;
return (
<button
key={event.id}
type="button"
onClick={() => setActiveEventIndex(idx)}
className="flex flex-col items-center group cursor-pointer relative focus:outline-none"
title={event.title}
>
{/* Step circle */}
<div
className={[
"w-8 h-8 rounded-full flex items-center justify-center font-[var(--font-label-caps)] text-xs font-bold transition-all duration-300 border-2 z-10",
isActive
? "bg-background border-primary text-primary status-led shadow-[0_0_12px_rgba(197,160,89,0.6)] scale-110"
: isPassed
? "bg-primary border-primary text-on-primary"
: "bg-surface-container-high border-white/10 text-on-surface-variant/40 hover:border-white/30 hover:text-on-surface"
].join(" ")}
>
{idx + 1}
</div>
</button>
);
})}
</div>
</div>
{/* Active Event Grid Container */}
{activeEvent && (
<div className="glass-panel p-6 sm:p-10 lg:p-16 rounded-[2rem] lg:rounded-[3rem] border border-primary/20 hover:border-primary/30 shadow-2xl transition-all duration-300">
{/* Top Navigation Control Header */}
<div className="flex justify-between items-center mb-10 border-b border-white/5 pb-6">
<button
type="button"
onClick={goToNewerEvent}
disabled={activeEventIndex === 0}
className="flex items-center gap-1.5 text-xs sm:text-sm font-bold uppercase tracking-wider text-on-surface-variant/60 hover:text-primary disabled:opacity-20 disabled:pointer-events-none transition-colors duration-200 focus:outline-none"
>
<span className="material-symbols-outlined text-lg">arrow_back</span>
<span className="hidden sm:inline">{lang === "vi" ? "Sự kiện mới hơn" : "Newer Event"}</span>
</button>
<span className="font-[var(--font-label-caps)] text-xs sm:text-sm text-primary tracking-widest bg-primary/5 border border-primary/20 px-4 py-2 rounded-xl">
{lang === "vi"
? `SỰ KIỆN ${activeEventIndex + 1} / ${gallery.events.length}`
: `EVENT ${activeEventIndex + 1} OF ${gallery.events.length}`
}
</span>
<button
type="button"
onClick={goToOlderEvent}
disabled={activeEventIndex === gallery.events.length - 1}
className="flex items-center gap-1.5 text-xs sm:text-sm font-bold uppercase tracking-wider text-on-surface-variant/60 hover:text-primary disabled:opacity-20 disabled:pointer-events-none transition-colors duration-200 focus:outline-none"
>
<span className="hidden sm:inline">{lang === "vi" ? "Sự kiện cũ hơn" : "Older Event"}</span>
<span className="material-symbols-outlined text-lg">arrow_forward</span>
</button>
</div>
{/* Event Info Header */}
<div className="max-w-4xl mb-12">
<h2 className="text-2xl sm:text-3xl lg:text-4xl font-[var(--font-display-lg)] text-primary mb-4 leading-tight">
{activeEvent.title}
</h2>
<div className="flex flex-wrap items-center gap-4 text-xs uppercase tracking-wider text-on-surface-variant/50 font-[var(--font-label-caps)] mb-6">
<div className="flex items-center gap-1.5 bg-surface-container-high px-3.5 py-2 rounded-xl border border-white/5">
<span className="material-symbols-outlined text-base text-primary">calendar_today</span>
<span>{activeEvent.date}</span>
</div>
{/* Meta details */}
<div className="flex flex-wrap items-center gap-4 lg:self-start lg:mt-2 text-xs uppercase tracking-wider text-on-surface-variant/60 font-[var(--font-label-caps)]">
<div className="flex items-center gap-1.5 bg-surface-container-high px-3 py-1.5 rounded-lg border border-white/5">
<span className="material-symbols-outlined text-base text-primary">location_on</span>
<span>{event.location}</span>
</div>
<div className="flex items-center gap-1.5 bg-surface-container-high px-3 py-1.5 rounded-lg border border-white/5">
<span className="material-symbols-outlined text-base text-primary">calendar_today</span>
<span>{event.date}</span>
</div>
</div>
</div>
{/* Collage gallery grid */}
<div className="grid grid-cols-1 md:grid-cols-3 gap-4 lg:gap-6">
{/* Large image (left) */}
<div
className="md:col-span-2 overflow-hidden rounded-2xl border border-white/10 group cursor-pointer relative h-[240px] sm:h-[320px] md:h-[360px]"
onClick={() => openLightbox(event.id, 0)}
>
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
src={getImgSrc(event.images[0])}
alt={`${event.title} Highlight 1`}
className="w-full h-full object-cover transition-transform duration-700 group-hover:scale-105"
loading="lazy"
/>
<div className="absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex items-center justify-center">
<div className="w-12 h-12 rounded-full bg-primary/20 backdrop-blur-md flex items-center justify-center border border-primary/50 text-white">
<span className="material-symbols-outlined text-2xl">zoom_in</span>
</div>
</div>
</div>
{/* Stacked images (right) */}
<div className="flex flex-col gap-4 lg:gap-6">
{event.images.slice(1, 3).map((imgUrl, i) => (
<div
key={i}
className="flex-1 overflow-hidden rounded-2xl border border-white/10 group cursor-pointer relative h-[180px] sm:h-[220px] md:h-[168px] lg:h-[168px]"
onClick={() => openLightbox(event.id, i + 1)}
>
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
src={getImgSrc(imgUrl)}
alt={`${event.title} Highlight ${i + 2}`}
className="w-full h-full object-cover transition-transform duration-700 group-hover:scale-105"
loading="lazy"
/>
<div className="absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex items-center justify-center">
<div className="w-10 h-10 rounded-full bg-primary/20 backdrop-blur-md flex items-center justify-center border border-primary/50 text-white">
<span className="material-symbols-outlined text-xl">zoom_in</span>
</div>
</div>
</div>
))}
</div>
{activeEvent.googleDriveUrl && activeEvent.googleDriveUrl.trim() !== "" && (
<a
href={activeEvent.googleDriveUrl}
target="_blank"
rel="noopener noreferrer"
className="flex items-center gap-2 bg-surface-container-high hover:bg-surface-container-highest px-3.5 py-2 rounded-xl border border-white/5 text-primary text-xs font-bold transition-all duration-200 focus:outline-none"
>
<i className="fab fa-google-drive text-sm"></i>
<span>{lang === "vi" ? "Xem Full Album trên Drive" : "View Full Album on Drive"}</span>
</a>
)}
</div>
</div>
))}
</div>
{/* Dynamic Mosaic Grid or Coming Soon Placeholder */}
{activeEvent.images.length === 0 ? (
<div className="flex flex-col items-center justify-center py-20 px-6 border border-white/5 bg-white/[0.01] rounded-2xl">
<span className="material-symbols-outlined text-5xl text-primary/45 mb-4">image</span>
<p className="text-on-surface-variant/60 font-sans text-sm sm:text-base text-center max-w-md">
{lang === "vi"
? "Hình ảnh nổi bật cho sự kiện này hiện đang được cập nhật."
: "Highlight images for this event are currently being updated."
}
</p>
</div>
) : (
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-6">
{activeEvent.images.map((imgUrl, i) => (
<div
key={i}
className={[
getMosaicClasses(i, activeEvent.images.length),
"overflow-hidden rounded-2xl border border-white/10 group cursor-pointer relative",
].join(" ")}
onClick={() => openLightbox(i)}
>
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
src={getImgSrc(imgUrl)}
alt={`${activeEvent.title} Highlight ${i + 1}`}
className="w-full h-full object-cover transition-transform duration-700 group-hover:scale-105"
loading="lazy"
/>
<div className="absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex items-center justify-center">
<div className="w-12 h-12 rounded-full bg-primary/20 backdrop-blur-md flex items-center justify-center border border-primary/50 text-white shadow-lg">
<span className="material-symbols-outlined text-2xl">zoom_in</span>
</div>
</div>
</div>
))}
</div>
)}
</div>
)}
</section>
{/* Invitation Section */}
<ReadyToJoin data={gallery.join} />
{/* Lightbox Overlay */}
{lightboxEventId !== null && lightboxImageIndex !== null && activeEvent && activeImage && (
{lightboxImageIndex !== null && activeEvent && activeImage && (
<div
className="fixed inset-0 z-[100] flex flex-col justify-center items-center bg-black/95 backdrop-blur-md transition-opacity duration-300"
onClick={closeLightbox}
@@ -182,7 +285,7 @@ export default function GalleryPageClient() {
{/* Close button */}
<button
type="button"
className="absolute top-6 right-6 text-white/70 hover:text-white transition-colors p-2 z-[110]"
className="absolute top-6 right-6 text-white/70 hover:text-white transition-colors p-2 z-[110] focus:outline-none"
onClick={closeLightbox}
aria-label="Close Lightbox"
>
@@ -197,7 +300,7 @@ export default function GalleryPageClient() {
{/* Prev arrow */}
<button
type="button"
className="w-12 h-12 md:w-16 md:h-16 rounded-full bg-white/5 hover:bg-white/10 border border-white/10 text-white flex items-center justify-center transition-colors mr-2 active:scale-95"
className="w-12 h-12 md:w-16 md:h-16 rounded-full bg-white/5 hover:bg-white/10 border border-white/10 text-white flex items-center justify-center transition-colors mr-2 active:scale-95 focus:outline-none"
onClick={() => setLightboxImageIndex((prev) => (prev! - 1 + activeEvent.images.length) % activeEvent.images.length)}
aria-label="Previous Image"
>
@@ -217,7 +320,7 @@ export default function GalleryPageClient() {
{/* Next arrow */}
<button
type="button"
className="w-12 h-12 md:w-16 md:h-16 rounded-full bg-white/5 hover:bg-white/10 border border-white/10 text-white flex items-center justify-center transition-colors ml-2 active:scale-95"
className="w-12 h-12 md:w-16 md:h-16 rounded-full bg-white/5 hover:bg-white/10 border border-white/10 text-white flex items-center justify-center transition-colors ml-2 active:scale-95 focus:outline-none"
onClick={() => setLightboxImageIndex((prev) => (prev! + 1) % activeEvent.images.length)}
aria-label="Next Image"
>
@@ -234,7 +337,7 @@ export default function GalleryPageClient() {
{activeEvent.title}
</h3>
<p className="text-on-surface-variant/60 text-xs sm:text-sm uppercase tracking-wider font-[var(--font-label-caps)]">
{useTranslation().lang === "vi"
{lang === "vi"
? `Hình ảnh ${lightboxImageIndex + 1} trên ${activeEvent.images.length}`
: `Image ${lightboxImageIndex + 1} of ${activeEvent.images.length}`
}
+1 -1
View File
@@ -44,7 +44,7 @@ export default function ReadyToJoin({ data }: Props) {
</Link>
<Link
href="/registration#members"
href="/#agenda"
className="w-full sm:w-auto inline-flex items-center justify-center gap-2 bg-surface-container-high hover:bg-surface-container-highest border border-white/10 hover:border-primary/40 text-on-surface-variant px-8 lg:px-10 py-4 rounded-xl font-bold uppercase tracking-widest text-xs lg:text-sm hover:scale-105 active:scale-95 transition-all duration-300"
>
<span>{data.viewMembersBtn}</span>