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:
1 parent
1e84023a44
commit
319c271d23
72 files changed
+4731
-765
No files matched your search
@@ -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>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user