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

+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>
);