This commit is contained in:
2026-05-28 19:37:12 +07:00
parent d47ee57377
commit e152bfcde1
9 changed files with 562 additions and 1 deletions
@@ -0,0 +1,247 @@
"use client";
import { useState, useEffect } from "react";
import { useTranslation } from "@/app/hooks/useTranslation";
import ReadyToJoin from "./ReadyToJoin";
const BASE = process.env.NEXT_PUBLIC_BASE_PATH || "";
type EventItem = {
id: number;
title: string;
location: string;
date: string;
description: string;
images: string[];
};
export default function GalleryPageClient() {
const { gallery } = useTranslation();
// Lightbox State
const [lightboxEventId, setLightboxEventId] = useState<number | null>(null);
const [lightboxImageIndex, setLightboxImageIndex] = useState<number | null>(null);
// Helper to format image source path
const getImgSrc = (src: string) => {
if (src.startsWith("http")) return src;
return `${BASE}${src}`;
};
// Keyboard navigation for Lightbox
useEffect(() => {
if (lightboxEventId === null || lightboxImageIndex === null) return;
const activeEvent = gallery.events.find((e: EventItem) => e.id === lightboxEventId);
if (!activeEvent) return;
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key === "Escape") {
closeLightbox();
} else if (e.key === "ArrowRight") {
setLightboxImageIndex((prev) => (prev! + 1) % activeEvent.images.length);
} else if (e.key === "ArrowLeft") {
setLightboxImageIndex((prev) => (prev! - 1 + activeEvent.images.length) % activeEvent.images.length);
}
};
window.addEventListener("keydown", handleKeyDown);
return () => {
window.removeEventListener("keydown", handleKeyDown);
};
}, [lightboxEventId, lightboxImageIndex, gallery.events]);
const openLightbox = (eventId: number, imgIndex: number) => {
setLightboxEventId(eventId);
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 activeImage = activeEvent && lightboxImageIndex !== null
? activeEvent.images[lightboxImageIndex]
: null;
return (
<main className="pt-16 lg:pt-20 min-h-screen bg-background text-on-surface">
{/* Hero Header */}
<section className="hero-glow py-20 lg:py-32 px-[var(--spacing-gutter)] text-center">
<div className="max-w-4xl mx-auto">
<span className="font-[var(--font-label-caps)] text-xs lg:text-sm text-primary block mb-4 lg:mb-6 tracking-[0.25em] uppercase">
{gallery.hero.eyebrow}
</span>
<h1 className="font-[var(--font-display-lg)] text-on-surface text-[clamp(2.5rem,6vw+1rem,5.5rem)] leading-none tracking-tight">
{gallery.hero.title}
</h1>
<p className="font-[var(--font-body-base)] text-on-surface-variant text-base lg:text-[20px] max-w-3xl mx-auto opacity-70 leading-relaxed mt-6">
{gallery.hero.description}
</p>
</div>
</section>
{/* Visual 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) => (
<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>
</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>
</div>
</div>
))}
</div>
</section>
{/* Invitation Section */}
<ReadyToJoin data={gallery.join} />
{/* Lightbox Overlay */}
{lightboxEventId !== null && 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}
>
{/* Close button */}
<button
type="button"
className="absolute top-6 right-6 text-white/70 hover:text-white transition-colors p-2 z-[110]"
onClick={closeLightbox}
aria-label="Close Lightbox"
>
<span className="material-symbols-outlined text-4xl">close</span>
</button>
{/* Lightbox content container */}
<div
className="relative flex items-center justify-between w-full max-w-6xl px-4 md:px-12 h-[60vh] sm:h-[70vh] md:h-[80vh]"
onClick={(e) => e.stopPropagation()}
>
{/* 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"
onClick={() => setLightboxImageIndex((prev) => (prev! - 1 + activeEvent.images.length) % activeEvent.images.length)}
aria-label="Previous Image"
>
<span className="material-symbols-outlined text-2xl md:text-3xl">chevron_left</span>
</button>
{/* Active Image */}
<div className="flex-1 flex items-center justify-center h-full relative overflow-hidden select-none px-4">
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
src={getImgSrc(activeImage)}
alt={`${activeEvent.title} Full Highlight`}
className="max-w-full max-h-full object-contain rounded-lg border border-white/5 shadow-2xl transition-all duration-300 animate-in fade-in zoom-in-95 duration-200"
/>
</div>
{/* 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"
onClick={() => setLightboxImageIndex((prev) => (prev! + 1) % activeEvent.images.length)}
aria-label="Next Image"
>
<span className="material-symbols-outlined text-2xl md:text-3xl">chevron_right</span>
</button>
</div>
{/* Info bar below image */}
<div
className="text-center mt-6 px-6 max-w-2xl select-none"
onClick={(e) => e.stopPropagation()}
>
<h3 className="font-[var(--font-display-lg)] text-primary text-base sm:text-lg mb-1.5">
{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"
? `Hình ảnh ${lightboxImageIndex + 1} trên ${activeEvent.images.length}`
: `Image ${lightboxImageIndex + 1} of ${activeEvent.images.length}`
}
</p>
</div>
</div>
)}
</main>
);
}
+57
View File
@@ -0,0 +1,57 @@
"use client";
import Link from "next/link";
type Props = {
data: {
title: string;
description: string;
registerBtn: string;
viewMembersBtn: string;
};
};
export default function ReadyToJoin({ data }: Props) {
return (
<section className="py-[var(--spacing-section-gap)] relative px-[var(--spacing-gutter)] max-w-hd mx-auto">
<div className="max-w-5xl mx-auto glass-panel gold-border p-8 sm:p-12 lg:p-20 rounded-[2.5rem] lg:rounded-[4rem] overflow-hidden relative shadow-2xl">
{/* Background Decor */}
<div className="absolute top-0 right-0 w-1/2 h-full bg-gradient-to-l from-primary/5 to-transparent pointer-events-none" />
<div className="absolute -bottom-24 -right-24 w-96 h-96 bg-primary/10 blur-[120px] rounded-full pointer-events-none" />
<div className="absolute -top-24 -left-24 w-96 h-96 bg-primary/5 blur-[120px] rounded-full pointer-events-none" />
<div className="relative z-10 text-center space-y-6 sm:space-y-8">
{/* Title */}
<h2 className="font-[var(--font-display-lg)] text-[clamp(1.75rem,3.5vw,3rem)] text-on-surface mb-4 leading-[1.1] tracking-tight">
{data.title}
</h2>
{/* Description */}
<p className="font-[var(--font-body-base)] text-sm sm:text-base lg:text-[18px] text-on-surface-variant max-w-3xl mx-auto leading-relaxed opacity-80">
{data.description}
</p>
{/* Call-to-Action Buttons */}
<div className="flex flex-col sm:flex-row justify-center items-center gap-4 sm:gap-6 pt-4">
<Link
href="/registration"
className="w-full sm:w-auto inline-flex items-center justify-center gap-2 gold-gradient-bg text-on-primary px-8 lg:px-10 py-4 rounded-xl font-bold uppercase tracking-widest text-xs lg:text-sm shadow-2xl shadow-primary/20 hover:shadow-primary/40 hover:scale-105 active:scale-95 transition-all duration-300 group"
>
<span>{data.registerBtn}</span>
<span className="material-symbols-outlined group-hover:translate-x-1.5 transition-transform text-lg">
arrow_forward
</span>
</Link>
<Link
href="/registration#members"
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>
</Link>
</div>
</div>
</div>
</section>
);
}
+19 -1
View File
@@ -1,5 +1,8 @@
"use client";
import Link from "next/link";
import { useTranslation } from "@/app/hooks/useTranslation";
const BASE = process.env.NEXT_PUBLIC_BASE_PATH || "";
type GalleryItem = {
@@ -32,6 +35,10 @@ const heightClass: Record<string, string> = {
};
export default function GallerySection({ data }: Props) {
const { lang } = useTranslation();
const isVi = lang === "vi";
const btnLabel = isVi ? "Xem Toàn Bộ Thư Viện" : "View Full Event Gallery";
return (
<section
className="py-16 lg:py-32 max-w-hd mx-auto px-[var(--spacing-gutter)]"
@@ -52,7 +59,7 @@ export default function GallerySection({ data }: Props) {
{/* Grid masonry-style */}
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 lg:gap-6">
{data.items.map((item, i) => (
{data.items.slice(0, 6).map((item, i) => (
<div
key={i}
className={[
@@ -75,6 +82,17 @@ export default function GallerySection({ data }: Props) {
</div>
))}
</div>
{/* Button to full gallery */}
<div className="flex justify-center mt-12 lg:mt-16">
<Link
href="/gallery"
className="inline-flex items-center gap-2 gold-gradient-bg text-on-primary px-8 py-4 font-[var(--font-body-base)] text-sm lg:text-base font-bold uppercase tracking-wider rounded-xl hover:scale-105 active:scale-95 transition-all duration-300 shadow-xl shadow-primary/20 hover:shadow-primary/30"
>
<span>{btnLabel}</span>
<span className="material-symbols-outlined text-sm font-bold">arrow_forward</span>
</Link>
</div>
</section>
);
}