67 lines
2.0 KiB
TypeScript
67 lines
2.0 KiB
TypeScript
import { CinemaCard } from "@/components/site/CinemaCard";
|
|
import type { Cinema, CinemaCategory } from "@/lib/cinemas";
|
|
import { useI18n } from "@/lib/i18n";
|
|
|
|
/** กริดการ์ดโรงหนัง — ใช้ทั้งหน้าแรกและส่วน "โรงหนังอิสระอื่นๆ" */
|
|
export function CinemaGrid({
|
|
cinemas,
|
|
source = "list",
|
|
searchQuery,
|
|
}: {
|
|
cinemas: Cinema[];
|
|
source?: string;
|
|
searchQuery?: string;
|
|
}) {
|
|
return (
|
|
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
|
{cinemas.map((cinema, index) => (
|
|
<CinemaCard
|
|
key={cinema.slug}
|
|
cinema={cinema}
|
|
index={index}
|
|
source={source}
|
|
searchQuery={searchQuery}
|
|
/>
|
|
))}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
type CategoryFilterProps = {
|
|
/** เก็บคีย์หมวดเป็นภาษาไทยเสมอ เพื่อใช้กรองข้อมูลได้ทุกภาษา */
|
|
active: CinemaCategory;
|
|
categories: readonly CinemaCategory[];
|
|
onChange: (category: CinemaCategory) => void;
|
|
};
|
|
|
|
export function CategoryFilter({
|
|
active,
|
|
categories,
|
|
onChange,
|
|
}: CategoryFilterProps) {
|
|
const { messages } = useI18n();
|
|
|
|
return (
|
|
<div className="flex flex-wrap gap-2">
|
|
{categories.map((category) => {
|
|
const isActive = category === active;
|
|
return (
|
|
<button
|
|
key={category}
|
|
type="button"
|
|
onClick={() => onChange(category)}
|
|
aria-pressed={isActive}
|
|
className={
|
|
isActive
|
|
? "rounded-[18px] border border-[#A92626] bg-gradient-to-b from-[#8F0808]/30 to-[#1B1B1B]/0 px-4 py-2 text-sm text-[#D47272]"
|
|
: "rounded-[18px] border border-[#303030] bg-[#242424] px-4 py-2 text-sm text-[#B3B3B3] transition hover:border-[#A92626]/60"
|
|
}
|
|
>
|
|
{messages.categories[category]}
|
|
</button>
|
|
);
|
|
})}
|
|
</div>
|
|
);
|
|
}
|