feat: บทความ 2 หน้า + แชร์/ลิงก์ย่อ + PWA + แอนิเมชัน + SEO/AI + เอกสาร

- บทความจากหลังบ้าน: /for-film-lovers, /for-cinemas (ArticlePage + ArticleEditor แบบบล็อกย่อหน้า/รูป)
- แชร์: ปุ่มบนการ์ดและท้ายหน้ารายละเอียด · ลิงก์ย่อ /c/<slug> (302) · ธีมแก้วตาม DESIGN.md
- PWA: manifest/sw/offline + ถอดการล็อกซูม (WCAG 1.4.4) + touch target ≥44px
- แอนิเมชัน reveal: IntersectionObserver + gate ด้วย html.fx-motion · เคารพ prefers-reduced-motion
- ค้นหา: normalize/ตัดวรรณยุกต์ + AND หลายคำ + จัดอันดับ · รองรับ /?q= จาก SearchAction
- SEO: pageMeta (canonical/OG/Twitter) + JSON-LD (WebSite/Organization/BreadcrumbList/MovieTheater/Article)
- ไม่ฝังโดเมนในโค้ด: origin มาจาก request (x-forwarded-host/proto) ทั้ง canonical, sitemap, robots, ลิงก์แชร์
- กัน AI: robots.txt (Nitro route, บล็อก AI 21 ตัว) + ai.txt + OG image 1200x630
- เอกสาร: README สรุปโปรเจกต์, DESIGN.md (motion/PWA/SEO/ข้อมูล), architecture.html, admin-guide
- tests: 135 ผ่าน (16 ไฟล์)
This commit is contained in:
Bkk1234 committed 2026-11-10 02:31:10 +07:00
1 parent 1e84023a44
commit 319c271d23
72 files changed
+4731 -765

No files matched your search

+15 -11
View File
@@ -1,16 +1,14 @@
import { useState } from "react";
import {
inputClass,
labelClass,
primaryButtonClass,
secondaryButtonClass,
} from "@/components/admin/form-styles";
import type { AboutContent, AboutSection } from "@/lib/content-types";
import type { Locale } from "@/lib/i18n/messages";
const inputClass =
"w-full rounded-lg border border-[#303030] bg-[#141414] px-3 py-2 text-sm text-white outline-none transition focus:border-[#A92626] focus-visible:ring-2 focus-visible:ring-[#A92626]/40";
const labelClass = "flex flex-col gap-1.5 text-xs text-[#999]";
const buttonClass =
"min-h-11 rounded-lg border border-[#303030] px-3 text-sm transition hover:border-[#A92626] hover:text-[#D47272] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[#A92626]";
const primaryButtonClass =
"min-h-11 rounded-lg bg-[#8F0808] px-4 text-sm font-medium transition hover:bg-[#a30a0a] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[#D47272]";
const LOCALE_TABS: Array<{ code: Locale; label: string }> = [
{ code: "th", label: "ไทย" },
{ code: "en", label: "English" },
@@ -106,7 +104,11 @@ export function AboutEditor({
</div>
<div className="flex flex-wrap items-center gap-2">
<button type="button" className={buttonClass} onClick={restoreDefaults}>
<button
type="button"
className={secondaryButtonClass}
onClick={restoreDefaults}
>
คืนค่าตั้งต้น ({locale.toUpperCase()})
</button>
<button
@@ -171,7 +173,9 @@ export function AboutEditor({
className="rounded-xl border border-[#242424] bg-[#141414] p-4"
>
<div className="mb-2 flex items-center justify-between gap-2">
<span className="text-xs text-[#8A8A8A]">ส่วนที่ {index + 1}</span>
<span className="text-xs text-[#8A8A8A]">
ส่วนที่ {index + 1}
</span>
<div className="flex items-center gap-1">
<button
type="button"
@@ -226,7 +230,7 @@ export function AboutEditor({
<button
type="button"
className={`${buttonClass} self-start`}
className={`${secondaryButtonClass} self-start`}
onClick={addSection}
>
+ เพิ่มส่วน
+129
View File
@@ -0,0 +1,129 @@
import {
compactButtonClass,
inputClass,
labelClass,
} from "@/components/admin/form-styles";
import type { ArticleBlock } from "@/lib/content-types";
type ArticleBlockCardProps = {
block: ArticleBlock;
/** ตำแหน่งของบล็อก (0-based) — ใช้แสดงเลขและปิดปุ่มที่เกินขอบ */
index: number;
/** จำนวนบล็อกทั้งหมด — ใช้ปิดปุ่ม "เลื่อนลง" ที่บล็อกสุดท้าย */
total: number;
/** ส่งบล็อกที่แก้แล้วกลับไปทั้งก้อน (ชนิดถูกต้องตาม type ของบล็อก) */
onChange: (next: ArticleBlock) => void;
onMove: (direction: -1 | 1) => void;
onRemove: () => void;
};
/**
* การ์ดแก้ไขบทความหนึ่งบล็อก — ย่อหน้าหรือรูป
* แยกออกมาจาก ArticleEditor เพื่อให้แต่ละไฟล์มีขนาดอ่านไหว
*/
export function ArticleBlockCard({
block,
index,
total,
onChange,
onMove,
onRemove,
}: ArticleBlockCardProps) {
return (
<div className="rounded-xl border border-[#242424] bg-[#141414] p-4">
<div className="mb-3 flex flex-wrap items-center justify-between gap-2">
<span className="text-xs uppercase tracking-wide text-[#999]">
{block.type === "image" ? `รูปที่ ${index + 1}` : `ย่อหน้าที่ ${index + 1}`}
</span>
<div className="flex items-center gap-1.5">
<button
type="button"
className={compactButtonClass}
aria-label={`เลื่อนขึ้น (บล็อกที่ ${index + 1})`}
onClick={() => onMove(-1)}
disabled={index === 0}
>
↑
</button>
<button
type="button"
className={compactButtonClass}
aria-label={`เลื่อนลง (บล็อกที่ ${index + 1})`}
onClick={() => onMove(1)}
disabled={index === total - 1}
>
↓
</button>
<button
type="button"
className={compactButtonClass}
aria-label={`ลบบล็อกที่ ${index + 1}`}
onClick={onRemove}
>
ลบ
</button>
</div>
</div>
{block.type === "paragraph" ? (
<textarea
value={block.text}
onChange={(event) =>
onChange({ type: "paragraph", text: event.target.value })
}
rows={4}
placeholder="พิมพ์ย่อหน้าที่นี่ — เว้นบรรทัดใหม่ได้ ระบบจะแสดงตามที่พิมพ์"
className={inputClass}
/>
) : (
<div className="grid gap-3 md:grid-cols-[minmax(0,1fr)_180px]">
<div className="flex flex-col gap-3">
<label className={labelClass}>
ลิงก์รูป (URL หรือ /images/…)
<input
value={block.src}
onChange={(event) =>
onChange({ ...block, src: event.target.value })
}
placeholder="/images/house-cinema.jpg"
className={inputClass}
/>
</label>
<label className={labelClass}>
คำอธิบายรูป (alt) — จำเป็นต่อการเข้าถึง
<input
value={block.alt}
onChange={(event) =>
onChange({ ...block, alt: event.target.value })
}
placeholder="บรรยากาศภายในโรงหนัง"
className={inputClass}
/>
</label>
<label className={labelClass}>
คำบรรยายใต้รูป (ไม่ใส่ก็ได้)
<input
value={block.caption}
onChange={(event) =>
onChange({ ...block, caption: event.target.value })
}
className={inputClass}
/>
</label>
</div>
<div className="flex items-start justify-center rounded-lg border border-[#242424] bg-[#0D0D0D] p-2">
{block.src.trim() !== "" ? (
<img
src={block.src}
alt=""
className="max-h-[140px] w-full rounded-md object-cover"
/>
) : (
<span className="py-8 text-xs text-[#666]">ยังไม่ได้ใส่ลิงก์รูป</span>
)}
</div>
</div>
)}
</div>
);
}
+215
View File
@@ -0,0 +1,215 @@
import { useState } from "react";
import { ArticleBlockCard } from "@/components/admin/ArticleBlockCard";
import {
inputClass,
labelClass,
primaryButtonClass,
secondaryButtonClass,
} from "@/components/admin/form-styles";
import {
countImages,
createImageBlock,
createParagraphBlock,
moveBlock,
removeBlock,
} from "@/lib/article";
import type { ArticleBlock, ArticleContent } from "@/lib/content-types";
import type { Locale } from "@/lib/i18n/messages";
const LOCALE_TABS: Array<{ code: Locale; label: string }> = [
{ code: "th", label: "ไทย" },
{ code: "en", label: "English" },
];
type ArticleEditorProps = {
value: Record<Locale, ArticleContent>;
defaults: Record<Locale, ArticleContent>;
onChange: (next: Record<Locale, ArticleContent>) => void;
onSave: () => void;
saving: boolean;
/** ป้ายปุ่มบันทึก เช่น "บันทึกหน้าสำหรับคนทำโรงหนัง" */
saveLabel: string;
};
/**
* ตัวแก้ไขหน้าบทความ (ใช้ทั้ง "สำหรับคนทำโรงหนัง" และ "สำหรับคนรักหนัง")
*
* ไฟล์นี้มีหน้าที่เดียว: ถือภาษาที่เลือก + ประกอบฟอร์ม
* - รายละเอียดของแต่ละบล็อก → `ArticleBlockCard`
* - สไตล์ฟอร์ม (input/label/ปุ่ม) → `form-styles`
* ฟิลด์ที่เว้นว่างจะถูกเซิร์ฟเวอร์เติมค่าเริ่มต้น (sanitizeForCinemas / sanitizeForFilmLovers)
*/
export function ArticleEditor({
value,
defaults,
onChange,
onSave,
saving,
saveLabel,
}: ArticleEditorProps) {
const [locale, setLocale] = useState<Locale>("th");
const current = value[locale];
/** อัปเดตฟิลด์ระดับหน้า (title/lead/contact… หรือทั้งรายการ blocks) */
function patch(next: Partial<ArticleContent>) {
onChange({ ...value, [locale]: { ...current, ...next } });
}
/** แทนที่บล็อกตำแหน่งที่ index — ชนิดของบล็อกถูกต้องเสมอ เพราะผู้เรียกส่งมาทั้งก้อน */
function replaceBlock(index: number, next: ArticleBlock) {
patch({
blocks: current.blocks.map((block, i) => (i === index ? next : block)),
});
}
function restoreDefaults() {
onChange({ ...value, [locale]: defaults[locale] });
}
const images = countImages(current.blocks);
const paragraphs = current.blocks.length - images;
return (
<div className="px-6 py-5">
<div className="mb-4 flex flex-wrap items-center justify-between gap-3">
<div
role="tablist"
aria-label="ภาษา"
className="flex items-center gap-1 rounded-lg border border-[#242424] bg-[#141414] p-1"
>
{LOCALE_TABS.map((tab) => (
<button
key={tab.code}
type="button"
role="tab"
aria-selected={locale === tab.code}
onClick={() => setLocale(tab.code)}
className={`min-h-9 rounded-md px-4 text-sm transition ${
locale === tab.code
? "bg-[#242424] font-semibold text-[#D47272]"
: "text-[#999] hover:text-white"
}`}
>
{tab.label}
</button>
))}
</div>
<div className="flex flex-wrap items-center gap-2">
<span className="text-xs text-[#999]">
{paragraphs} ย่อหน้า · {images} รูป
</span>
<button
type="button"
className={secondaryButtonClass}
onClick={restoreDefaults}
>
คืนค่าตั้งต้น ({locale.toUpperCase()})
</button>
<button
type="button"
className={primaryButtonClass}
onClick={onSave}
disabled={saving}
>
{saving ? "กำลังบันทึก…" : saveLabel}
</button>
</div>
</div>
<div className="grid gap-4 lg:grid-cols-2">
<label className={labelClass}>
หัวเรื่อง (H1)
<input
value={current.title}
onChange={(event) => patch({ title: event.target.value })}
placeholder="สำหรับคนทำโรงหนัง"
className={inputClass}
/>
{current.title.trim() === "" ? (
<span className="text-[#D47272]">เว้นว่างไม่ได้ — ระบบจะใช้ค่าเดิม</span>
) : null}
</label>
<label className={labelClass}>
คำเกริ่นนำ (แสดงใต้หัวเรื่อง)
<textarea
value={current.lead}
onChange={(event) => patch({ lead: event.target.value })}
rows={3}
className={inputClass}
/>
</label>
</div>
<div className="mt-6 flex flex-col gap-3">
<div className="flex flex-wrap items-center justify-between gap-2">
<h3 className="text-sm font-semibold text-white">เนื้อหาบทความ</h3>
<div className="flex flex-wrap gap-2">
<button
type="button"
className={secondaryButtonClass}
onClick={() =>
patch({ blocks: [...current.blocks, createParagraphBlock()] })
}
>
+ เพิ่มย่อหน้า
</button>
<button
type="button"
className={secondaryButtonClass}
onClick={() =>
patch({ blocks: [...current.blocks, createImageBlock()] })
}
>
+ เพิ่มรูปภาพ
</button>
</div>
</div>
{current.blocks.length === 0 ? (
<p className="rounded-lg border border-dashed border-[#303030] p-6 text-center text-sm text-[#999]">
ยังไม่มีเนื้อหา — กด “เพิ่มย่อหน้า” หรือ “เพิ่มรูปภาพ” เพื่อเริ่มเขียน
</p>
) : null}
{current.blocks.map((block, index) => (
<ArticleBlockCard
key={`${block.type}-${index}`}
block={block}
index={index}
total={current.blocks.length}
onChange={(next) => replaceBlock(index, next)}
onMove={(direction) =>
patch({ blocks: moveBlock(current.blocks, index, direction) })
}
onRemove={() =>
patch({ blocks: removeBlock(current.blocks, index) })
}
/>
))}
</div>
<div className="mt-6 grid gap-4 lg:grid-cols-2">
<label className={labelClass}>
หัวข้อการ์ดติดต่อ
<input
value={current.contactHeading}
onChange={(event) => patch({ contactHeading: event.target.value })}
className={inputClass}
/>
</label>
<label className={labelClass}>
ข้อความในการ์ดติดต่อ
<textarea
value={current.contactNote}
onChange={(event) => patch({ contactNote: event.target.value })}
rows={3}
className={inputClass}
/>
</label>
</div>
</div>
);
}
+21
View File
@@ -0,0 +1,21 @@
/**
* คลาสฟอร์มที่ใช้ร่วมทุกแท็บของหลังบ้าน
* อยู่ที่เดียวเพื่อให้หน้าตาเหมือนกันหมด และแก้สไตล์ครั้งเดียวมีผลทุกที่
* (ห้ามประกาศ inputClass/labelClass ซ้ำใน component)
*/
export const inputClass =
"w-full rounded-lg border border-[#303030] bg-[#141414] px-3 py-2 text-sm text-white outline-none transition focus:border-[#A92626] focus-visible:ring-2 focus-visible:ring-[#A92626]/40";
export const labelClass = "flex flex-col gap-1.5 text-xs text-[#999]";
/** ปุ่มหลัก — ใช้กับการกระทำที่ต้องการให้เด่น (เช่น บันทึก) */
export const primaryButtonClass =
"min-h-11 rounded-lg bg-[#8F0808] px-4 text-sm font-medium transition hover:bg-[#a30a0a] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[#D47272]";
/** ปุ่มรอง — ใช้กับการกระทำทั่วไป (เช่น เพิ่มบล็อก/คืนค่าตั้งต้น) */
export const secondaryButtonClass =
"min-h-11 rounded-lg border border-[#303030] px-3 text-sm transition hover:border-[#A92626] hover:text-[#D47272] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[#A92626]";
/** ปุ่มขนาดกะทัดรัด — ใช้กับเครื่องมือในแต่ละบล็อก (↑ ↓ ลบ) */
export const compactButtonClass =
"min-h-9 rounded-lg border border-[#303030] px-2.5 text-sm text-[#B3B3B3] transition hover:border-[#A92626] hover:text-[#D47272] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[#A92626] disabled:opacity-40";
+40 -21
View File
@@ -1,8 +1,8 @@
import { IconChevronLeft, IconChevronRight } from "@tabler/icons-react";
import type { ReactNode } from "react";
import { useState, type ReactNode } from "react";
import { Logo } from "@/components/site/Logo";
import { splitGallery } from "@/lib/gallery";
import { rotateGallery, splitGallery } from "@/lib/gallery";
import { useI18n } from "@/lib/i18n";
type GalleryProps = {
@@ -38,52 +38,71 @@ function GallerySlot({ photo, alt, placeholder, className }: GallerySlotProps) {
);
}
/** แกลเลอรีภาพโรงหนัง — ป้าย "+N" คำนวณจากจำนวนรูปจริงในข้อมูล */
/** แกลเลอรีภาพโรงหนัง — ปุ่มลูกศรเลื่อนดูภาพทั้งหมดโดยภาพหลักและภาพย่อยเลื่อนตามกัน */
export function Gallery({ photos, cinemaName }: GalleryProps) {
const { messages } = useI18n();
const { main, thumbs, remaining } = splitGallery(photos);
const [startIndex, setStartIndex] = useState(0);
const total = photos.length;
// หมุนรายการตามตำแหน่งที่เลือก แล้วแบ่งเป็นภาพหลัก + ภาพย่อยตามเดิม
const { main, thumbs, remaining } = splitGallery(
rotateGallery(photos, startIndex),
);
const [firstThumb = null, secondThumb = null] = thumbs;
const canNavigate = total > 1;
function step(direction: 1 | -1) {
setStartIndex((current) => current + direction);
}
return (
<section className="grid gap-6 lg:grid-cols-[minmax(0,807px)_minmax(0,387px)]">
<div className="relative overflow-hidden rounded-xl">
<GallerySlot
key={`main-${main ?? "empty"}`}
photo={main}
alt={`${messages.gallery.main} — ${cinemaName}`}
placeholder={<Logo size="md" />}
className="aspect-[269/202] w-full lg:aspect-auto lg:h-[606px]"
className="fx-swap aspect-[269/202] w-full lg:aspect-auto lg:h-[606px]"
/>
<button
type="button"
aria-label={messages.gallery.previous}
className="absolute left-6 top-1/2 flex size-10 -translate-y-1/2 items-center justify-center rounded-full bg-black/50"
>
<IconChevronLeft size={24} />
</button>
<button
type="button"
aria-label={messages.gallery.next}
className="absolute right-6 top-1/2 flex size-10 -translate-y-1/2 items-center justify-center rounded-full bg-black/50"
>
<IconChevronRight size={24} />
</button>
{canNavigate ? (
<>
<button
type="button"
onClick={() => step(-1)}
aria-label={messages.gallery.previous}
className="absolute left-6 top-1/2 flex size-10 -translate-y-1/2 items-center justify-center rounded-full bg-black/50 text-white transition after:absolute after:-inset-1 after:content-[''] hover:bg-black/75 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#A92626] active:scale-95"
>
<IconChevronLeft size={24} />
</button>
<button
type="button"
onClick={() => step(1)}
aria-label={messages.gallery.next}
className="absolute right-6 top-1/2 flex size-10 -translate-y-1/2 items-center justify-center rounded-full bg-black/50 text-white transition after:absolute after:-inset-1 after:content-[''] hover:bg-black/75 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#A92626] active:scale-95"
>
<IconChevronRight size={24} />
</button>
</>
) : null}
</div>
<div className="grid grid-cols-2 gap-6 lg:grid-cols-1 lg:grid-rows-2">
<div className="overflow-hidden rounded-xl">
<GallerySlot
key={`thumb-1-${firstThumb ?? "empty"}`}
photo={firstThumb}
alt={`${messages.gallery.second} — ${cinemaName}`}
placeholder={<Logo size="sm" />}
className="aspect-[387/290] w-full"
className="fx-swap aspect-[387/290] w-full"
/>
</div>
<div className="relative overflow-hidden rounded-xl">
<GallerySlot
key={`thumb-2-${secondThumb ?? "empty"}`}
photo={secondThumb}
alt={`${messages.gallery.third} — ${cinemaName}`}
placeholder={<Logo size="sm" />}
className="aspect-[387/290] w-full"
className="fx-swap aspect-[387/290] w-full"
/>
{remaining > 0 ? (
<div className="absolute bottom-2.5 right-2.5 flex size-[60px] items-center justify-center rounded-lg bg-black/80 text-lg font-medium">
+44 -12
View File
@@ -1,5 +1,7 @@
import { IconCircleCheck, IconMapPin, IconSearch } from "@tabler/icons-react";
import { useRef, type FormEvent } from "react";
import { Reveal } from "@/components/site/Reveal";
import type { NearMeStatus } from "@/hooks/use-near-me";
import { useI18n } from "@/lib/i18n";
@@ -8,10 +10,15 @@ type HeroSectionProps = {
onQueryChange: (query: string) => void;
nearMeStatus: NearMeStatus;
onRequestLocation: () => void;
/** เรียกเมื่อผู้ใช้กดปุ่ม "ค้นหา" หรือกด Enter — ใช้เลื่อนไปที่ผลลัพธ์ (การกรองยังทำงานสดขณะพิมพ์) */
onSubmitSearch: () => void;
};
/** ข้อความสถานะของปุ่ม "ใกล้ฉัน" — แสดงเฉพาะตอนกำลังหา/ผิดพลาด/พร้อมใช้ */
function statusMessage(status: NearMeStatus, messages: ReturnType<typeof useI18n>["messages"]) {
function statusMessage(
status: NearMeStatus,
messages: ReturnType<typeof useI18n>["messages"],
) {
switch (status) {
case "locating":
return messages.search.locating;
@@ -34,38 +41,63 @@ export function HeroSection({
onQueryChange,
nearMeStatus,
onRequestLocation,
onSubmitSearch,
}: HeroSectionProps) {
const { messages } = useI18n();
const status = statusMessage(nearMeStatus, messages);
const isReady = nearMeStatus === "ready";
const inputRef = useRef<HTMLInputElement>(null);
/**
* ปุ่ม "ค้นหา" / Enter — ไม่ได้ทำหน้าที่กรอง (กรองสดอยู่แล้วใน onChange)
* หน้าที่คือ: กันหน้าโหลดใหม่, ปิดคีย์บอร์ดมือถือ, แล้วเลื่อนไปที่ผลลัพธ์
*/
function handleSubmit(event: FormEvent<HTMLFormElement>) {
event.preventDefault();
inputRef.current?.blur();
onSubmitSearch();
}
return (
<section className="mx-auto flex max-w-[1016px] flex-col items-center gap-10 pt-24 md:pt-[167px]">
<div className="flex max-w-[745px] flex-col items-center gap-4 text-center">
<Reveal
delay={60}
className="flex max-w-[745px] flex-col items-center gap-4 text-center"
>
<h1 className="text-4xl font-bold leading-[1.3] md:text-[56px]">
{messages.hero.titlePrefix}
<span className="text-[#A92626]">{messages.hero.titleHighlight}</span>
<span className="text-[#D47272]">{messages.hero.titleHighlight}</span>
{messages.hero.titleSuffix}
</h1>
<p className="text-base md:text-xl">{messages.hero.subtitle}</p>
</div>
</Reveal>
<div className="w-full rounded-2xl border border-[#303030] bg-[#1B1B1B]/80 px-4 py-6 backdrop-blur-[32px] md:px-10">
<div className="flex h-14 items-center gap-3 rounded-lg border border-[#1B1B1B] bg-[#1F1F1F] px-5">
<Reveal
delay={200}
className="w-full rounded-2xl border border-[#303030] bg-[#1B1B1B]/80 px-4 py-6 backdrop-blur-[32px] md:px-10"
>
<form
role="search"
onSubmit={handleSubmit}
className="flex h-14 items-center gap-3 rounded-lg border border-[#1B1B1B] bg-[#1F1F1F] px-5 transition-colors duration-300 focus-within:border-[#A92626]/70"
>
<IconSearch size={16} className="shrink-0 text-[#999]" />
<input
ref={inputRef}
value={query}
onChange={(event) => onQueryChange(event.target.value)}
placeholder={messages.search.placeholder}
aria-label={messages.search.placeholder}
className="min-w-0 flex-1 bg-transparent text-sm text-white outline-none placeholder:text-[#454545]"
type="search"
enterKeyHint="search"
className="min-w-0 flex-1 bg-transparent text-sm text-white outline-none placeholder:text-[#8A8A8A] [&::-webkit-search-cancel-button]:hidden"
/>
<button
type="button"
onClick={onRequestLocation}
disabled={nearMeStatus === "locating"}
aria-label={messages.search.nearMe}
className={`hidden items-center gap-2 border-l border-[#999] px-4 text-sm transition disabled:opacity-60 sm:flex ${
className={`relative hidden items-center gap-2 border-l border-[#999] px-4 text-sm transition after:absolute after:-inset-y-3 after:inset-x-0 after:content-[''] disabled:opacity-60 sm:flex ${
isReady ? "text-[#D47272]" : "text-[#999] hover:text-white"
}`}
>
@@ -73,12 +105,12 @@ export function HeroSection({
{messages.search.nearMe}
</button>
<button
type="button"
className="h-8 rounded-lg border border-[#8F0808] bg-[#8F0808] px-6 text-sm font-medium transition hover:bg-[#a30a0a]"
type="submit"
className="relative h-8 rounded-lg border border-[#8F0808] bg-[#8F0808] px-6 text-sm font-medium transition after:absolute after:-inset-y-1.5 after:-inset-x-1 after:content-[''] hover:bg-[#a30a0a]"
>
{messages.search.submit}
</button>
</div>
</form>
{status ? (
<p
@@ -91,7 +123,7 @@ export function HeroSection({
{status}
</p>
) : null}
</div>
</Reveal>
</section>
);
}
+139
View File
@@ -0,0 +1,139 @@
import { IconArrowBackUp } from "@tabler/icons-react";
import { Link } from "react-router";
import { footerIcon } from "@/components/site/footer-icons";
import { Reveal } from "@/components/site/Reveal";
import { SiteShell } from "@/components/site/SiteShell";
import { useContent } from "@/lib/content-context";
import type { ArticleBlock, ArticleContent } from "@/lib/content-types";
/** บล็อกบทความหนึ่งชิ้น — ย่อหน้าหรือรูป (รูปมีคำบรรยายได้) */
function ArticleBlockView({
block,
index,
}: {
block: ArticleBlock;
index: number;
}) {
// ไล่จังหวะแบบสั้น ๆ แต่ไม่เกิน 3 บล็อกแรก (บล็อกท้าย ๆ จะได้ไม่รอนาน)
const delay = 100 + Math.min(index, 3) * 60;
if (block.type === "image") {
return (
<Reveal delay={delay}>
<figure className="flex flex-col gap-2">
<img
src={block.src}
alt={block.alt}
loading="lazy"
className="w-full rounded-xl bg-[#242424] object-cover"
/>
{block.caption ? (
<figcaption className="font-content text-[14px] leading-[1.7] text-[#999]">
{block.caption}
</figcaption>
) : null}
</figure>
</Reveal>
);
}
return (
<Reveal delay={delay}>
<p className="font-content max-w-[860px] text-[18px] leading-[1.95] text-[#C7C7C7] md:text-[20px]">
{block.text}
</p>
</Reveal>
);
}
/**
* โครงหน้าบทความที่ใช้ร่วมกัน (สำหรับคนทำโรงหนัง / สำหรับคนรักหนัง)
* ภาษาภาพเดียวกับหน้า "เกี่ยวกับเรา": กรอบ 1440 + px-[108px], ฟอนต์เนื้อหา IBM Plex Sans Thai Looped,
* การ์ดติดต่อไล่แดงขอบ rgba(169,38,38,0.45) และไอคอนโซเชียลชุดเดียวกับ footer
*/
export function ArticlePage({
content,
backLabel,
}: {
content: ArticleContent;
backLabel: string;
}) {
const { site } = useContent();
return (
<SiteShell variant="detail">
<main className="relative z-10 mx-auto flex w-full max-w-[1440px] flex-col gap-10 px-5 pb-16 pt-4 md:px-[108px] md:pt-6">
<Reveal kind="fade">
<Link
to="/"
className="inline-flex w-fit items-center gap-2 text-xl font-medium transition hover:text-[#D47272]"
>
<IconArrowBackUp size={24} />
{backLabel}
</Link>
</Reveal>
<Reveal delay={40} className="flex flex-col gap-4">
<h1 className="text-[32px] font-bold leading-[1.3] md:text-[40px]">
{content.title}
</h1>
<p className="font-content max-w-[860px] text-[19px] leading-[1.8] text-[#C4C4C4] md:text-[21px]">
{content.lead}
</p>
</Reveal>
<article className="flex flex-col gap-7">
{content.blocks.map((block, index) => (
<ArticleBlockView
key={`${block.type}-${index}`}
block={block}
index={index}
/>
))}
</article>
<Reveal kind="fade">
<section
className="flex flex-col gap-6 rounded-xl p-6 backdrop-blur-sm lg:flex-row lg:items-center lg:justify-between"
style={{
border: "1px solid rgba(169,38,38,0.45)",
background:
"linear-gradient(180deg, rgba(143,8,8,0.18) 0%, rgba(27,27,27,0.85) 65%, rgba(13,13,13,0.7) 100%)",
}}
>
<div className="flex flex-col gap-3">
<h2 className="text-2xl font-semibold leading-[1.3]">
{content.contactHeading}
</h2>
<p className="font-content max-w-[720px] text-[16px] leading-[1.9] text-[#C4C4C4] md:text-[17px]">
{content.contactNote}
</p>
</div>
{site.footer.length > 0 ? (
<div className="flex flex-wrap items-center gap-2">
{site.footer.map((item) => {
const Icon = footerIcon(item.icon_name);
return (
<a
key={item.id}
href={item.href}
aria-label={item.label}
title={item.label}
target="_blank"
rel="noreferrer"
className="flex size-11 items-center justify-center rounded-full bg-white/90 text-[#0D0D0D] transition hover:bg-white"
>
<Icon size={20} />
</a>
);
})}
</div>
) : null}
</section>
</Reveal>
</main>
</SiteShell>
);
}
+23 -6
View File
@@ -5,6 +5,10 @@ import {
} from "@tabler/icons-react";
import { Link } from "react-router";
import { ShareButton } from "@/components/site/ShareButton";
import { useNearMe } from "@/hooks/use-near-me";
import { useReveal } from "@/hooks/use-reveal";
import { trackEvent } from "@/lib/analytics-client";
import {
CARD_GRADIENTS,
cinemaCategoryLabel,
@@ -13,8 +17,6 @@ import {
type Cinema,
} from "@/lib/cinemas";
import { formatDistance } from "@/lib/geo";
import { trackEvent } from "@/lib/analytics-client";
import { useNearMe } from "@/hooks/use-near-me";
import { useI18n } from "@/lib/i18n";
type CinemaCardProps = {
@@ -43,9 +45,18 @@ export function CinemaCard({
messages.card.distanceFallback,
);
// ไล่จังหวะโผล่ทีละใบตามคอลัมน์ (เริ่มหลังหัวข้อ/หมวด เพื่อให้ดูเป็นลำดับ)
const { ref, revealed, style } = useReveal<HTMLElement>(
140 + (index % 4) * 70,
);
return (
<article
className={`relative flex aspect-[3/4] flex-col justify-end overflow-hidden rounded-[20px] bg-gradient-to-br p-2 lg:aspect-auto lg:h-[308px] ${gradient}`}
ref={ref}
data-reveal="zoom"
data-revealed={revealed ? "" : undefined}
style={style}
className={`group relative flex aspect-[3/4] flex-col justify-end overflow-hidden rounded-[20px] bg-gradient-to-br p-2 transition-[translate,box-shadow] duration-300 ease-out hover:-translate-y-1 hover:shadow-[0_18px_38px_-24px_rgba(143,8,8,0.75)] lg:aspect-auto lg:h-[308px] ${gradient}`}
>
{cover ? (
<>
@@ -54,7 +65,7 @@ export function CinemaCard({
alt=""
aria-hidden="true"
loading="lazy"
className="absolute inset-0 size-full object-cover"
className="absolute inset-0 size-full object-cover transition-transform duration-700 ease-out group-hover:scale-[1.06]"
/>
{/* ไล่เงาเพื่อให้ตัวอักษรบนการ์ดอ่านได้ */}
<div
@@ -64,12 +75,18 @@ export function CinemaCard({
</>
) : null}
<div className="relative flex flex-col gap-1.5 rounded-2xl border border-white/10 bg-[#1B1B1B]/80 p-3 backdrop-blur-xl">
{/* ปุ่มแชร์ลอยมุมขวาบนของการ์ด */}
<div className="absolute right-3 top-3 z-10">
<ShareButton slug={cinema.slug} title={cinemaName(cinema, locale)} />
</div>
<div className="relative flex flex-col gap-1.5 rounded-2xl border border-white/10 bg-[#1B1B1B]/80 p-3 backdrop-blur-xl transition-colors duration-300 group-hover:border-[#A92626]/40">
<span className="text-[10px] text-[#B3B3B3]">{distanceLabel}</span>
<h3 className="text-sm font-semibold">{cinemaName(cinema, locale)}</h3>
<p className="flex items-center gap-1.5 text-xs text-[#B3B3B3]">
<IconMapPin size={12} />
{cinemaLocationLabel(cinema, locale) || messages.card.locationFallback}
{cinemaLocationLabel(cinema, locale) ||
messages.card.locationFallback}
</p>
<p className="flex items-center gap-1.5 text-xs text-[#B3B3B3]">
<IconBuildingCommunity size={12} />
+4 -4
View File
@@ -51,11 +51,11 @@ export function CategoryFilter({
type="button"
onClick={() => onChange(category)}
aria-pressed={isActive}
className={
className={`relative rounded-[18px] border px-4 py-2 text-sm after:absolute after:-inset-y-1.5 after:inset-x-0 after:content-[''] ${
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"
}
? "border-[#A92626] bg-gradient-to-b from-[#8F0808]/30 to-[#1B1B1B]/0 text-[#D47272]"
: "border-[#303030] bg-[#242424] text-[#B3B3B3] transition hover:border-[#A92626]/60"
}`}
>
{messages.categories[category]}
</button>
+131 -32
View File
@@ -1,6 +1,14 @@
import { useI18n } from "@/lib/i18n";
import { LOCALE_OPTIONS } from "@/lib/i18n/messages";
import { IconCheck, IconChevronDown } from "@tabler/icons-react";
import {
useEffect,
useRef,
useState,
type KeyboardEvent as ReactKeyboardEvent,
} from "react";
import { COLORS } from "@/lib/design-tokens";
import { useI18n } from "@/lib/i18n";
import { LOCALE_OPTIONS, type Locale } from "@/lib/i18n/messages";
/** ธงชาติไทยย่อส่วน */
function FlagTh() {
@@ -47,40 +55,131 @@ function FlagEn() {
const FLAGS = { th: FlagTh, en: FlagEn } as const;
/**
* สลับภาษาเป็นปุ่มสองปุ่ม (TH / EN) — ไม่มีเมนูให้เปิด/ปิด
* จึงไม่มีปัญหาคลิกพลาดหรือเมนูถูกบัง และกดครั้งเดียวเปลี่ยนทันที
* สลับภาษาเป็น "ปุ่มเดียว + dropdown"
*
* - ปุ่มแสดงภาษาปัจจุบัน (ธง + รหัส) พร้อมลูกศรบอกว่ามีกั้นลงมา
* - เลือกแล้วเปลี่ยนภาษาทันทีและปิดเมนู คืนโฟกัสกลับไปที่ปุ่ม
* - ปิดได้ด้วยคลิกนอกเมนู หรือกด Escape
* (เดิมเป็นปุ่ม TH/EN สองปุ่ม — ยุบเหลือปุ่มเดียวเพื่อประหยัดที่ใน header มือถือ)
*/
export function LocaleSwitcher() {
const { locale, setLocale } = useI18n();
const { locale, setLocale, messages } = useI18n();
const [open, setOpen] = useState(false);
const wrapperRef = useRef<HTMLDivElement>(null);
const triggerRef = useRef<HTMLButtonElement>(null);
// ปิดเมนูเมื่อคลิกที่อื่น หรือกด Escape
useEffect(() => {
if (!open) return;
// ให้คีย์บอร์ดเริ่มที่ตัวเลือกปัจจุบัน (มาตรฐานของ role="menu")
wrapperRef.current
?.querySelector<HTMLButtonElement>(
'[role="menuitemradio"][aria-checked="true"]',
)
?.focus();
function handlePointerDown(event: MouseEvent) {
if (!wrapperRef.current?.contains(event.target as Node)) setOpen(false);
}
function handleKeyDown(event: KeyboardEvent) {
if (event.key !== "Escape") return;
setOpen(false);
triggerRef.current?.focus();
}
document.addEventListener("mousedown", handlePointerDown);
document.addEventListener("keydown", handleKeyDown);
return () => {
document.removeEventListener("mousedown", handlePointerDown);
document.removeEventListener("keydown", handleKeyDown);
};
}, [open]);
const current =
LOCALE_OPTIONS.find((option) => option.locale === locale) ??
LOCALE_OPTIONS[0];
const CurrentFlag = FLAGS[current.locale];
/** เลื่อนโฟกัสด้วยลูกศรขึ้น/ลงในเมนู (role="menu" ต้องรองรับคีย์บอร์ด) */
function handleMenuKeyDown(event: ReactKeyboardEvent<HTMLDivElement>) {
if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return;
event.preventDefault();
const items = Array.from(
wrapperRef.current?.querySelectorAll<HTMLButtonElement>(
'[role="menuitemradio"]',
) ?? [],
);
if (items.length === 0) return;
const currentIndex = items.indexOf(
document.activeElement as HTMLButtonElement,
);
const step = event.key === "ArrowDown" ? 1 : -1;
const nextIndex = (currentIndex + step + items.length) % items.length;
items[nextIndex]?.focus();
}
function choose(next: Locale) {
setLocale(next);
setOpen(false);
triggerRef.current?.focus();
}
return (
<div role="group" aria-label="ภาษา" className="flex items-center gap-1">
{LOCALE_OPTIONS.map((option) => {
const Flag = FLAGS[option.locale];
const isActive = option.locale === locale;
return (
<button
key={option.locale}
type="button"
lang={option.locale}
onClick={() => setLocale(option.locale)}
aria-pressed={isActive}
title={option.name}
className={`flex items-center gap-1.5 rounded-lg px-1.5 py-1 text-sm transition sm:gap-2 sm:px-2 ${
isActive
? "bg-[#242424] font-semibold text-[#D47272]"
: "text-[#B3B3B3] hover:text-white"
}`}
>
<span className="hidden sm:block">
<Flag />
</span>
<span className="text-base font-medium leading-none sm:text-lg">
{option.code}
</span>
</button>
);
})}
<div ref={wrapperRef} className="relative">
<button
ref={triggerRef}
type="button"
aria-haspopup="menu"
aria-expanded={open}
aria-label={`${messages.nav.language}: ${current.name}`}
title={current.name}
onClick={() => setOpen((value) => !value)}
className="flex min-h-10 items-center gap-1.5 rounded-lg px-2 text-sm text-[#B3B3B3] transition hover:text-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-[#A92626] after:absolute after:-inset-y-1 after:-inset-x-0.5 after:content-[''] sm:gap-2"
>
<CurrentFlag />
<span className="font-medium leading-none">{current.code}</span>
<IconChevronDown
size={14}
aria-hidden="true"
className={`transition-transform duration-200 ${open ? "rotate-180" : ""}`}
/>
</button>
{open ? (
<div
role="menu"
aria-label={messages.nav.language}
onKeyDown={handleMenuKeyDown}
className="absolute right-0 top-[calc(100%+8px)] z-30 flex w-[190px] flex-col gap-1 rounded-xl border border-[#303030] bg-[#141414] p-2 shadow-lg"
>
{LOCALE_OPTIONS.map((option) => {
const Flag = FLAGS[option.locale];
const isActive = option.locale === locale;
return (
<button
key={option.locale}
type="button"
role="menuitemradio"
aria-checked={isActive}
lang={option.locale}
onClick={() => choose(option.locale)}
className={`flex min-h-11 items-center gap-2 rounded-lg px-2.5 text-sm transition ${
isActive
? "bg-[#242424] font-semibold text-[#D47272]"
: "text-[#B3B3B3] hover:bg-[#1B1B1B] hover:text-white"
}`}
>
<Flag />
<span className="flex-1 text-left">{option.name}</span>
{isActive ? <IconCheck size={16} aria-hidden="true" /> : null}
</button>
);
})}
</div>
) : null}
</div>
);
}
+40
View File
@@ -0,0 +1,40 @@
import { Link } from "react-router";
/**
* ลิงก์เมนูใน header — ใช้ร่วมทั้งแถบเดสก์ท็อปและเมนูมือถือ
* `variant` ต่างกันเพราะเดสก์ท็อปมีกรอบ/ไอคอนสถานะ active ส่วนเมนูมือถือเป็นรายการแนวตั้ง
*/
export function NavLink({
to,
label,
isActive,
variant,
}: {
to: string;
label: string;
isActive: boolean;
variant: "bar" | "panel";
}) {
const className =
variant === "bar"
? `relative flex items-center rounded-lg border px-3 py-1.5 text-sm transition after:absolute after:-inset-y-2 after:-inset-x-0.5 after:content-[''] ${
isActive
? "border-[#A92626] bg-[#8F0808]/20 text-white"
: "border-[#303030] text-[#B3B3B3] hover:border-[#A92626]/60 hover:text-white"
}`
: `flex min-h-11 items-center rounded-lg px-3 text-sm transition ${
isActive
? "bg-[#242424] text-white"
: "text-[#B3B3B3] hover:bg-[#1B1B1B] hover:text-white"
}`;
return (
<Link
to={to}
aria-current={isActive ? "page" : undefined}
className={className}
>
{label}
</Link>
);
}
+41
View File
@@ -0,0 +1,41 @@
import type { ReactNode } from "react";
import { useReveal } from "@/hooks/use-reveal";
import type { RevealKind } from "@/lib/motion";
type RevealProps = {
children: ReactNode;
/** rise = เลื่อนขึ้นเบา ๆ (ค่าตั้งต้น) · fade = จางเข้าอย่างเดียว · zoom = ขยายเล็กน้อย */
kind?: RevealKind;
/** หน่วงก่อนเริ่ม (ms) — ใช้ทำจังหวะไล่กันในกริด/คอลัมน์ */
delay?: number;
className?: string;
};
/**
* ห่อบล็อกให้ "ค่อย ๆ โผล่" เมื่อเลื่อนมาถึง
*
* ใช้ `data-revealed` เป็น attribute ว่าง (ไม่ใช่ boolean) เพราะ CSS เลือกด้วย
* selector `[data-revealed]` ใน global.css
* เป็น <div> ธรรมดา — ใช้ในบริบท block/flex/grid เท่านั้น (ไม่ใช้กับ inline)
*/
export function Reveal({
children,
kind = "rise",
delay = 0,
className,
}: RevealProps) {
const { ref, revealed, style } = useReveal<HTMLDivElement>(delay);
return (
<div
ref={ref}
data-reveal={kind}
data-revealed={revealed ? "" : undefined}
style={style}
className={className}
>
{children}
</div>
);
}
+129
View File
@@ -0,0 +1,129 @@
import { IconCheck, IconShare } from "@tabler/icons-react";
import {
useEffect,
useRef,
useState,
type MouseEvent as ReactMouseEvent,
} from "react";
import { useI18n } from "@/lib/i18n";
import {
buildShareUrl,
buildShortSharePath,
resolveShareOrigin,
shareOrCopy,
type ShareResult,
} from "@/lib/share";
import { useShareOrigin } from "@/lib/share-origin";
type ShareButtonProps = {
/** slug ของโรงหนัง — ใช้สร้างลิงก์ย่อ `/c/<slug>` */
slug: string;
/** ชื่อที่ส่งให้แผงแชร์ของระบบ */
title: string;
/** `icon` = ปุ่มกลมบนการ์ด · `wide` = ปุ่มมีข้อความ (ใช้ท้ายหน้ารายละเอียด) */
variant?: "icon" | "wide";
};
/**
* ปุ่มแชร์โรงหนัง — ลิงก์ย่อ `/c/<slug>` บนโดเมนที่ตั้งใน env `SHARE_ORIGIN`
* - มี Web Share (มือถือ) → เปิดแผงแชร์ของระบบ และคัดลอกลิงก์สำรองให้ด้วย
* - ไม่มี → คัดลอกลิงก์ลงคลิปบอร์ด แล้วบอกผลผ่าน aria-live
*/
export function ShareButton({
slug,
title,
variant = "icon",
}: ShareButtonProps) {
const { messages } = useI18n();
const configuredOrigin = useShareOrigin();
const [result, setResult] = useState<ShareResult | null>(null);
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
// ล้างตัวจับเวลาเมื่อ unmount กัน state อัปเดตหลัง component ถูกถอด
useEffect(() => {
return () => {
if (timerRef.current) clearTimeout(timerRef.current);
};
}, []);
async function handleClick(event: ReactMouseEvent<HTMLButtonElement>) {
// กันการ์ดที่ห่ออยู่ถูกคลิกตาม (การ์ดมีลิงก์ "ดูรายละเอียด" ข้างใน)
event.preventDefault();
event.stopPropagation();
const url = buildShareUrl(
resolveShareOrigin(configuredOrigin, window.location.origin),
buildShortSharePath(slug),
);
const next = await shareOrCopy({ title, url });
setResult(next);
if (timerRef.current) clearTimeout(timerRef.current);
timerRef.current = setTimeout(() => setResult(null), 2500);
}
const isCopy = result === "copied" || result === "shared";
const label =
result === "failed"
? messages.share.failed
: isCopy
? messages.share.copied
: variant === "wide"
? messages.share.pageLabel
: messages.share.label;
const icon = isCopy ? <IconCheck size={16} /> : <IconShare size={16} />;
if (variant === "wide") {
return (
<div className="flex flex-wrap items-center gap-3">
<button
type="button"
onClick={handleClick}
title={title}
className={`flex min-h-11 items-center gap-2 rounded-lg border px-4 text-sm backdrop-blur transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-[#A92626] ${
result === "failed"
? "border-[#A92626]/60 bg-[#1B1B1B]/80 text-[#D47272]"
: isCopy
? "border-[#D47272]/50 bg-[#1B1B1B]/80 text-[#D47272]"
: "border-[#332B2B] bg-[#1B1B1B]/80 text-white hover:border-[#A92626]/60 hover:bg-[#242424]"
}`}
>
{icon}
{label}
</button>
<span
role="status"
aria-live="polite"
className="text-xs text-[#B3B3B3]"
>
{result ? label : ""}
</span>
</div>
);
}
return (
<div className="relative">
<button
type="button"
onClick={handleClick}
aria-label={`${messages.share.label}: ${title}`}
title={messages.share.label}
className={`relative flex size-9 items-center justify-center rounded-xl border backdrop-blur-xl transition after:absolute after:-inset-1.5 after:content-[''] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#A92626] active:scale-95 ${
result === "failed"
? "border-[#A92626]/60 bg-[#1B1B1B]/80 text-[#D47272]"
: isCopy
? "border-[#D47272]/50 bg-[#1B1B1B]/80 text-[#D47272]"
: "border-white/10 bg-[#1B1B1B]/80 text-white hover:border-[#A92626]/60 hover:bg-[#242424] hover:text-[#D47272]"
}`}
>
{icon}
</button>
<span role="status" aria-live="polite" className="sr-only">
{result ? label : ""}
</span>
</div>
);
}
+13 -1
View File
@@ -1,7 +1,7 @@
import { Link } from "react-router";
import { Logo } from "@/components/site/Logo";
import { footerIcon } from "@/components/site/footer-icons";
import { Logo } from "@/components/site/Logo";
import { useContent } from "@/lib/content-context";
import { useI18n } from "@/lib/i18n";
@@ -19,6 +19,18 @@ export function SiteFooter() {
<div className="flex items-center gap-4">
<Logo size="sm" />
<nav aria-label="เมนูล่าง" className="flex items-center gap-3 text-xs">
<Link
to="/for-film-lovers"
className="text-[#B3B3B3] transition hover:text-white"
>
{messages.nav.forFilmLovers}
</Link>
<Link
to="/for-cinemas"
className="text-[#B3B3B3] transition hover:text-white"
>
{messages.nav.forCinemas}
</Link>
<Link
to="/about"
className="text-[#B3B3B3] transition hover:text-white"
+50 -14
View File
@@ -1,7 +1,8 @@
import { Link, useLocation } from "react-router";
import { Logo } from "@/components/site/Logo";
import { LocaleSwitcher } from "@/components/site/LocaleSwitcher";
import { Logo } from "@/components/site/Logo";
import { NavLink } from "@/components/site/NavLink";
import { useI18n } from "@/lib/i18n";
/**
@@ -11,26 +12,61 @@ import { useI18n } from "@/lib/i18n";
export function SiteHeader() {
const { messages } = useI18n();
const { pathname } = useLocation();
const isAbout = pathname.startsWith("/about");
// เมนูหลัก: หน้าเฉพาะกลุ่มมาก่อน แล้วปิดท้ายด้วย "เกี่ยวกับเรา"
const links: Array<{ to: string; label: string }> = [
{ to: "/for-film-lovers", label: messages.nav.forFilmLovers },
{ to: "/for-cinemas", label: messages.nav.forCinemas },
{ to: "/about", label: messages.nav.about },
];
return (
<header className="relative z-10 mx-auto flex h-[68px] w-full max-w-[1440px] items-center justify-between gap-4 px-5 md:px-[108px]">
<Link to="/" aria-label={`AlterFlixHub — ${messages.nav.home}`} className="shrink-0">
<header className="fx-drop relative z-10 mx-auto flex h-[68px] w-full max-w-[1440px] items-center justify-between gap-3 px-5 md:px-[108px]">
<Link
to="/"
aria-label={`AlterFlixHub — ${messages.nav.home}`}
className="shrink-0"
>
<Logo />
</Link>
<div className="flex items-center gap-1.5 sm:gap-2">
<Link
to="/about"
aria-current={isAbout ? "page" : undefined}
className={`rounded-lg border px-2 py-1 text-xs transition sm:px-3 sm:py-1.5 sm:text-sm ${
isAbout
? "border-[#A92626] bg-[#8F0808]/20 text-white"
: "border-[#303030] text-[#B3B3B3] hover:border-[#A92626]/60 hover:text-white"
}`}
{/* มือถือ: เมนูพับ (ใช้ <details> เนทีฟ — คีย์บอร์ด/ปิดด้วย Esc ได้เอง) */}
<details className="group relative sm:hidden">
<summary className="flex min-h-10 cursor-pointer list-none items-center rounded-lg border border-[#303030] px-3 text-sm text-[#B3B3B3] transition hover:border-[#A92626]/60 hover:text-white [&::-webkit-details-marker]:hidden">
{messages.nav.menu}
</summary>
<nav
aria-label={messages.nav.menu}
className="absolute right-0 top-[calc(100%+8px)] z-20 flex w-[220px] flex-col gap-1 rounded-xl border border-[#303030] bg-[#141414] p-2 shadow-lg"
>
{links.map((link) => (
<NavLink
key={link.to}
to={link.to}
label={link.label}
isActive={pathname.startsWith(link.to)}
variant="panel"
/>
))}
</nav>
</details>
{/* เดสก์ท็อป: ลิงก์ตรงทั้งสามหน้า */}
<nav
aria-label={messages.nav.menu}
className="hidden items-center gap-2 sm:flex"
>
{messages.nav.about}
</Link>
{links.map((link) => (
<NavLink
key={link.to}
to={link.to}
label={link.label}
isActive={pathname.startsWith(link.to)}
variant="bar"
/>
))}
</nav>
<LocaleSwitcher />
</div>
+2 -2
View File
@@ -30,7 +30,7 @@ function HomeBackdrop() {
<img
src={HERO_IMAGE}
alt=""
className="pointer-events-none absolute inset-x-0 top-0 h-[553px] w-full object-cover"
className="fx-hero-image pointer-events-none absolute inset-x-0 top-0 h-[553px] w-full object-cover"
/>
<div className="pointer-events-none absolute inset-x-0 top-0 h-[553px] bg-gradient-to-b from-transparent via-[#0D0D0D]/60 to-[#0D0D0D]" />
<div className="pointer-events-none absolute left-1/2 top-0 size-[382px] -translate-x-1/2 -translate-y-1/2 rounded-full bg-[#8F0808] blur-[237px]" />
@@ -66,7 +66,7 @@ export function SiteShell({
<SiteHeader />
{/* flex-1 ดัน footer ไปท้ายจอเมื่อเนื้อหาสั้น — เป็น block ธรรมดา
(ไม่ใช้ flex-col เพื่อไม่ให้ main ที่มี mx-auto หดเหลือ max-content จนล้นจอมือถือ) */}
<div className="flex-1">{children}</div>
<div className="fx-page flex-1">{children}</div>
<SiteFooter />
</div>
);