พอร์ต UI จาก web-at-transit-mock เข้า Next.js + data sync เข้า Postgres/SeaweedFS
- 8 หน้า (home/stops/routes/stop/check/blog/about/credits) แปลง partials → React component ตรง mock
- ตรรกะพอร์ตเป็น src/lib/ui/*.ts (mount()) + runtime/PageRuntime
- CSS: base + pages/*.css import ต่อ route (คงลำดับ cascade ของ mock)
- asset/content: public/{image,resource/data,content,locales,vendor}
- แก้ path รูปไทล์พาร์ทเนอร์ (.image → /image) + fallback absolute
- ลบ UI เดิมที่ไม่ตรง mock (expanded/stops details/old components/globals.css)
- script/sync_data_to_postgres.mjs + sync_images_to_storage.mjs (dry-run/--apply, backup)
- docs/UI-PORT.md + DESIGN.md + README
This commit is contained in:
1 parent
24187fc3b7
commit
138a3d15d8
300 files changed
+20213
-1978
No files matched your search
@@ -0,0 +1,122 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef } from "react";
|
||||
import { usePathname } from "next/navigation";
|
||||
|
||||
const NAV = [
|
||||
{ href: "/", key: "nav.home", label: "หน้าแรก" },
|
||||
{ href: "/stops", key: "nav.stops", label: "ป้ายหยุดรถ" },
|
||||
{ href: "/routes", key: "nav.routes", label: "รายละเอียดสายรถ" },
|
||||
{ href: "/about", key: "nav.about", label: "เกี่ยวกับเรา" },
|
||||
{ href: "/blog", key: "nav.blog", label: "บ่นไปเรื่อย" },
|
||||
{ href: "/credits", key: "nav.credits", label: "เครดิต" },
|
||||
];
|
||||
|
||||
function isActive(pathname: string, href: string): boolean {
|
||||
if (href === "/") return pathname === "/";
|
||||
return pathname === href || pathname.startsWith(`${href}/`);
|
||||
}
|
||||
|
||||
export default function SiteHeader() {
|
||||
const pathname = usePathname() || "/";
|
||||
const menuRef = useRef<HTMLDetailsElement>(null);
|
||||
|
||||
// ปิดเมนู hamburger เมื่อเปลี่ยนหน้า หรือคลิกนอกเมนู (เดิมอยู่ใน index.html)
|
||||
useEffect(() => {
|
||||
if (menuRef.current) menuRef.current.removeAttribute("open");
|
||||
function onDocClick(event: MouseEvent) {
|
||||
const menu = menuRef.current;
|
||||
if (!menu) return;
|
||||
const target = event.target as HTMLElement;
|
||||
if (target.closest(".mu-menu-panel a")) {
|
||||
menu.removeAttribute("open");
|
||||
return;
|
||||
}
|
||||
if (!target.closest(".mu-menu")) menu.removeAttribute("open");
|
||||
}
|
||||
document.addEventListener("click", onDocClick);
|
||||
return () => document.removeEventListener("click", onDocClick);
|
||||
}, [pathname]);
|
||||
|
||||
return (
|
||||
<header className="mu-topbar">
|
||||
<div className="mu-container mu-topbar-inner">
|
||||
<a className="mu-brand" href="/" aria-label="Atroute — หน้าแรก">
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
<img
|
||||
className="mu-logo-img"
|
||||
src="/image/icons/minibus-512x512.png"
|
||||
alt="Atroute logo"
|
||||
width={44}
|
||||
height={44}
|
||||
decoding="async"
|
||||
/>
|
||||
<span>
|
||||
<span className="mu-brand-title">Atroute</span>
|
||||
<span className="mu-brand-subtitle" data-i18n="brand.subtitle">
|
||||
สถานีขนส่งผู้โดยสารจังหวัดอ่างทอง
|
||||
</span>
|
||||
</span>
|
||||
</a>
|
||||
|
||||
<nav className="mu-nav" aria-label="เมนูหลัก">
|
||||
{NAV.map((item) => (
|
||||
<a
|
||||
key={item.href}
|
||||
className={isActive(pathname, item.href) ? "active" : undefined}
|
||||
href={item.href}
|
||||
data-i18n={item.key}
|
||||
>
|
||||
{item.label}
|
||||
</a>
|
||||
))}
|
||||
</nav>
|
||||
|
||||
<details className="mu-menu" id="topnav" ref={menuRef}>
|
||||
<summary className="mu-menu-btn" aria-label="เมนูหลัก" aria-haspopup="true">
|
||||
<svg
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth={2}
|
||||
strokeLinecap="round"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<line x1="4" x2="20" y1="6" y2="6" />
|
||||
<line x1="4" x2="20" y1="12" y2="12" />
|
||||
<line x1="4" x2="20" y1="18" y2="18" />
|
||||
</svg>
|
||||
</summary>
|
||||
<div className="mu-menu-panel" role="menu">
|
||||
{NAV.slice(0, 3).map((item) => (
|
||||
<a key={item.href} href={item.href} data-i18n={item.key} role="menuitem">
|
||||
{item.label}
|
||||
</a>
|
||||
))}
|
||||
<a href="/check" data-i18n="cta.check" role="menuitem">
|
||||
เช็กเวลาเดินรถ
|
||||
</a>
|
||||
{NAV.slice(3).map((item) => (
|
||||
<a key={item.href} href={item.href} data-i18n={item.key} role="menuitem">
|
||||
{item.label}
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<div className="mu-lang-switch" role="group" aria-label="ภาษา / Language">
|
||||
<button type="button" className="mu-lang-btn" data-i18n-switch="th">
|
||||
ไทย
|
||||
</button>
|
||||
<button type="button" className="mu-lang-btn" data-i18n-switch="en">
|
||||
EN
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<a className="mu-action-btn" href="/check" data-i18n="cta.check">
|
||||
เช็กเวลาเดินรถ
|
||||
</a>
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user