first commit
This commit is contained in:
commit
2a1854ab08
120 files changed
+11300
No files matched your search
@@ -0,0 +1,887 @@
|
||||
/* ============================================================
|
||||
AT Transit — bold-creative light theme
|
||||
Ported from flow_ui/ui/_shared.css + index.html inline styles
|
||||
============================================================ */
|
||||
|
||||
:root {
|
||||
--bg: #f7f9fd;
|
||||
--surface: #ffffff;
|
||||
--ink: #1f2a44;
|
||||
--ink-muted: #4a5876;
|
||||
--muted: #6f7b95;
|
||||
--line: #e9eef7;
|
||||
|
||||
--sky-50: #dbeafe; --sky-700: #1d4ed8;
|
||||
--purple-50: #ede9fe; --purple-700: #6d28d9;
|
||||
--pink-50: #fce7f3; --pink-700: #be185d;
|
||||
--mint-50: #d1fae5; --mint-700: #047857;
|
||||
--green-50: #dcfce7; --green-700: #15803d;
|
||||
--amber-50: #fef3c7; --amber-700: #b45309;
|
||||
|
||||
--grad-sky: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%);
|
||||
--grad-purple: linear-gradient(135deg, #8b5cf6 0%, #c084fc 100%);
|
||||
--grad-pink: linear-gradient(135deg, #ec4899 0%, #f472b6 100%);
|
||||
--grad-mint: linear-gradient(135deg, #10b981 0%, #34d399 100%);
|
||||
--grad-amber: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
|
||||
--grad-cta: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
|
||||
|
||||
--radius: 16px;
|
||||
--radius-lg: 22px;
|
||||
--shadow-sm: 0 4px 14px rgba(20, 40, 90, .06);
|
||||
--shadow-md: 0 10px 24px rgba(20, 40, 90, .10);
|
||||
--shadow-lg: 0 18px 36px rgba(15, 23, 42, .14);
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
html, body { margin: 0; padding: 0; }
|
||||
body {
|
||||
font-family: "Noto Sans Thai", "Prompt", "Sukhumvit Set", "Sarabun",
|
||||
system-ui, -apple-system, sans-serif;
|
||||
background: var(--bg);
|
||||
color: var(--ink);
|
||||
min-height: 100vh;
|
||||
}
|
||||
a { color: inherit; text-decoration: none; }
|
||||
img { max-width: 100%; display: block; }
|
||||
|
||||
/* ---------- Layout helpers ---------- */
|
||||
.container { max-width: 1200px; margin: 0 auto; padding: 0 28px; }
|
||||
@media (max-width: 640px) { .container { padding: 0 18px; } }
|
||||
.main { padding: 40px 0 24px; }
|
||||
|
||||
/* ---------- Topbar ---------- */
|
||||
.topbar {
|
||||
position: sticky; top: 0; z-index: 50;
|
||||
background: #ffffff;
|
||||
border-bottom: 1px solid var(--line);
|
||||
box-shadow: 0 2px 8px rgba(20, 40, 90, .04);
|
||||
}
|
||||
.topbar__inner {
|
||||
display: flex; align-items: center; gap: 18px;
|
||||
padding: 14px 28px; max-width: 1200px; margin: 0 auto;
|
||||
}
|
||||
.brand { display: flex; align-items: center; gap: 12px; }
|
||||
.brand__logo {
|
||||
width: 44px; height: 44px; border-radius: 12px;
|
||||
background: var(--grad-cta);
|
||||
padding: 4px;
|
||||
}
|
||||
.brand__title { margin: 0; font-weight: 800; font-size: 1.05rem; color: var(--ink); }
|
||||
.brand__subtitle { margin: 0; font-size: .72rem; color: var(--muted); }
|
||||
|
||||
.nav { margin-left: auto; display: flex; gap: 28px; }
|
||||
.nav a {
|
||||
color: var(--ink-muted); font-size: .92rem; font-weight: 600;
|
||||
padding: 6px 4px; border-bottom: 2px solid transparent; transition: color .15s;
|
||||
}
|
||||
.nav a.active { color: var(--pink-700); border-bottom-color: #ec4899; }
|
||||
.nav a:hover { color: var(--ink); }
|
||||
|
||||
.cta-pill {
|
||||
background: var(--grad-cta); color: #fff; padding: 10px 22px;
|
||||
border-radius: 999px; font-weight: 700; font-size: .88rem;
|
||||
box-shadow: 0 6px 14px rgba(124, 58, 237, .3);
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
@media (max-width: 820px) {
|
||||
.nav { display: none; }
|
||||
.brand__subtitle { display: none; }
|
||||
}
|
||||
|
||||
/* ---------- Hero ---------- */
|
||||
.hero {
|
||||
position: relative; overflow: hidden;
|
||||
padding: 56px 0 64px;
|
||||
background: linear-gradient(180deg, #f0ebff 0%, #ffe8ee 50%, #fff4d6 100%);
|
||||
text-align: center;
|
||||
}
|
||||
.hero__blob {
|
||||
position: absolute; border-radius: 50%;
|
||||
filter: blur(50px); opacity: .55; z-index: 0;
|
||||
}
|
||||
.hero__blob.one { width: 220px; height: 220px; background: #b794f4; top: -50px; left: 8%; }
|
||||
.hero__blob.two { width: 260px; height: 260px; background: #f9a8d4; top: 40%; right: 8%; }
|
||||
.hero__blob.three { width: 180px; height: 180px; background: #fde68a; bottom: -40px; left: 38%; }
|
||||
.hero__inner { position: relative; z-index: 1; }
|
||||
|
||||
.hero__badge {
|
||||
display: inline-block;
|
||||
background: rgba(255, 255, 255, .8);
|
||||
backdrop-filter: blur(6px);
|
||||
color: var(--purple-700);
|
||||
padding: 6px 16px; border-radius: 999px;
|
||||
font-size: .82rem; font-weight: 700;
|
||||
margin-bottom: 18px;
|
||||
box-shadow: 0 4px 10px rgba(124, 58, 237, .12);
|
||||
}
|
||||
.hero h1 {
|
||||
margin: 0 0 26px;
|
||||
font-size: clamp(1.6rem, 4vw, 2.4rem);
|
||||
font-weight: 800; line-height: 1.35; color: var(--ink);
|
||||
}
|
||||
.hero__lead {
|
||||
margin: -6px auto 0;
|
||||
max-width: 640px;
|
||||
color: var(--ink-muted);
|
||||
font-size: 1rem;
|
||||
line-height: 1.7;
|
||||
}
|
||||
.hero__grad {
|
||||
background: linear-gradient(120deg, #d946ef 10%, #a855f7 60%, #6366f1 100%);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
background-clip: text;
|
||||
}
|
||||
.hero__actions {
|
||||
margin: 28px auto 0;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 14px;
|
||||
max-width: 860px;
|
||||
}
|
||||
.pill-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 58px;
|
||||
background: rgba(255, 255, 255, .88);
|
||||
color: var(--ink);
|
||||
padding: 12px 18px;
|
||||
border-radius: 18px;
|
||||
font-weight: 800;
|
||||
font-size: .98rem;
|
||||
border: 1px solid rgba(124, 58, 237, .18);
|
||||
box-shadow: 0 10px 22px rgba(40, 60, 120, .10);
|
||||
transition: transform .15s, box-shadow .15s, border-color .15s;
|
||||
}
|
||||
.pill-link:hover { transform: translateY(-2px); box-shadow: 0 14px 24px rgba(40, 60, 120, .16); }
|
||||
.pill-link--primary {
|
||||
background: var(--grad-cta);
|
||||
color: #fff;
|
||||
border-color: transparent;
|
||||
}
|
||||
.pill-link--secondary {
|
||||
background: rgba(255, 255, 255, .95);
|
||||
border-color: rgba(59, 130, 246, .22);
|
||||
}
|
||||
.pill-link--accent {
|
||||
background: rgba(255, 255, 255, .95);
|
||||
border-color: rgba(236, 72, 153, .22);
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.hero__actions { grid-template-columns: 1fr; }
|
||||
}
|
||||
|
||||
/* ---------- Zones / Cards ---------- */
|
||||
.zone { margin-bottom: 36px; }
|
||||
.zone__head {
|
||||
display: flex; align-items: center; gap: 14px; margin-bottom: 14px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.zone__tag {
|
||||
padding: 5px 14px; border-radius: 999px;
|
||||
font-size: .82rem; font-weight: 700;
|
||||
}
|
||||
.zone__tag.sky { background: var(--sky-50); color: var(--sky-700); }
|
||||
.zone__tag.purple { background: var(--purple-50); color: var(--purple-700); }
|
||||
.zone__tag.pink { background: var(--pink-50); color: var(--pink-700); }
|
||||
.zone__tag.mint { background: var(--mint-50); color: var(--mint-700); }
|
||||
.zone__desc { color: var(--muted); font-size: .88rem; margin: 0; }
|
||||
|
||||
.grid {
|
||||
display: grid; gap: 18px;
|
||||
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
|
||||
}
|
||||
|
||||
.card {
|
||||
display: block; background: #fff; border-radius: var(--radius);
|
||||
overflow: hidden; box-shadow: var(--shadow-sm);
|
||||
transition: transform .18s ease, box-shadow .18s ease;
|
||||
color: inherit;
|
||||
}
|
||||
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
|
||||
|
||||
.card__head {
|
||||
height: 130px; display: flex; align-items: center; justify-content: center;
|
||||
position: relative;
|
||||
}
|
||||
.card__head.sky { background: var(--grad-sky); }
|
||||
.card__head.purple { background: var(--grad-purple); }
|
||||
.card__head.pink { background: var(--grad-pink); }
|
||||
.card__head.mint { background: var(--grad-mint); }
|
||||
.card__head.amber { background: var(--grad-amber); }
|
||||
|
||||
.card__num {
|
||||
color: #fff; font-size: 52px; font-weight: 900;
|
||||
text-shadow: 0 4px 12px rgba(0, 0, 0, .25);
|
||||
letter-spacing: .02em; margin: 0;
|
||||
}
|
||||
.card__body { padding: 14px 16px 16px; }
|
||||
.card__name {
|
||||
margin: 0 0 10px; font-size: .9rem; color: var(--ink); font-weight: 700;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.card__chips { display: flex; flex-wrap: wrap; gap: 6px; }
|
||||
.card__icon {
|
||||
font-size: 56px; line-height: 1;
|
||||
filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .25));
|
||||
}
|
||||
.chip {
|
||||
display: inline-block; padding: 4px 12px; border-radius: 999px;
|
||||
font-size: .78rem; font-weight: 700;
|
||||
}
|
||||
.chip.sky { background: var(--sky-50); color: var(--sky-700); }
|
||||
.chip.purple { background: var(--purple-50); color: var(--purple-700); }
|
||||
.chip.pink { background: var(--pink-50); color: var(--pink-700); }
|
||||
.chip.mint { background: var(--mint-50); color: var(--mint-700); }
|
||||
.chip.green { background: var(--green-50); color: var(--green-700); }
|
||||
.chip.amber { background: var(--amber-50); color: var(--amber-700); }
|
||||
|
||||
/* ---------- Stats summary ---------- */
|
||||
.summary { padding: 8px 0 40px; }
|
||||
.summary__grid {
|
||||
display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px;
|
||||
}
|
||||
.stat {
|
||||
padding: 28px 18px; text-align: center;
|
||||
border-radius: 18px; margin: 0;
|
||||
}
|
||||
.stat h3 { margin: 0 0 4px; font-size: 2rem; color: var(--ink); font-weight: 800; }
|
||||
.stat p { margin: 0; font-size: .82rem; color: var(--ink-muted); font-weight: 600; }
|
||||
.stat.pink { background: var(--pink-50); }
|
||||
.stat.sky { background: var(--sky-50); }
|
||||
.stat.purple { background: var(--purple-50); }
|
||||
.stat.mint { background: var(--mint-50); }
|
||||
@media (max-width: 720px) {
|
||||
.summary__grid { grid-template-columns: repeat(2, 1fr); }
|
||||
}
|
||||
|
||||
/* ---------- Generic content (routes/stops detail pages) ---------- */
|
||||
.page { max-width: 1200px; margin: 0 auto; padding: 28px 28px 60px; }
|
||||
.section-title { margin: 28px 0 14px; font-size: 1.25rem; color: var(--ink); font-weight: 800; }
|
||||
.muted { color: var(--muted); }
|
||||
|
||||
.panel {
|
||||
background: #fff; border-radius: var(--radius);
|
||||
box-shadow: var(--shadow-sm); padding: 22px 24px;
|
||||
border: 1px solid var(--line);
|
||||
}
|
||||
.crumbs { color: var(--muted); font-size: .85rem; margin: 8px 0 12px; }
|
||||
.crumbs a { color: var(--purple-700); font-weight: 600; }
|
||||
.crumbs a:hover { text-decoration: underline; }
|
||||
|
||||
.pill {
|
||||
display: inline-block; padding: 5px 12px; border-radius: 999px;
|
||||
background: var(--purple-50); color: var(--purple-700);
|
||||
font-size: .78rem; font-weight: 700;
|
||||
}
|
||||
.pill--alt { background: var(--pink-50); color: var(--pink-700); }
|
||||
|
||||
.table {
|
||||
width: 100%; border-collapse: separate; border-spacing: 0;
|
||||
margin-top: 14px;
|
||||
background: linear-gradient(180deg, #ffffff 0%, #fbfbff 100%);
|
||||
border-radius: var(--radius); overflow: hidden;
|
||||
border: 1px solid var(--line);
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
.table th, .table td { padding: 14px 18px; text-align: left; font-size: .92rem; }
|
||||
.table th {
|
||||
background: linear-gradient(180deg, #f3eefe 0%, #fde7f0 100%);
|
||||
color: var(--ink); font-weight: 800;
|
||||
font-size: .76rem; text-transform: uppercase; letter-spacing: .06em;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
.table tr + tr td { border-top: 1px solid var(--line); }
|
||||
.table tbody tr:hover td { background: #faf8ff; }
|
||||
|
||||
.map-wrap {
|
||||
height: 360px; border-radius: var(--radius); overflow: hidden;
|
||||
border: 1px solid var(--line);
|
||||
}
|
||||
|
||||
/* ---------- Stop detail (map + gallery) ---------- */
|
||||
.stop-detail__split {
|
||||
display: grid;
|
||||
grid-template-columns: 1.1fr 1fr;
|
||||
gap: 18px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
@media (max-width: 900px) {
|
||||
.stop-detail__split { grid-template-columns: 1fr; }
|
||||
}
|
||||
.stop-detail__gallery {
|
||||
display: flex; flex-direction: column; gap: 10px;
|
||||
background: #fff; border-radius: var(--radius);
|
||||
border: 1px solid var(--line); box-shadow: var(--shadow-sm);
|
||||
overflow: hidden;
|
||||
}
|
||||
.stop-detail__gallery--empty,
|
||||
.stop-detail__map--empty {
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
min-height: 320px; background: #f4f6fc; color: var(--muted);
|
||||
}
|
||||
.stop-detail__hero-img {
|
||||
width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block;
|
||||
}
|
||||
.stop-detail__thumbs {
|
||||
display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
|
||||
padding: 0 10px 10px;
|
||||
}
|
||||
.stop-detail__thumbs img {
|
||||
width: 100%; aspect-ratio: 1 / 1; object-fit: cover;
|
||||
border-radius: 10px; border: 1px solid var(--line);
|
||||
}
|
||||
.stop-detail__map {
|
||||
height: 100%; min-height: 360px;
|
||||
border-radius: var(--radius); overflow: hidden;
|
||||
border: 1px solid var(--line); box-shadow: var(--shadow-sm);
|
||||
background: #e5edf7;
|
||||
}
|
||||
.stop-detail__placeholder {
|
||||
font-size: .95rem; font-weight: 600;
|
||||
}
|
||||
|
||||
/* ---------- Schedule card list (soft gradient, modern) ---------- */
|
||||
.schedule-list {
|
||||
display: grid; gap: 14px; margin-top: 14px;
|
||||
}
|
||||
.schedule-card {
|
||||
position: relative;
|
||||
display: grid; grid-template-columns: minmax(220px, 320px) 1fr;
|
||||
gap: 18px; align-items: center;
|
||||
padding: 18px 20px 18px 26px;
|
||||
background: linear-gradient(135deg, #ffffff 0%, #fbfaff 60%, #fff5fb 100%);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-sm);
|
||||
overflow: hidden;
|
||||
transition: transform .15s ease, box-shadow .15s ease;
|
||||
}
|
||||
.schedule-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
|
||||
.schedule-card__rail {
|
||||
position: absolute; left: 0; top: 0; bottom: 0; width: 6px;
|
||||
background: var(--grad-cta);
|
||||
}
|
||||
.schedule-card--sky .schedule-card__rail { background: var(--grad-sky); }
|
||||
.schedule-card--purple .schedule-card__rail { background: var(--grad-purple); }
|
||||
.schedule-card--pink .schedule-card__rail { background: var(--grad-pink); }
|
||||
.schedule-card--mint .schedule-card__rail { background: var(--grad-mint); }
|
||||
.schedule-card--amber .schedule-card__rail { background: var(--grad-amber); }
|
||||
.schedule-card--sky { background: linear-gradient(135deg, #ffffff 0%, #f0f6ff 100%); }
|
||||
.schedule-card--purple { background: linear-gradient(135deg, #ffffff 0%, #f6f1ff 100%); }
|
||||
.schedule-card--pink { background: linear-gradient(135deg, #ffffff 0%, #fff0f7 100%); }
|
||||
.schedule-card--mint { background: linear-gradient(135deg, #ffffff 0%, #ecfdf5 100%); }
|
||||
.schedule-card--amber { background: linear-gradient(135deg, #ffffff 0%, #fff7e8 100%); }
|
||||
|
||||
.schedule-card__head {
|
||||
display: flex; flex-direction: column; gap: 10px;
|
||||
}
|
||||
.schedule-card__route {
|
||||
display: inline-flex; flex-direction: column; align-items: flex-start;
|
||||
padding: 10px 16px; border-radius: 14px;
|
||||
color: #fff; min-width: 140px;
|
||||
box-shadow: 0 8px 18px rgba(15, 23, 42, .15);
|
||||
background: var(--grad-cta);
|
||||
}
|
||||
.schedule-card__route.sky { background: var(--grad-sky); }
|
||||
.schedule-card__route.purple { background: var(--grad-purple); }
|
||||
.schedule-card__route.pink { background: var(--grad-pink); }
|
||||
.schedule-card__route.mint { background: var(--grad-mint); }
|
||||
.schedule-card__route.amber { background: var(--grad-amber); }
|
||||
.schedule-card__route-label {
|
||||
font-size: .68rem; text-transform: uppercase; letter-spacing: .1em;
|
||||
opacity: .85; font-weight: 700;
|
||||
}
|
||||
.schedule-card__route-id {
|
||||
font-size: 1.5rem; font-weight: 900; letter-spacing: .02em; line-height: 1.1;
|
||||
}
|
||||
.schedule-card__meta {
|
||||
display: flex; flex-direction: column; gap: 4px;
|
||||
}
|
||||
.schedule-card__direction {
|
||||
display: inline-flex; align-items: center; gap: 6px;
|
||||
font-weight: 700; color: var(--ink); font-size: .92rem;
|
||||
}
|
||||
.schedule-card__note {
|
||||
font-size: .82rem; color: var(--ink-muted);
|
||||
}
|
||||
|
||||
.schedule-card__times {
|
||||
display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start;
|
||||
}
|
||||
.schedule-card__time {
|
||||
display: inline-flex; align-items: center; gap: 5px;
|
||||
padding: 7px 12px; border-radius: 999px;
|
||||
font-size: .88rem; font-weight: 700; letter-spacing: .02em;
|
||||
color: var(--ink);
|
||||
background: linear-gradient(135deg, #ffffff 0%, #f3eefe 100%);
|
||||
border: 1px solid #e3d9fb;
|
||||
box-shadow: 0 2px 6px rgba(124, 58, 237, .08);
|
||||
}
|
||||
.schedule-card__time:hover {
|
||||
background: var(--grad-cta); color: #fff; border-color: transparent;
|
||||
}
|
||||
.schedule-card__empty {
|
||||
font-size: .85rem; color: var(--muted); font-style: italic;
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.schedule-card { grid-template-columns: 1fr; gap: 12px; padding: 16px 16px 16px 22px; }
|
||||
.schedule-card__route { width: 100%; }
|
||||
}
|
||||
|
||||
/* Detail-page hero (inside .page wrapper) */
|
||||
.page > .hero {
|
||||
border-radius: var(--radius-lg);
|
||||
margin-bottom: 22px;
|
||||
padding: 30px 28px;
|
||||
text-align: left;
|
||||
background: linear-gradient(135deg, #ede9fe 0%, #fce7f3 100%);
|
||||
}
|
||||
.page > .hero h1 {
|
||||
font-size: clamp(1.4rem, 3vw, 1.9rem); margin: 6px 0 10px;
|
||||
}
|
||||
|
||||
/* ---------- Footer (rich dark) ---------- */
|
||||
.footer {
|
||||
margin-top: 48px;
|
||||
background:
|
||||
radial-gradient(circle at 0% 0%, rgba(122, 76, 192, .35), transparent 35%),
|
||||
radial-gradient(circle at 100% 10%, rgba(48, 113, 184, .35), transparent 35%),
|
||||
linear-gradient(180deg, #1a1830 0%, #0f1126 100%);
|
||||
color: #cfd5ec;
|
||||
padding: 48px 0 0;
|
||||
}
|
||||
.footer .container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
|
||||
.footer__grid {
|
||||
display: grid; grid-template-columns: 1.4fr 1fr 1fr 1.1fr; gap: 28px;
|
||||
}
|
||||
.footer__brand { display: flex; flex-direction: column; gap: 12px; }
|
||||
.footer__brand-row { display: flex; align-items: center; gap: 12px; }
|
||||
.footer__brand-row img {
|
||||
width: 48px; height: 48px; border-radius: 12px;
|
||||
background: #fff; padding: 4px; object-fit: contain;
|
||||
}
|
||||
.footer__brand-row strong {
|
||||
display: block; color: #fff; font-size: 1.05rem;
|
||||
font-weight: 800; letter-spacing: .01em;
|
||||
}
|
||||
.footer__brand-row span { display: block; color: #9aa3c3; font-size: .82rem; margin-top: 2px; }
|
||||
.footer__brand p { margin: 0; color: #b6bdda; font-size: .88rem; line-height: 1.6; }
|
||||
|
||||
.footer__col h4 {
|
||||
margin: 0 0 14px; color: #fff; font-size: .9rem;
|
||||
font-weight: 800; letter-spacing: .03em; text-transform: uppercase;
|
||||
}
|
||||
.footer__col ul {
|
||||
list-style: none; padding: 0; margin: 0;
|
||||
display: flex; flex-direction: column; gap: 8px;
|
||||
}
|
||||
.footer__col ul a {
|
||||
color: #cfd5ec; font-size: .9rem; transition: color .15s;
|
||||
display: inline-flex; align-items: center; gap: 8px;
|
||||
}
|
||||
.footer__col ul a::before { content: "›"; color: #a855f7; font-weight: 800; }
|
||||
.footer__col ul a:hover { color: #fff; }
|
||||
.footer__contact .row { margin-bottom: 8px; }
|
||||
.footer__contact a, .footer__contact span {
|
||||
display: inline-flex; align-items: center; gap: 8px;
|
||||
color: #cfd5ec; font-size: .88rem;
|
||||
}
|
||||
|
||||
.footer__sponsors {
|
||||
margin-top: 36px; padding-top: 28px;
|
||||
border-top: 1px solid rgba(255, 255, 255, .08);
|
||||
}
|
||||
.footer__sponsors h4 { margin: 0 0 6px; color: #fff; font-size: .95rem; font-weight: 800; }
|
||||
.footer__sponsors .lead { margin: 0 0 18px; color: #9aa3c3; font-size: .85rem; }
|
||||
.sponsor-strip {
|
||||
display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px;
|
||||
}
|
||||
.sponsor-tile {
|
||||
background: #fff; border-radius: 12px; padding: 10px;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
aspect-ratio: 5 / 3; overflow: hidden;
|
||||
transition: transform .15s, box-shadow .15s;
|
||||
}
|
||||
.sponsor-tile img {
|
||||
width: 100%; height: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
.sponsor-tile:hover { transform: translateY(-3px); box-shadow: 0 12px 24px rgba(0, 0, 0, .35); }
|
||||
|
||||
.footer__bottom {
|
||||
margin-top: 36px; padding: 18px 0 22px;
|
||||
border-top: 1px solid rgba(255, 255, 255, .08);
|
||||
text-align: center;
|
||||
}
|
||||
.footer__bottom p { margin: 0; color: #8d96b8; font-size: .82rem; letter-spacing: .02em; }
|
||||
.footer__bottom .pill {
|
||||
display: inline-block; margin-left: 10px; padding: 2px 10px;
|
||||
border-radius: 999px; background: rgba(122, 76, 192, .25);
|
||||
color: #d8c7ff; font-size: .72rem; font-weight: 700;
|
||||
}
|
||||
|
||||
@media (max-width: 980px) { .footer__grid { grid-template-columns: 1fr 1fr; } }
|
||||
@media (max-width: 640px) {
|
||||
.footer__grid { grid-template-columns: 1fr; }
|
||||
.footer { padding: 36px 0 0; }
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
Modern soft-gradient list pages (/stops, /routes)
|
||||
============================================================ */
|
||||
.page-hero {
|
||||
position: relative; overflow: hidden;
|
||||
border-radius: var(--radius-lg);
|
||||
padding: 44px 36px 38px;
|
||||
margin-bottom: 22px;
|
||||
background:
|
||||
radial-gradient(120% 140% at 0% 0%, #ede9fe 0%, transparent 55%),
|
||||
radial-gradient(120% 140% at 100% 0%, #fce7f3 0%, transparent 55%),
|
||||
radial-gradient(120% 140% at 50% 120%, #fef3c7 0%, transparent 55%),
|
||||
linear-gradient(135deg, #ffffff 0%, #fbfaff 100%);
|
||||
border: 1px solid rgba(168, 85, 247, .12);
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
.page-hero--alt {
|
||||
background:
|
||||
radial-gradient(120% 140% at 0% 0%, #dbeafe 0%, transparent 55%),
|
||||
radial-gradient(120% 140% at 100% 0%, #ede9fe 0%, transparent 55%),
|
||||
radial-gradient(120% 140% at 50% 120%, #d1fae5 0%, transparent 55%),
|
||||
linear-gradient(135deg, #ffffff 0%, #f7faff 100%);
|
||||
border-color: rgba(59, 130, 246, .14);
|
||||
}
|
||||
.page-hero__blob {
|
||||
position: absolute; border-radius: 50%; filter: blur(46px); opacity: .55;
|
||||
pointer-events: none;
|
||||
}
|
||||
.page-hero__blob--a { width: 220px; height: 220px; background: #c4b5fd; top: -50px; left: -40px; }
|
||||
.page-hero__blob--b { width: 260px; height: 260px; background: #f9a8d4; top: 30%; right: -60px; }
|
||||
.page-hero__blob--c { width: 180px; height: 180px; background: #fde68a; bottom: -50px; left: 40%; }
|
||||
.page-hero--alt .page-hero__blob--a { background: #93c5fd; }
|
||||
.page-hero--alt .page-hero__blob--b { background: #c4b5fd; }
|
||||
.page-hero--alt .page-hero__blob--c { background: #6ee7b7; }
|
||||
.page-hero__inner { position: relative; z-index: 1; }
|
||||
.page-hero__badge {
|
||||
display: inline-block; padding: 6px 14px; border-radius: 999px;
|
||||
background: rgba(255, 255, 255, .7); backdrop-filter: blur(6px);
|
||||
border: 1px solid rgba(168, 85, 247, .25);
|
||||
color: var(--purple-700); font-size: .72rem; font-weight: 800;
|
||||
letter-spacing: .08em;
|
||||
}
|
||||
.page-hero__title {
|
||||
margin: 14px 0 8px; font-size: 2.4rem; font-weight: 900;
|
||||
color: var(--ink); letter-spacing: -.01em; line-height: 1.15;
|
||||
}
|
||||
.page-hero__title-grad {
|
||||
background: var(--grad-cta); -webkit-background-clip: text;
|
||||
background-clip: text; color: transparent;
|
||||
margin-left: 10px;
|
||||
}
|
||||
.page-hero--alt .page-hero__title-grad { background: var(--grad-sky); -webkit-background-clip: text; background-clip: text; }
|
||||
.page-hero__subtitle { margin: 0 0 16px; color: var(--ink-muted); font-size: 1rem; }
|
||||
.page-hero__stats { display: flex; flex-wrap: wrap; gap: 10px; }
|
||||
.page-hero__stat {
|
||||
display: inline-flex; align-items: baseline; gap: 6px;
|
||||
padding: 8px 16px; border-radius: 999px;
|
||||
background: rgba(255, 255, 255, .8); backdrop-filter: blur(8px);
|
||||
border: 1px solid rgba(15, 23, 42, .06);
|
||||
font-size: .85rem; color: var(--ink-muted); font-weight: 600;
|
||||
box-shadow: 0 4px 12px rgba(124, 58, 237, .08);
|
||||
}
|
||||
.page-hero__stat b {
|
||||
background: var(--grad-cta); -webkit-background-clip: text;
|
||||
background-clip: text; color: transparent;
|
||||
font-size: 1.05rem; font-weight: 900;
|
||||
}
|
||||
|
||||
.map-wrap--soft { border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); margin-bottom: 18px; }
|
||||
|
||||
/* Toolbar (search + filter chips) */
|
||||
.toolbar {
|
||||
display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
|
||||
padding: 14px 16px; margin: 18px 0;
|
||||
background: linear-gradient(135deg, #ffffff 0%, #fbfaff 100%);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius);
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
.toolbar__search {
|
||||
flex: 1 1 280px;
|
||||
display: inline-flex; align-items: center; gap: 8px;
|
||||
padding: 8px 14px; border-radius: 12px;
|
||||
background: #f4f6fc; border: 1px solid var(--line);
|
||||
color: var(--muted);
|
||||
}
|
||||
.toolbar__search input {
|
||||
flex: 1; border: 0; outline: 0; background: transparent;
|
||||
font: inherit; color: var(--ink);
|
||||
}
|
||||
.toolbar__chips { display: flex; flex-wrap: wrap; gap: 8px; }
|
||||
|
||||
.chip-soft {
|
||||
display: inline-flex; align-items: center; gap: 6px;
|
||||
padding: 6px 12px; border-radius: 999px;
|
||||
font-size: .78rem; font-weight: 700; letter-spacing: .01em;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
.chip-soft--sky { background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%); color: var(--sky-700); border-color: #cfe0fb; }
|
||||
.chip-soft--purple { background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%); color: var(--purple-700); border-color: #ddd3fb; }
|
||||
.chip-soft--pink { background: linear-gradient(135deg, #fdf2f8 0%, #fce7f3 100%); color: var(--pink-700); border-color: #f9cce3; }
|
||||
.chip-soft--mint { background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%); color: var(--mint-700); border-color: #b6ecd0; }
|
||||
.chip-soft--amber { background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%); color: var(--amber-700); border-color: #fde9a8; }
|
||||
|
||||
/* Tile grid + tile component */
|
||||
.tile-grid {
|
||||
display: grid; gap: 16px; margin-top: 4px;
|
||||
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
||||
}
|
||||
.tile {
|
||||
position: relative;
|
||||
display: grid; grid-template-columns: 76px 1fr auto;
|
||||
gap: 14px; align-items: center;
|
||||
padding: 16px 18px; border-radius: var(--radius-lg);
|
||||
border: 1px solid var(--line);
|
||||
background: linear-gradient(135deg, #ffffff 0%, #fbfaff 100%);
|
||||
box-shadow: var(--shadow-sm);
|
||||
color: inherit; overflow: hidden;
|
||||
transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
|
||||
}
|
||||
.tile::before {
|
||||
content: ""; position: absolute; inset: 0;
|
||||
background: var(--grad-cta); opacity: 0;
|
||||
transition: opacity .2s ease;
|
||||
border-radius: inherit; pointer-events: none;
|
||||
mix-blend-mode: multiply;
|
||||
}
|
||||
.tile:hover {
|
||||
transform: translateY(-3px);
|
||||
box-shadow: var(--shadow-md);
|
||||
border-color: rgba(168, 85, 247, .28);
|
||||
}
|
||||
.tile--sky { background: linear-gradient(135deg, #ffffff 0%, #f0f6ff 100%); }
|
||||
.tile--purple { background: linear-gradient(135deg, #ffffff 0%, #f6f1ff 100%); }
|
||||
.tile--pink { background: linear-gradient(135deg, #ffffff 0%, #fff0f7 100%); }
|
||||
.tile--mint { background: linear-gradient(135deg, #ffffff 0%, #ecfdf5 100%); }
|
||||
.tile--amber { background: linear-gradient(135deg, #ffffff 0%, #fff7e8 100%); }
|
||||
|
||||
.tile__badge {
|
||||
width: 64px; height: 64px; border-radius: 18px;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
color: #fff; font-size: 30px; font-weight: 900;
|
||||
box-shadow: 0 10px 22px rgba(15, 23, 42, .18);
|
||||
background: var(--grad-cta);
|
||||
}
|
||||
.tile__badge--num { font-size: 18px; letter-spacing: .02em; padding: 0 6px; text-align: center; }
|
||||
.tile__badge--sky { background: var(--grad-sky); }
|
||||
.tile__badge--purple { background: var(--grad-purple); }
|
||||
.tile__badge--pink { background: var(--grad-pink); }
|
||||
.tile__badge--mint { background: var(--grad-mint); }
|
||||
.tile__badge--amber { background: var(--grad-amber); }
|
||||
|
||||
.tile__body { min-width: 0; }
|
||||
.tile__title {
|
||||
margin: 0 0 4px; font-size: 1rem; font-weight: 800; color: var(--ink);
|
||||
line-height: 1.3;
|
||||
overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
|
||||
-webkit-line-clamp: 2; -webkit-box-orient: vertical;
|
||||
}
|
||||
.tile__meta {
|
||||
margin: 0 0 8px; font-size: .82rem; color: var(--ink-muted);
|
||||
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
||||
}
|
||||
.tile__chips { display: flex; flex-wrap: wrap; gap: 6px; }
|
||||
.tile__arrow {
|
||||
font-size: 1.4rem; color: var(--muted); font-weight: 700;
|
||||
transition: transform .18s ease, color .18s ease;
|
||||
}
|
||||
.tile:hover .tile__arrow { color: var(--purple-700); transform: translateX(4px); }
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.page-hero { padding: 32px 22px 28px; }
|
||||
.page-hero__title { font-size: 1.8rem; }
|
||||
.tile { grid-template-columns: 56px 1fr; padding: 14px; }
|
||||
.tile__badge { width: 52px; height: 52px; font-size: 24px; border-radius: 14px; }
|
||||
.tile__arrow { display: none; }
|
||||
}
|
||||
|
||||
/* ============ Route detail hero ============ */
|
||||
.route-hero { padding-top: 38px; }
|
||||
.route-hero__top {
|
||||
display: grid;
|
||||
grid-template-columns: 96px 1fr;
|
||||
gap: 20px;
|
||||
align-items: center;
|
||||
position: relative; z-index: 1;
|
||||
}
|
||||
.route-hero__badge {
|
||||
width: 96px; height: 96px;
|
||||
border-radius: 26px;
|
||||
background: linear-gradient(135deg,#7c3aed,#ec4899 55%,#f59e0b);
|
||||
color: #fff;
|
||||
font-weight: 900; font-size: 1.9rem;
|
||||
letter-spacing: .5px;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
box-shadow: 0 18px 38px rgba(124,58,237,.35), inset 0 1px 0 rgba(255,255,255,.4);
|
||||
border: 3px solid rgba(255,255,255,.7);
|
||||
}
|
||||
.route-hero__title-wrap { min-width: 0; }
|
||||
.route-hero__chips {
|
||||
display: flex; flex-wrap: wrap; gap: 6px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.route-hero__actions {
|
||||
margin-top: 18px;
|
||||
display: flex; flex-wrap: wrap; gap: 12px;
|
||||
position: relative; z-index: 1;
|
||||
}
|
||||
.route-hero__cta {
|
||||
display: inline-flex; align-items: center; gap: 8px;
|
||||
padding: 12px 22px;
|
||||
border-radius: 999px;
|
||||
background: linear-gradient(135deg,#7c3aed,#ec4899);
|
||||
color: #fff !important; font-weight: 800; font-size: .95rem;
|
||||
text-decoration: none;
|
||||
box-shadow: 0 12px 28px rgba(124,58,237,.32);
|
||||
transition: transform .18s ease, box-shadow .18s ease;
|
||||
}
|
||||
.route-hero__cta:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(124,58,237,.42); }
|
||||
.route-hero__back {
|
||||
display: inline-flex; align-items: center; gap: 6px;
|
||||
padding: 12px 18px;
|
||||
border-radius: 999px;
|
||||
background: rgba(255,255,255,.72);
|
||||
border: 1px solid rgba(124,58,237,.18);
|
||||
color: var(--purple-700) !important; font-weight: 700; font-size: .9rem;
|
||||
text-decoration: none;
|
||||
backdrop-filter: blur(6px);
|
||||
transition: background .18s ease;
|
||||
}
|
||||
.route-hero__back:hover { background: #fff; }
|
||||
|
||||
/* ============ Route map section ============ */
|
||||
.route-map-section { margin-top: 28px; }
|
||||
.route-map-section__head {
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
gap: 14px; flex-wrap: wrap;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.route-map-section__head .section-title { margin: 0; }
|
||||
.route-map-section__legend {
|
||||
display: inline-flex; flex-wrap: wrap; gap: 14px;
|
||||
font-size: .85rem; color: var(--ink-muted); font-weight: 600;
|
||||
}
|
||||
.route-map-section__legend span { display: inline-flex; align-items: center; gap: 6px; }
|
||||
.dot {
|
||||
width: 12px; height: 12px; border-radius: 50%;
|
||||
display: inline-block;
|
||||
border: 2px solid #fff;
|
||||
box-shadow: 0 0 0 1px rgba(0,0,0,.08);
|
||||
}
|
||||
.dot--start { background: linear-gradient(135deg,#34d399,#10b981); }
|
||||
.dot--mid { background: linear-gradient(135deg,#a78bfa,#7c3aed); }
|
||||
.dot--end { background: linear-gradient(135deg,#fb7185,#e11d48); }
|
||||
.route-map {
|
||||
height: 460px;
|
||||
border: 1px solid rgba(124,58,237,.12);
|
||||
}
|
||||
.route-map-empty {
|
||||
padding: 28px;
|
||||
text-align: center;
|
||||
border-radius: 20px;
|
||||
background: linear-gradient(135deg,#fdf4ff,#eef2ff);
|
||||
border: 1px dashed rgba(124,58,237,.25);
|
||||
}
|
||||
|
||||
/* ============ Stops timeline ============ */
|
||||
.stop-timeline {
|
||||
list-style: none;
|
||||
padding: 0; margin: 14px 0 0;
|
||||
display: flex; flex-direction: column; gap: 10px;
|
||||
position: relative;
|
||||
}
|
||||
.stop-node {
|
||||
position: relative;
|
||||
display: grid;
|
||||
grid-template-columns: 56px 1fr auto;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
padding: 14px 16px;
|
||||
border-radius: 18px;
|
||||
background: linear-gradient(135deg,#ffffff 0%,#fbfaff 100%);
|
||||
border: 1px solid rgba(124,58,237,.10);
|
||||
box-shadow: 0 6px 16px rgba(31,28,68,.05);
|
||||
transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
|
||||
}
|
||||
.stop-node:hover {
|
||||
transform: translateY(-1px);
|
||||
border-color: rgba(124,58,237,.25);
|
||||
box-shadow: 0 10px 24px rgba(124,58,237,.12);
|
||||
}
|
||||
.stop-node__line {
|
||||
position: absolute;
|
||||
left: 43px; top: 100%;
|
||||
width: 2px; height: 10px;
|
||||
background: linear-gradient(180deg, rgba(124,58,237,.35), rgba(124,58,237,0));
|
||||
}
|
||||
.stop-node:last-child .stop-node__line { display: none; }
|
||||
.stop-node__bullet {
|
||||
width: 44px; height: 44px;
|
||||
border-radius: 14px;
|
||||
background: linear-gradient(135deg,#a78bfa,#7c3aed);
|
||||
color: #fff;
|
||||
font-weight: 800; font-size: 1.05rem;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
border: 3px solid #fff;
|
||||
box-shadow: 0 6px 14px rgba(124,58,237,.30);
|
||||
}
|
||||
.stop-node__bullet.is-start { background: linear-gradient(135deg,#34d399,#10b981); box-shadow: 0 6px 14px rgba(16,185,129,.30); }
|
||||
.stop-node__bullet.is-end { background: linear-gradient(135deg,#fb7185,#e11d48); box-shadow: 0 6px 14px rgba(225,29,72,.28); }
|
||||
.stop-node--sky .stop-node__bullet:not(.is-start):not(.is-end) { background: linear-gradient(135deg,#7dd3fc,#0284c7); }
|
||||
.stop-node--pink .stop-node__bullet:not(.is-start):not(.is-end) { background: linear-gradient(135deg,#fda4af,#db2777); }
|
||||
.stop-node--mint .stop-node__bullet:not(.is-start):not(.is-end) { background: linear-gradient(135deg,#6ee7b7,#059669); }
|
||||
.stop-node--amber .stop-node__bullet:not(.is-start):not(.is-end) { background: linear-gradient(135deg,#fcd34d,#d97706); }
|
||||
.stop-node__body { min-width: 0; }
|
||||
.stop-node__head {
|
||||
display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.stop-node__title {
|
||||
font-weight: 800; font-size: 1.02rem;
|
||||
color: var(--ink, #1f1c44);
|
||||
text-decoration: none;
|
||||
}
|
||||
.stop-node__title:hover { color: var(--purple-700); }
|
||||
.stop-node__meta {
|
||||
display: flex; flex-wrap: wrap; gap: 8px;
|
||||
align-items: center;
|
||||
font-size: .85rem; color: var(--ink-muted);
|
||||
}
|
||||
.stop-node__loc { font-size: .82rem; }
|
||||
.stop-node__warn {
|
||||
font-size: .75rem; font-weight: 700;
|
||||
padding: 2px 8px; border-radius: 999px;
|
||||
background: #fff7ed; color: #c2410c;
|
||||
border: 1px solid #fed7aa;
|
||||
}
|
||||
.stop-node__arrow {
|
||||
font-size: 1.4rem; color: var(--muted);
|
||||
font-weight: 700; text-decoration: none;
|
||||
transition: transform .18s ease, color .18s ease;
|
||||
}
|
||||
.stop-node:hover .stop-node__arrow { color: var(--purple-700); transform: translateX(4px); }
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.route-hero__top { grid-template-columns: 76px 1fr; gap: 14px; }
|
||||
.route-hero__badge { width: 76px; height: 76px; font-size: 1.5rem; border-radius: 22px; }
|
||||
.route-map { height: 360px; }
|
||||
.stop-node { grid-template-columns: 48px 1fr; padding: 12px 14px; }
|
||||
.stop-node__bullet { width: 40px; height: 40px; font-size: .95rem; border-radius: 12px; }
|
||||
.stop-node__line { left: 37px; }
|
||||
.stop-node__arrow { display: none; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">
|
||||
<defs>
|
||||
<linearGradient id="bg" x1="0%" y1="0%" x2="100%" y2="100%">
|
||||
<stop offset="0%" stop-color="#8b5cf6"/>
|
||||
<stop offset="100%" stop-color="#ec4899"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect width="64" height="64" rx="16" fill="url(#bg)"/>
|
||||
<g fill="#fff" transform="translate(8 14)">
|
||||
<rect x="2" y="6" width="44" height="22" rx="6" fill="#fff"/>
|
||||
<rect x="6" y="10" width="14" height="10" rx="2" fill="#8b5cf6"/>
|
||||
<rect x="22" y="10" width="14" height="10" rx="2" fill="#8b5cf6"/>
|
||||
<circle cx="12" cy="32" r="5" fill="#1f2a44"/>
|
||||
<circle cx="36" cy="32" r="5" fill="#1f2a44"/>
|
||||
<circle cx="12" cy="32" r="2" fill="#fff"/>
|
||||
<circle cx="36" cy="32" r="2" fill="#fff"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 808 B |
@@ -0,0 +1,28 @@
|
||||
import "./globals.css";
|
||||
import type { Metadata } from "next";
|
||||
import { Header } from "@/components/Header";
|
||||
import { Footer } from "@/components/Footer";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "AT Transit — สถานีขนส่งผู้โดยสารจังหวัดอ่างทอง",
|
||||
description:
|
||||
"ค้นหาเส้นทาง ตารางเดินรถ และจุดจอดในจังหวัดอ่างทองและจังหวัดใกล้เคียง",
|
||||
};
|
||||
|
||||
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<html lang="th">
|
||||
<head>
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@400;500;600;700;800&family=Prompt:wght@400;500;600;700&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
</head>
|
||||
<body>
|
||||
<Header />
|
||||
{children}
|
||||
<Footer />
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
import Link from "next/link";
|
||||
import { api, type RouteListItem } from "@/lib/api";
|
||||
import { VisitTracker } from "@/lib/visit-tracker";
|
||||
|
||||
// Map route_group_code to visual tone
|
||||
const ZONE_TONES: Record<string, "sky" | "purple" | "pink" | "mint"> = {
|
||||
bangkok: "sky",
|
||||
interprovincial: "purple",
|
||||
in_province: "pink",
|
||||
municipal: "mint",
|
||||
};
|
||||
|
||||
const ZONE_DESCS: Record<string, string> = {
|
||||
bangkok: "เส้นทางเชื่อมต่อกรุงเทพมหานคร",
|
||||
interprovincial: "เส้นทางเชื่อมต่อจังหวัดใกล้เคียง",
|
||||
in_province: "เส้นทางภายในจังหวัดอ่างทอง",
|
||||
municipal: "เส้นทางภายในเขตเทศบาล",
|
||||
};
|
||||
|
||||
// Display order: bangkok → interprovincial → in_province → municipal
|
||||
const ZONE_ORDER = ["bangkok", "interprovincial", "in_province", "municipal"];
|
||||
|
||||
// Cycle chip colors within a zone for visual rhythm
|
||||
const CHIP_CYCLE = ["purple", "sky", "pink", "mint"] as const;
|
||||
|
||||
export default async function HomePage() {
|
||||
const [groupsRes, routesRes] = await Promise.allSettled([
|
||||
api.routeGroups(),
|
||||
api.routes(),
|
||||
]);
|
||||
|
||||
const groups = groupsRes.status === "fulfilled" ? groupsRes.value.items : [];
|
||||
const routes = routesRes.status === "fulfilled" ? routesRes.value.items : [];
|
||||
|
||||
// Group routes by code
|
||||
const byCode = new Map<string, RouteListItem[]>();
|
||||
for (const r of routes) {
|
||||
const list = byCode.get(r.route_group_code) ?? [];
|
||||
list.push(r);
|
||||
byCode.set(r.route_group_code, list);
|
||||
}
|
||||
|
||||
const orderedGroups = [...groups].sort((a, b) => {
|
||||
const ai = ZONE_ORDER.indexOf(a.code);
|
||||
const bi = ZONE_ORDER.indexOf(b.code);
|
||||
return (ai === -1 ? 99 : ai) - (bi === -1 ? 99 : bi);
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<VisitTracker path="/" />
|
||||
|
||||
<section className="hero">
|
||||
<div className="hero__blob one" aria-hidden />
|
||||
<div className="hero__blob two" aria-hidden />
|
||||
<div className="hero__blob three" aria-hidden />
|
||||
<div className="container hero__inner">
|
||||
<span className="hero__badge">✨ ยินดีต้อนรับ</span>
|
||||
<h1>
|
||||
สถานีขนส่งผู้โดยสารภายใน
|
||||
<br />
|
||||
<span className="hero__grad">จังหวัดอ่างทอง</span>
|
||||
</h1>
|
||||
<p className="hero__lead">
|
||||
ดูสายรถ, ค้นหาป้าย และเปิดตัวอย่างเส้นทางได้ทันทีจากหน้าแรก
|
||||
</p>
|
||||
<div className="hero__actions">
|
||||
<Link className="pill-link pill-link--primary" href="/routes">
|
||||
ดูรายละเอียดสายรถ
|
||||
</Link>
|
||||
<Link className="pill-link pill-link--secondary" href="/stops">
|
||||
ค้นหาป้ายหยุดรถ
|
||||
</Link>
|
||||
{routes[0] && (
|
||||
<Link
|
||||
className="pill-link pill-link--accent"
|
||||
href={`/routes/${encodeURIComponent(routes[0].route_id)}`}
|
||||
>
|
||||
ดูตัวอย่างสายรถ
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<main className="main">
|
||||
<div className="container">
|
||||
{orderedGroups.map((g) => {
|
||||
const items = byCode.get(g.code) ?? [];
|
||||
if (items.length === 0) return null;
|
||||
const tone = ZONE_TONES[g.code] ?? "purple";
|
||||
return (
|
||||
<section key={g.id} className="zone">
|
||||
<div className="zone__head">
|
||||
<span className={`zone__tag ${tone}`}>{g.label_th}</span>
|
||||
<p className="zone__desc">
|
||||
{ZONE_DESCS[g.code] ?? ""} · {items.length} เส้นทาง
|
||||
</p>
|
||||
</div>
|
||||
<div className="grid">
|
||||
{items.map((r, i) => (
|
||||
<Link
|
||||
key={r.route_id}
|
||||
href={`/routes/${encodeURIComponent(r.route_id)}`}
|
||||
className="card"
|
||||
>
|
||||
<div className={`card__head ${tone}`}>
|
||||
<p className="card__num">{r.route_id}</p>
|
||||
</div>
|
||||
<div className="card__body">
|
||||
<p className="card__name">{r.name_th}</p>
|
||||
<span className={`chip ${CHIP_CYCLE[i % CHIP_CYCLE.length]}`}>
|
||||
✅ ดูตาราง
|
||||
</span>
|
||||
</div>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</main>
|
||||
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
type ExpandedRoutePageProps = {
|
||||
params: Promise<{ routeId: string }>;
|
||||
};
|
||||
|
||||
export default async function ExpandedRoutePage({ params }: ExpandedRoutePageProps) {
|
||||
const { routeId } = await params;
|
||||
redirect(`/routes/${encodeURIComponent(routeId)}`);
|
||||
return null;
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
import { api, isApiNotFoundError, resolveFileUrl, type RouteDetail, type RouteStop, type StopListItem, type Schedule } from "@/lib/api";
|
||||
import LazyMapView from "@/components/LazyMapView";
|
||||
import { VisitTracker } from "@/lib/visit-tracker";
|
||||
|
||||
const TONES = ["sky", "purple", "pink", "mint", "amber"] as const;
|
||||
|
||||
type RouteDetailPageProps = {
|
||||
params: Promise<{ routeId: string }>;
|
||||
};
|
||||
|
||||
export default async function RouteDetailPage({
|
||||
params,
|
||||
}: RouteDetailPageProps) {
|
||||
const { routeId } = await params;
|
||||
|
||||
let route: RouteDetail | null = null;
|
||||
let stops: RouteStop[] = [];
|
||||
let schedules: Schedule[] = [];
|
||||
let allStops: StopListItem[] = [];
|
||||
|
||||
try {
|
||||
[route, { items: stops }, { items: schedules }, { items: allStops }] = await Promise.all([
|
||||
api.route(routeId),
|
||||
api.routeStops(routeId),
|
||||
api.schedules({ route_id: routeId }),
|
||||
api.stops(),
|
||||
]);
|
||||
} catch (error) {
|
||||
if (isApiNotFoundError(error)) {
|
||||
notFound();
|
||||
}
|
||||
route = null;
|
||||
stops = [];
|
||||
schedules = [];
|
||||
allStops = [];
|
||||
}
|
||||
|
||||
if (!route) {
|
||||
return (
|
||||
<main className="page">
|
||||
<VisitTracker path={`/routes/${routeId}`} />
|
||||
<section className="hero">
|
||||
<h1>ไม่สามารถโหลดข้อมูลเส้นทางได้</h1>
|
||||
<p className="muted">ระบบยังเปิดอยู่ แต่ backend ตอบกลับไม่ได้ในตอนนี้</p>
|
||||
<Link href="/routes">กลับไปหน้าสายรถ</Link>
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
// Build coord lookup by station_id from /stops dataset
|
||||
const coordById = new Map<number, { lat: number; lng: number }>();
|
||||
for (const s of allStops) {
|
||||
if (s.lat != null && s.lng != null) {
|
||||
coordById.set(s.id, { lat: s.lat, lng: s.lng });
|
||||
}
|
||||
}
|
||||
|
||||
const mapPoints = stops
|
||||
.map((s) => {
|
||||
const c = coordById.get(s.station_id);
|
||||
if (!c) return null;
|
||||
return {
|
||||
id: s.station_id,
|
||||
lat: c.lat,
|
||||
lng: c.lng,
|
||||
label: s.name_th,
|
||||
code: s.code,
|
||||
sequence: s.stop_sequence,
|
||||
};
|
||||
})
|
||||
.filter((x): x is NonNullable<typeof x> => x !== null);
|
||||
|
||||
const path: [number, number][] = mapPoints.map((p) => [p.lat, p.lng]);
|
||||
const provinceSet = new Set(
|
||||
stops.map((s) => s.province_th).filter((x): x is string => !!x),
|
||||
);
|
||||
|
||||
return (
|
||||
<main className="page">
|
||||
<VisitTracker path={`/routes/${routeId}`} />
|
||||
|
||||
<section className="page-hero page-hero--alt route-hero">
|
||||
<span className="page-hero__blob page-hero__blob--a" aria-hidden />
|
||||
<span className="page-hero__blob page-hero__blob--b" aria-hidden />
|
||||
<span className="page-hero__blob page-hero__blob--c" aria-hidden />
|
||||
<div className="route-hero__top">
|
||||
<div className="route-hero__badge">{route.route_id}</div>
|
||||
<div className="route-hero__title-wrap">
|
||||
<div className="route-hero__chips">
|
||||
<span className="chip-soft chip-soft--purple">{route.route_group_label_th || route.route_group_code}</span>
|
||||
<span className="chip-soft chip-soft--sky">{route.vehicle_type}</span>
|
||||
{provinceSet.size > 0 && (
|
||||
<span className="chip-soft chip-soft--mint">{provinceSet.size} จังหวัด</span>
|
||||
)}
|
||||
</div>
|
||||
<h1 className="page-hero__title">
|
||||
<span className="page-hero__title-grad">{route.name_th}</span>
|
||||
</h1>
|
||||
<p className="page-hero__subtitle">
|
||||
เส้นทางหมายเลข {route.route_id} · ผ่าน {stops.length} จุดจอด · {schedules.length} รอบเวลา
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="page-hero__stats">
|
||||
<span className="page-hero__stat"><b>{stops.length}</b> จุดจอด</span>
|
||||
<span className="page-hero__stat"><b>{schedules.length}</b> รอบเวลา</span>
|
||||
<span className="page-hero__stat"><b>{provinceSet.size}</b> จังหวัด</span>
|
||||
</div>
|
||||
|
||||
<div className="route-hero__actions">
|
||||
<Link href="/routes" className="route-hero__back">
|
||||
← กลับสายทั้งหมด
|
||||
</Link>
|
||||
</div>
|
||||
{/* ภาพประกอบ */}
|
||||
{route.images && route.images.length > 0 && (
|
||||
<section>
|
||||
<h2 className="section-title">ภาพประกอบ</h2>
|
||||
<div className="grid">
|
||||
{route.images.map((img) => (
|
||||
<figure key={img.id} className="card" style={{ padding: 8 }}>
|
||||
<img
|
||||
src={resolveFileUrl(img.url_path)}
|
||||
alt={String((img.meta as any)?.alt_th || route.name_th)}
|
||||
style={{ width: "100%", borderRadius: 12, display: "block" }}
|
||||
/>
|
||||
</figure>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{/* ติดต่อ */}
|
||||
<section>
|
||||
<h2 className="section-title">ติดต่อ</h2>
|
||||
{Array.isArray((route.contact as any)?.phones) && (route.contact as any).phones.length > 0 ? (
|
||||
<ul>
|
||||
{(route.contact as any).phones.map((p: any, i: number) => (
|
||||
<li key={i}>
|
||||
<strong>{p.label || "โทร"}:</strong> <a href={`tel:${p.number}`}>{p.number}</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<p className="muted">ไม่พบเบอร์ติดต่อ</p>
|
||||
)}
|
||||
</section>
|
||||
|
||||
{/* เมตาดาตา */}
|
||||
<section>
|
||||
<h2 className="section-title">เมตาดาตา</h2>
|
||||
<pre className="card" style={{ overflow: "auto", padding: 16 }}>
|
||||
{JSON.stringify(route.metadata, null, 2)}
|
||||
</pre>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section className="route-map-section">
|
||||
<div className="route-map-section__head">
|
||||
<h2 className="section-title">เส้นทางวิ่ง</h2>
|
||||
<span className="route-map-section__legend">
|
||||
<span><i className="dot dot--start" /> ต้นทาง</span>
|
||||
<span><i className="dot dot--mid" /> จุดผ่าน</span>
|
||||
<span><i className="dot dot--end" /> ปลายทาง</span>
|
||||
</span>
|
||||
</div>
|
||||
{mapPoints.length >= 1 ? (
|
||||
<div className="map-wrap map-wrap--soft route-map">
|
||||
<LazyMapView points={mapPoints} path={path} />
|
||||
</div>
|
||||
) : (
|
||||
<p className="muted route-map-empty">— ยังไม่มีพิกัดสำหรับจุดจอดของสายนี้ —</p>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2 className="section-title">จุดจอดตามลำดับ ({stops.length})</h2>
|
||||
<ol className="stop-timeline">
|
||||
{stops.map((s, i) => {
|
||||
const tone = TONES[i % TONES.length];
|
||||
const isStart = i === 0;
|
||||
const isEnd = i === stops.length - 1;
|
||||
const hasCoord = coordById.has(s.station_id);
|
||||
const stopHref = s.code ? `/stops/${encodeURIComponent(s.code)}` : null;
|
||||
return (
|
||||
<li key={s.station_id} className={`stop-node stop-node--${tone}`}>
|
||||
<span className="stop-node__line" aria-hidden />
|
||||
<span className={`stop-node__bullet ${isStart ? "is-start" : isEnd ? "is-end" : ""}`}>
|
||||
{s.stop_sequence}
|
||||
</span>
|
||||
<div className="stop-node__body">
|
||||
<div className="stop-node__head">
|
||||
{stopHref ? (
|
||||
<Link href={stopHref} className="stop-node__title">
|
||||
{s.name_th}
|
||||
</Link>
|
||||
) : (
|
||||
<span className="stop-node__title">{s.name_th}</span>
|
||||
)}
|
||||
{isStart && <span className="chip-soft chip-soft--mint">ต้นทาง</span>}
|
||||
{isEnd && <span className="chip-soft chip-soft--pink">ปลายทาง</span>}
|
||||
</div>
|
||||
<div className="stop-node__meta">
|
||||
<span className="chip-soft chip-soft--sky">{s.station_type}</span>
|
||||
{(s.city_th || s.province_th) && (
|
||||
<span className="stop-node__loc">
|
||||
📍 {[s.city_th, s.province_th].filter(Boolean).join(" · ")}
|
||||
</span>
|
||||
)}
|
||||
{!hasCoord && (
|
||||
<span className="stop-node__warn">ไม่มีพิกัดบนแผนที่</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{stopHref ? (
|
||||
<Link href={stopHref} className="stop-node__arrow" aria-label="ดูจุดจอด">→</Link>
|
||||
) : (
|
||||
<span className="stop-node__arrow" aria-hidden>→</span>
|
||||
)}
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ol>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2 className="section-title">ตารางเวลา ({schedules.length})</h2>
|
||||
{schedules.length === 0 ? (
|
||||
<p className="muted">ยังไม่มีข้อมูลตารางเวลา</p>
|
||||
) : (
|
||||
<div className="schedule-list">
|
||||
{schedules.map((s, i) => {
|
||||
const tone = TONES[i % TONES.length];
|
||||
return (
|
||||
<article key={s.id} className={`schedule-card schedule-card--${tone}`}>
|
||||
<span className="schedule-card__rail" aria-hidden />
|
||||
<div className="schedule-card__head">
|
||||
<div className={`schedule-card__route ${tone}`}>
|
||||
<span>{s.station_name_th}</span>
|
||||
<small>จุดต้นทาง</small>
|
||||
</div>
|
||||
<div className="schedule-card__meta">
|
||||
<strong>{s.direction_note || "ทุกทิศทาง"}</strong>
|
||||
{s.schedule_note && <span>{s.schedule_note}</span>}
|
||||
</div>
|
||||
</div>
|
||||
{s.departure_times.length === 0 ? (
|
||||
<span className="schedule-card__empty">— ยังไม่มีรอบ —</span>
|
||||
) : (
|
||||
<div className="schedule-card__times">
|
||||
{s.departure_times.map((t, j) => (
|
||||
<span key={`${s.id}-${j}`} className="schedule-card__time">🕒 {t}</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</article>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
import Link from "next/link";
|
||||
import { api } from "@/lib/api";
|
||||
import { VisitTracker } from "@/lib/visit-tracker";
|
||||
|
||||
type SP = { group?: string; province?: string };
|
||||
|
||||
const TONES = ["sky", "purple", "pink", "mint", "amber"] as const;
|
||||
const GROUP_TONE: Record<string, (typeof TONES)[number]> = {
|
||||
REGIONAL: "sky",
|
||||
INTRA: "purple",
|
||||
INTERPROV: "pink",
|
||||
LOCAL: "mint",
|
||||
AIRPORT: "amber",
|
||||
};
|
||||
|
||||
export default async function RoutesPage({ searchParams }: { searchParams: SP }) {
|
||||
const group = searchParams.group;
|
||||
const province = searchParams.province ? Number(searchParams.province) : undefined;
|
||||
const res = await api.routes({ group, province }).catch(() => ({ items: [] }));
|
||||
const { items } = res;
|
||||
const groupCounts = items.reduce<Record<string, { label: string; n: number }>>((acc, r) => {
|
||||
const key = r.route_group_code;
|
||||
if (!acc[key]) acc[key] = { label: r.route_group_label_th || key, n: 0 };
|
||||
acc[key].n += 1;
|
||||
return acc;
|
||||
}, {});
|
||||
return (
|
||||
<main className="page">
|
||||
<VisitTracker path="/routes" />
|
||||
|
||||
<section className="page-hero page-hero--alt">
|
||||
<div className="page-hero__blob page-hero__blob--a" />
|
||||
<div className="page-hero__blob page-hero__blob--b" />
|
||||
<div className="page-hero__blob page-hero__blob--c" />
|
||||
<div className="page-hero__inner">
|
||||
<span className="page-hero__badge">🛣️ ROUTE NETWORK</span>
|
||||
<h1 className="page-hero__title">
|
||||
เส้นทางเดินรถ<span className="page-hero__title-grad">ทั้งหมด</span>
|
||||
</h1>
|
||||
<p className="page-hero__subtitle">
|
||||
{group ? `กรองหมวด: ${group}` : "ครอบคลุมทุกหมวด"}
|
||||
{province ? ` · จังหวัด #${province}` : ""}
|
||||
</p>
|
||||
<div className="page-hero__stats">
|
||||
<span className="page-hero__stat"><b>{items.length}</b> เส้นทาง</span>
|
||||
<span className="page-hero__stat"><b>{Object.keys(groupCounts).length}</b> หมวด</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div className="toolbar">
|
||||
<div className="toolbar__search">
|
||||
<span aria-hidden>🔍</span>
|
||||
<input placeholder="ค้นหาเลขสาย หรือชื่อเส้นทาง…" disabled />
|
||||
</div>
|
||||
<div className="toolbar__chips">
|
||||
{Object.entries(groupCounts).map(([code, { label, n }]) => (
|
||||
<span key={code} className={`chip-soft chip-soft--${GROUP_TONE[code] ?? "sky"}`}>
|
||||
{label} · {n}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="tile-grid">
|
||||
{items.map((r, i) => {
|
||||
const tone = GROUP_TONE[r.route_group_code] ?? TONES[i % TONES.length];
|
||||
return (
|
||||
<Link
|
||||
key={r.route_id}
|
||||
href={`/routes/${encodeURIComponent(r.route_id)}`}
|
||||
className={`tile tile--${tone}`}
|
||||
>
|
||||
<div className={`tile__badge tile__badge--${tone} tile__badge--num`}>
|
||||
<span>{r.route_id}</span>
|
||||
</div>
|
||||
<div className="tile__body">
|
||||
<p className="tile__title">{r.name_th}</p>
|
||||
<p className="tile__meta">{r.route_group_label_th || r.route_group_code}</p>
|
||||
<div className="tile__chips">
|
||||
<span className={`chip-soft chip-soft--${tone}`}>
|
||||
{r.route_group_label_th || r.route_group_code}
|
||||
</span>
|
||||
<span className="chip-soft chip-soft--mint">🚌 {r.vehicle_type}</span>
|
||||
</div>
|
||||
</div>
|
||||
<span className="tile__arrow" aria-hidden>→</span>
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { notFound, redirect } from "next/navigation";
|
||||
|
||||
interface StopDetailPageProps {
|
||||
params: Promise<{ stopId: string }>;
|
||||
}
|
||||
|
||||
export default async function StopDetailPage({ params }: StopDetailPageProps) {
|
||||
const { stopId } = await params;
|
||||
if (!stopId || stopId === "undefined") {
|
||||
notFound();
|
||||
}
|
||||
redirect(`/stops/details?code=${encodeURIComponent(stopId)}`);
|
||||
return null;
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
import { api, isApiNotFoundError, resolveFileUrl, type Schedule, type StopDetail } from "@/lib/api";
|
||||
import LazyMapView from "@/components/LazyMapView";
|
||||
import { VisitTracker } from "@/lib/visit-tracker";
|
||||
|
||||
const TONES = ["sky", "purple", "pink", "mint", "amber"] as const;
|
||||
|
||||
type StopDetailsPageProps = {
|
||||
searchParams: Promise<{ code?: string }>;
|
||||
};
|
||||
|
||||
export default async function StopDetailsPage({ searchParams }: StopDetailsPageProps) {
|
||||
const { code } = await searchParams;
|
||||
if (!code) notFound();
|
||||
|
||||
let stop: StopDetail | null = null;
|
||||
let schedules: Schedule[] = [];
|
||||
|
||||
try {
|
||||
stop = await api.stop(code);
|
||||
({ items: schedules } = await api.schedules({ stop_code: stop.code }));
|
||||
} catch (error) {
|
||||
if (isApiNotFoundError(error)) {
|
||||
notFound();
|
||||
}
|
||||
stop = null;
|
||||
schedules = [];
|
||||
}
|
||||
|
||||
if (!stop) {
|
||||
return (
|
||||
<main className="page">
|
||||
<VisitTracker path={`/stops/details?code=${code}`} />
|
||||
<section className="hero">
|
||||
<h1>ไม่สามารถโหลดข้อมูลป้ายนี้ได้</h1>
|
||||
<p className="muted">ระบบยังเปิดอยู่ แต่ backend ตอบกลับไม่ได้ในตอนนี้</p>
|
||||
<Link href="/stops">กลับไปหน้าป้ายหยุดรถ</Link>
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
const place = [stop.city_th, stop.province_th].filter(Boolean).join(" / ") || "—";
|
||||
const hasMap = stop.lat != null && stop.lng != null;
|
||||
const mapPoints = hasMap
|
||||
? [{ id: stop.id, lat: stop.lat as number, lng: stop.lng as number, label: stop.name_th, code: stop.code }]
|
||||
: [];
|
||||
|
||||
return (
|
||||
<main className="page">
|
||||
<VisitTracker path={`/stops/details?code=${stop.code}`} />
|
||||
<section className="hero">
|
||||
<span className="pill">{stop.station_type}</span>
|
||||
<h1 style={{ marginTop: 10 }}>{stop.name_th}</h1>
|
||||
<p className="muted">📍 {place}{hasMap ? ` · ${stop.lat?.toFixed(4)}, ${stop.lng?.toFixed(4)}` : ""}</p>
|
||||
</section>
|
||||
<div className="stop-detail__split">
|
||||
{stop.images.length > 0 ? (
|
||||
<div className="stop-detail__gallery">
|
||||
<img
|
||||
className="stop-detail__hero-img"
|
||||
src={resolveFileUrl(stop.images[0].url_path)}
|
||||
alt={(stop.images[0].meta as { alt_th?: string } | undefined)?.alt_th ?? stop.name_th}
|
||||
/>
|
||||
{stop.images.length > 1 && (
|
||||
<div className="stop-detail__thumbs">
|
||||
{stop.images.slice(1, 5).map((img) => (
|
||||
<img key={img.id} src={resolveFileUrl(img.url_path)} alt={stop.name_th} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<div className="stop-detail__gallery stop-detail__gallery--empty">
|
||||
<div className="stop-detail__placeholder">📷 ยังไม่มีรูปป้ายนี้</div>
|
||||
</div>
|
||||
)}
|
||||
{hasMap ? (
|
||||
<div className="stop-detail__map">
|
||||
<LazyMapView points={mapPoints} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="stop-detail__map stop-detail__map--empty">
|
||||
<div className="stop-detail__placeholder">🗺️ ยังไม่มีพิกัดของป้ายนี้</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<h2 className="section-title">ตารางเวลาที่จุดนี้</h2>
|
||||
{schedules.length === 0 ? (
|
||||
<p className="muted">ยังไม่มีข้อมูล</p>
|
||||
) : (
|
||||
<div className="schedule-list">
|
||||
{schedules.map((s, i) => {
|
||||
const tone = TONES[i % TONES.length];
|
||||
return (
|
||||
<article key={s.id} className={`schedule-card schedule-card--${tone}`}>
|
||||
<div className="schedule-card__rail" />
|
||||
<div className="schedule-card__head">
|
||||
<Link
|
||||
href={`/routes/${encodeURIComponent(s.route_id)}`}
|
||||
className={`schedule-card__route ${tone}`}
|
||||
>
|
||||
<span className="schedule-card__route-label">เส้นทาง</span>
|
||||
<span className="schedule-card__route-id">{s.route_id}</span>
|
||||
</Link>
|
||||
<div className="schedule-card__meta">
|
||||
<span className="schedule-card__direction">
|
||||
<span aria-hidden>🧭</span>
|
||||
{s.direction_note || "ไม่ระบุทิศทาง"}
|
||||
</span>
|
||||
{s.schedule_note && (
|
||||
<span className="schedule-card__note">📝 {s.schedule_note}</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="schedule-card__times">
|
||||
{s.departure_times.length === 0 ? (
|
||||
<span className="schedule-card__empty">— ยังไม่มีรอบ —</span>
|
||||
) : (
|
||||
s.departure_times.map((t, j) => (
|
||||
<span key={j} className="schedule-card__time">🕒 {t}</span>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</article>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
import Link from "next/link";
|
||||
import { api } from "@/lib/api";
|
||||
import LazyMapView from "@/components/LazyMapView";
|
||||
import { VisitTracker } from "@/lib/visit-tracker";
|
||||
|
||||
const TONES = ["sky", "purple", "pink", "mint", "amber"] as const;
|
||||
const TYPE_TONE: Record<string, (typeof TONES)[number]> = {
|
||||
terminal: "purple",
|
||||
station: "sky",
|
||||
pickup: "amber",
|
||||
market: "pink",
|
||||
landmark: "mint",
|
||||
};
|
||||
const TYPE_ICON: Record<string, string> = {
|
||||
terminal: "🚍",
|
||||
station: "🚏",
|
||||
pickup: "🛣️",
|
||||
market: "🏪",
|
||||
landmark: "📍",
|
||||
};
|
||||
const TYPE_LABEL: Record<string, string> = {
|
||||
terminal: "สถานีขนส่ง",
|
||||
station: "ป้ายหลัก",
|
||||
pickup: "จุดรับส่ง",
|
||||
market: "ตลาด/ชุมชน",
|
||||
landmark: "จุดสังเกต",
|
||||
};
|
||||
|
||||
export default async function StopsPage() {
|
||||
const { items } = await api.stops().catch(() => ({ items: [] }));
|
||||
const points = items
|
||||
.filter((s) => s.lat != null && s.lng != null)
|
||||
.map((s) => ({ id: s.id, lat: s.lat as number, lng: s.lng as number, label: s.name_th, code: s.code }));
|
||||
const typeCounts = items.reduce<Record<string, number>>((acc, s) => {
|
||||
acc[s.station_type] = (acc[s.station_type] ?? 0) + 1;
|
||||
return acc;
|
||||
}, {});
|
||||
return (
|
||||
<main className="page">
|
||||
<VisitTracker path="/stops" />
|
||||
|
||||
<section className="page-hero">
|
||||
<div className="page-hero__blob page-hero__blob--a" />
|
||||
<div className="page-hero__blob page-hero__blob--b" />
|
||||
<div className="page-hero__blob page-hero__blob--c" />
|
||||
<div className="page-hero__inner">
|
||||
<span className="page-hero__badge">🚏 STOP DIRECTORY</span>
|
||||
<h1 className="page-hero__title">
|
||||
จุดจอด<span className="page-hero__title-grad">ทั่วประเทศ</span>
|
||||
</h1>
|
||||
<p className="page-hero__subtitle">
|
||||
ค้นหาป้าย / สถานีขนส่ง พร้อมแผนที่และเส้นทางที่ผ่าน
|
||||
</p>
|
||||
<div className="page-hero__stats">
|
||||
<span className="page-hero__stat"><b>{items.length}</b> จุดจอด</span>
|
||||
<span className="page-hero__stat"><b>{points.length}</b> มีพิกัด</span>
|
||||
<span className="page-hero__stat"><b>{Object.keys(typeCounts).length}</b> ประเภท</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{points.length > 0 && (
|
||||
<div className="map-wrap map-wrap--soft">
|
||||
<LazyMapView points={points} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="toolbar">
|
||||
<div className="toolbar__search">
|
||||
<span aria-hidden>🔍</span>
|
||||
<input placeholder="ค้นหาชื่อป้าย หรือจังหวัด…" disabled />
|
||||
</div>
|
||||
<div className="toolbar__chips">
|
||||
{Object.entries(typeCounts).map(([t, n]) => (
|
||||
<span key={t} className={`chip-soft chip-soft--${TYPE_TONE[t] ?? "sky"}`}>
|
||||
{TYPE_ICON[t] ?? "📍"} {TYPE_LABEL[t] ?? t} · {n}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="tile-grid">
|
||||
{items.map((s, i) => {
|
||||
const tone = TYPE_TONE[s.station_type] ?? TONES[i % TONES.length];
|
||||
const icon = TYPE_ICON[s.station_type] ?? "📍";
|
||||
const place = [s.city_th, s.province_th].filter(Boolean).join(" · ");
|
||||
const stopHref = s.code ? `/stops/${encodeURIComponent(s.code)}` : null;
|
||||
return (
|
||||
stopHref ? (
|
||||
<Link
|
||||
key={s.id}
|
||||
href={stopHref}
|
||||
className={`tile tile--${tone}`}
|
||||
>
|
||||
<div className={`tile__badge tile__badge--${tone}`}>
|
||||
<span>{icon}</span>
|
||||
</div>
|
||||
<div className="tile__body">
|
||||
<p className="tile__title">{s.name_th}</p>
|
||||
<p className="tile__meta">{place || "—"}</p>
|
||||
<div className="tile__chips">
|
||||
<span className={`chip-soft chip-soft--${tone}`}>
|
||||
{TYPE_LABEL[s.station_type] ?? s.station_type}
|
||||
</span>
|
||||
{s.lat != null && s.lng != null && (
|
||||
<span className="chip-soft chip-soft--mint">📍 บนแผนที่</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<span className="tile__arrow" aria-hidden>→</span>
|
||||
</Link>
|
||||
) : (
|
||||
<div key={s.id} className={`tile tile--${tone} tile--disabled`}>
|
||||
<div className={`tile__badge tile__badge--${tone}`}>
|
||||
<span>{icon}</span>
|
||||
</div>
|
||||
<div className="tile__body">
|
||||
<p className="tile__title">{s.name_th}</p>
|
||||
<p className="tile__meta">{place || "—"}</p>
|
||||
<div className="tile__chips">
|
||||
<span className={`chip-soft chip-soft--${tone}`}>
|
||||
{TYPE_LABEL[s.station_type] ?? s.station_type}
|
||||
</span>
|
||||
{s.lat != null && s.lng != null && (
|
||||
<span className="chip-soft chip-soft--mint">📍 บนแผนที่</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<span className="tile__arrow" aria-hidden>→</span>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
import Link from "next/link";
|
||||
import Image from "next/image";
|
||||
import { api, resolveFileUrl } from "@/lib/api";
|
||||
|
||||
const popularRoutes = [
|
||||
{ id: "101", label: "สาย 101 · อ่างทอง-อยุธยา" },
|
||||
{ id: "902", label: "สาย 902 · กรุงเทพ-อ่างทอง" },
|
||||
{ id: "15", label: "สาย 15 · สายใน" },
|
||||
{ id: "464", label: "สาย 464 · สุพรรณ-สระบุรี" },
|
||||
];
|
||||
|
||||
const SPONSOR_LABELS: Record<string, string> = {
|
||||
"7-11": "7-Eleven",
|
||||
"shopee": "Shopee",
|
||||
"lazada": "Lazada",
|
||||
"airasia-move": "airasia MOVE",
|
||||
"busonlineticket": "busonlineticket",
|
||||
"trip": "Trip.com",
|
||||
"truck2hand": "truck2hand",
|
||||
"tcl999-angthong": "ทีซีแอล 999 อ่างทอง",
|
||||
"bus-pingraow": "รถบัสปิ่นเกล้า",
|
||||
};
|
||||
|
||||
function labelFor(entityId: string): string {
|
||||
return SPONSOR_LABELS[entityId] ?? entityId;
|
||||
}
|
||||
|
||||
export async function Footer() {
|
||||
let sponsors: { entity_id: string; url_path: string }[] = [];
|
||||
try {
|
||||
const res = await api.images({ entity_type: "sponsor" });
|
||||
sponsors = res.items.map((item) => ({
|
||||
entity_id: item.entity_id,
|
||||
url_path: item.url_path,
|
||||
}));
|
||||
} catch {
|
||||
sponsors = [];
|
||||
}
|
||||
|
||||
return (
|
||||
<footer className="footer">
|
||||
<div className="container">
|
||||
<div className="footer__grid">
|
||||
<div className="footer__brand">
|
||||
<div className="footer__brand-row">
|
||||
<Image src="/logo.svg" alt="AT Transit" width={48} height={48} />
|
||||
<div>
|
||||
<strong>AT Transit</strong>
|
||||
<span>สถานีขนส่งผู้โดยสารจังหวัดอ่างทอง</span>
|
||||
</div>
|
||||
</div>
|
||||
<p>
|
||||
ศูนย์รวมข้อมูลตารางเดินรถ จุดจอด และเส้นทางในจังหวัดอ่างทองและจังหวัดใกล้เคียง
|
||||
อัปเดตข้อมูลล่าสุดจากผู้ประกอบการแต่ละสายโดยตรง
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="footer__col">
|
||||
<h4>เมนู</h4>
|
||||
<ul>
|
||||
<li><Link href="/">หน้าแรก</Link></li>
|
||||
<li><Link href="/stops">ค้นหาป้ายหยุดรถ</Link></li>
|
||||
<li><Link href="/routes">รายละเอียดสายรถ</Link></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div className="footer__col">
|
||||
<h4>สายยอดนิยม</h4>
|
||||
<ul>
|
||||
{popularRoutes.map((r) => (
|
||||
<li key={r.id}>
|
||||
<Link href={`/routes/${r.id}`}>{r.label}</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div className="footer__col footer__contact">
|
||||
<h4>ติดต่อ</h4>
|
||||
<div className="row"><a href="tel:+66649639025">📞 +66 64 963 9025</a></div>
|
||||
<div className="row"><span>📍 ถนนเทศบาล 1 อ.เมือง อ่างทอง</span></div>
|
||||
<div className="row"><span>🕒 บริการ 04:30 - 21:00 น.</span></div>
|
||||
<div className="row"><a href="#">💬 LINE Official: @attransit</a></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section className="footer__sponsors" aria-label="ผู้สนับสนุน">
|
||||
<h4>ผู้สนับสนุน & พาร์ทเนอร์</h4>
|
||||
<p className="lead">จองตั๋ว · สั่งของ · เช็กของฝาก ที่ร้านค้าและบริการพันธมิตรของเรา</p>
|
||||
<div className="sponsor-strip">
|
||||
{sponsors.length > 0 ? (
|
||||
sponsors.map((s) => (
|
||||
<a
|
||||
key={s.entity_id}
|
||||
className="sponsor-tile"
|
||||
href="#"
|
||||
aria-label={labelFor(s.entity_id)}
|
||||
title={labelFor(s.entity_id)}
|
||||
>
|
||||
<img src={resolveFileUrl(s.url_path)} alt={labelFor(s.entity_id)} loading="lazy" />
|
||||
</a>
|
||||
))
|
||||
) : (
|
||||
<span className="sponsor-tile sponsor-tile--empty">ยังไม่มีข้อมูลผู้สนับสนุน</span>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div className="footer__bottom">
|
||||
<p>© {new Date().getFullYear()} AT Transit <span className="pill">mockup template</span></p>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
"use client";
|
||||
import Link from "next/link";
|
||||
import Image from "next/image";
|
||||
import { usePathname } from "next/navigation";
|
||||
|
||||
const links = [
|
||||
{ href: "/", label: "หน้าแรก" },
|
||||
{ href: "/stops", label: "ป้ายหยุดรถ" },
|
||||
{ href: "/routes", label: "รายละเอียดสายรถ" },
|
||||
];
|
||||
|
||||
export function Header() {
|
||||
const pathname = usePathname();
|
||||
const isActive = (href: string) =>
|
||||
href === "/" ? pathname === "/" : pathname.startsWith(href);
|
||||
|
||||
return (
|
||||
<header className="topbar">
|
||||
<div className="topbar__inner">
|
||||
<Link href="/" className="brand">
|
||||
<Image
|
||||
src="/logo.svg"
|
||||
alt="AT Transit"
|
||||
width={44}
|
||||
height={44}
|
||||
className="brand__logo"
|
||||
priority
|
||||
/>
|
||||
<div>
|
||||
<p className="brand__title">AT Transit</p>
|
||||
<p className="brand__subtitle">สถานีขนส่งผู้โดยสารจังหวัดอ่างทอง</p>
|
||||
</div>
|
||||
</Link>
|
||||
<nav className="nav" aria-label="เมนูหลัก">
|
||||
{links.map((l) => (
|
||||
<Link key={l.href} href={l.href} className={isActive(l.href) ? "active" : ""}>
|
||||
{l.label}
|
||||
</Link>
|
||||
))}
|
||||
</nav>
|
||||
<Link href="/routes" className="cta-pill">เช็กเวลาเดินรถ</Link>
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
"use client";
|
||||
|
||||
import dynamic from "next/dynamic";
|
||||
import type { MapViewProps } from "@/components/MapView";
|
||||
|
||||
const ClientMapView = dynamic(() => import("@/components/MapView"), { ssr: false });
|
||||
|
||||
export default function LazyMapView(props: MapViewProps) {
|
||||
return <ClientMapView {...props} />;
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
"use client";
|
||||
import "leaflet/dist/leaflet.css";
|
||||
import { MapContainer, TileLayer, Marker, Popup, Polyline, useMap } from "react-leaflet";
|
||||
import L from "leaflet";
|
||||
import { useEffect } from "react";
|
||||
|
||||
type LatLng = [number, number];
|
||||
type Point = { id: number; lat: number; lng: number; label: string; code: string; sequence?: number };
|
||||
|
||||
// Fix default marker icon paths for webpack/Next
|
||||
const icon = new L.Icon({
|
||||
iconUrl: "https://unpkg.com/[email protected]/dist/images/marker-icon.png",
|
||||
iconRetinaUrl: "https://unpkg.com/[email protected]/dist/images/marker-icon-2x.png",
|
||||
shadowUrl: "https://unpkg.com/[email protected]/dist/images/marker-shadow.png",
|
||||
iconSize: [25, 41],
|
||||
iconAnchor: [12, 41],
|
||||
});
|
||||
|
||||
function numberedIcon(n: number, tone: "start" | "mid" | "end") {
|
||||
const colors: Record<string, string> = {
|
||||
start: "linear-gradient(135deg,#34d399,#10b981)",
|
||||
end: "linear-gradient(135deg,#fb7185,#e11d48)",
|
||||
mid: "linear-gradient(135deg,#a78bfa,#7c3aed)",
|
||||
};
|
||||
const html =
|
||||
'<div style="' +
|
||||
'width:32px;height:32px;border-radius:50%;' +
|
||||
'background:' + colors[tone] + ';' +
|
||||
'color:#fff;font-weight:800;font-size:13px;font-family:system-ui;' +
|
||||
'display:flex;align-items:center;justify-content:center;' +
|
||||
'border:3px solid #fff;' +
|
||||
'box-shadow:0 4px 10px rgba(31,28,68,.28), 0 0 0 1px rgba(124,58,237,.18);' +
|
||||
'">' + String(n) + '</div>';
|
||||
return L.divIcon({
|
||||
html,
|
||||
className: "route-marker",
|
||||
iconSize: [32, 32],
|
||||
iconAnchor: [16, 16],
|
||||
popupAnchor: [0, -14],
|
||||
});
|
||||
}
|
||||
|
||||
function FitBounds({ positions }: { positions: LatLng[] }) {
|
||||
const map = useMap();
|
||||
useEffect(() => {
|
||||
if (positions.length === 0) return;
|
||||
if (positions.length === 1) {
|
||||
map.setView(positions[0], 12);
|
||||
return;
|
||||
}
|
||||
const bounds = L.latLngBounds(positions.map((p) => L.latLng(p[0], p[1])));
|
||||
map.fitBounds(bounds, { padding: [36, 36] });
|
||||
}, [map, positions]);
|
||||
return null;
|
||||
}
|
||||
|
||||
type Props = {
|
||||
points: Point[];
|
||||
path?: LatLng[];
|
||||
};
|
||||
|
||||
export type MapViewProps = Props;
|
||||
|
||||
export default function MapView({ points, path }: Props) {
|
||||
const fallback: LatLng[] = points.map((p) => [p.lat, p.lng]);
|
||||
const positions: LatLng[] = path && path.length > 0 ? path : fallback;
|
||||
const center: LatLng = positions.length > 0 ? positions[0] : [9.1, 99.3];
|
||||
const isRoute = !!path && path.length > 0;
|
||||
return (
|
||||
<MapContainer center={center} zoom={9} style={{ height: "100%", width: "100%" }}>
|
||||
<TileLayer
|
||||
attribution='© OpenStreetMap'
|
||||
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
||||
/>
|
||||
{isRoute && path ? (
|
||||
<Polyline
|
||||
positions={path}
|
||||
pathOptions={{ color: "#7c3aed", weight: 5, opacity: 0.85, lineCap: "round" }}
|
||||
/>
|
||||
) : null}
|
||||
{points.map((p, idx) => {
|
||||
let tone: "start" | "mid" | "end" = "mid";
|
||||
if (isRoute) {
|
||||
if (idx === 0) tone = "start";
|
||||
else if (idx === points.length - 1) tone = "end";
|
||||
}
|
||||
const markerIcon = isRoute ? numberedIcon(p.sequence ?? idx + 1, tone) : icon;
|
||||
const stopHref = p.code ? `/stops/${encodeURIComponent(p.code)}` : null;
|
||||
return (
|
||||
<Marker key={String(p.id) + "-" + String(idx)} position={[p.lat, p.lng]} icon={markerIcon}>
|
||||
<Popup>
|
||||
<strong>{p.label}</strong>
|
||||
<br />
|
||||
{stopHref ? <a href={stopHref}>รายละเอียด →</a> : <span>ไม่มีรหัสป้าย</span>}
|
||||
</Popup>
|
||||
</Marker>
|
||||
);
|
||||
})}
|
||||
<FitBounds positions={positions} />
|
||||
</MapContainer>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
export const API_BASE =
|
||||
process.env.NEXT_PUBLIC_API_BASE || "/api";
|
||||
export const FILES_BASE =
|
||||
process.env.NEXT_PUBLIC_FILES_BASE || "/files";
|
||||
|
||||
const SERVER_API_BASE =
|
||||
process.env.INTERNAL_API_BASE ||
|
||||
process.env.BACKEND_INTERNAL_URL ||
|
||||
process.env.NEXT_PUBLIC_API_BASE ||
|
||||
"http://localhost:20001/api";
|
||||
|
||||
export class ApiError extends Error {
|
||||
status: number;
|
||||
body: string;
|
||||
|
||||
constructor(status: number, statusText: string, body: string) {
|
||||
super(`API ${status} ${statusText}: ${body}`);
|
||||
this.name = "ApiError";
|
||||
this.status = status;
|
||||
this.body = body;
|
||||
}
|
||||
}
|
||||
|
||||
export function isApiNotFoundError(error: unknown): boolean {
|
||||
return (
|
||||
typeof error === "object" &&
|
||||
error !== null &&
|
||||
"status" in error &&
|
||||
(error as { status?: unknown }).status === 404
|
||||
);
|
||||
}
|
||||
|
||||
async function request<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
const base = typeof window === "undefined" ? SERVER_API_BASE : API_BASE;
|
||||
const res = await fetch(`${base}${path}`, {
|
||||
...init,
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
...(init?.headers || {}),
|
||||
},
|
||||
cache: "no-store",
|
||||
});
|
||||
if (!res.ok) {
|
||||
const body = await res.text().catch(() => "");
|
||||
throw new ApiError(res.status, res.statusText, body);
|
||||
}
|
||||
return (await res.json()) as T;
|
||||
}
|
||||
|
||||
export function resolveFileUrl(path: string): string {
|
||||
if (/^https?:\/\//i.test(path)) {
|
||||
return path;
|
||||
}
|
||||
if (path.startsWith(FILES_BASE)) {
|
||||
return path;
|
||||
}
|
||||
return `${FILES_BASE}${path.startsWith("/") ? path : `/${path}`}`;
|
||||
}
|
||||
|
||||
export const api = {
|
||||
provinces: () => request<{ items: Province[] }>("/provinces"),
|
||||
routeGroups: () => request<{ items: RouteGroup[] }>("/route-groups"),
|
||||
routes: (params: { group?: string; province?: number } = {}) => {
|
||||
const q = new URLSearchParams();
|
||||
if (params.group) q.set("group", params.group);
|
||||
if (params.province != null) q.set("province", String(params.province));
|
||||
const qs = q.toString();
|
||||
return request<{ items: RouteListItem[] }>(
|
||||
`/routes${qs ? `?${qs}` : ""}`,
|
||||
);
|
||||
},
|
||||
route: (routeId: string) => request<RouteDetail>(`/routes/${encodeURIComponent(routeId)}`),
|
||||
routeStops: (routeId: string) =>
|
||||
request<{ items: RouteStop[] }>(`/routes/${encodeURIComponent(routeId)}/stops`),
|
||||
stops: (params: { bbox?: string; q?: string } = {}) => {
|
||||
const q = new URLSearchParams();
|
||||
if (params.bbox) q.set("bbox", params.bbox);
|
||||
if (params.q) q.set("q", params.q);
|
||||
const qs = q.toString();
|
||||
return request<{ items: StopListItem[] }>(`/stops${qs ? `?${qs}` : ""}`);
|
||||
},
|
||||
stop: (code: string) => request<StopDetail>(`/stops/${encodeURIComponent(code)}`),
|
||||
schedules: (params: { route_id?: string; stop_id?: number; stop_code?: string }) => {
|
||||
const q = new URLSearchParams();
|
||||
if (params.route_id) q.set("route_id", params.route_id);
|
||||
if (params.stop_id != null) q.set("stop_id", String(params.stop_id));
|
||||
if (params.stop_code) q.set("stop_code", params.stop_code);
|
||||
return request<{ items: Schedule[] }>(`/schedules?${q.toString()}`);
|
||||
},
|
||||
recordVisit: (body: { page_path: string; visitor_id: string }) =>
|
||||
request<{ counted: boolean; unique_today: boolean }>("/visits", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(body),
|
||||
}),
|
||||
visitsSummary: () =>
|
||||
request<{
|
||||
total_all_time: number;
|
||||
total_today: number;
|
||||
unique_today: number;
|
||||
top_pages: { page_path: string; total_visits: number; unique_visitors: number }[];
|
||||
}>("/visits/summary"),
|
||||
images: (params: { entity_type?: string; entity_id?: string } = {}) => {
|
||||
const q = new URLSearchParams();
|
||||
if (params.entity_type) q.set("entity_type", params.entity_type);
|
||||
if (params.entity_id) q.set("entity_id", params.entity_id);
|
||||
const qs = q.toString();
|
||||
return request<{ items: (ImageRef & { entity_type: string; entity_id: string })[] }>(
|
||||
`/images${qs ? `?${qs}` : ""}`,
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
export type Province = { id: number; name_th: string };
|
||||
export type RouteGroup = {
|
||||
id: number;
|
||||
code: string;
|
||||
label_th: string;
|
||||
display_order: number;
|
||||
is_active: boolean;
|
||||
};
|
||||
export type ImageRef = {
|
||||
id: string;
|
||||
kind: string;
|
||||
url_path: string;
|
||||
display_order: number;
|
||||
meta: Record<string, unknown>;
|
||||
};
|
||||
export type RouteListItem = {
|
||||
route_id: string;
|
||||
name_th: string;
|
||||
vehicle_type: string;
|
||||
route_group_id: number;
|
||||
route_group_code: string;
|
||||
route_group_label_th: string;
|
||||
contact: Record<string, unknown>;
|
||||
metadata: Record<string, unknown>;
|
||||
province_ids: number[];
|
||||
images: ImageRef[];
|
||||
};
|
||||
export type RouteDetail = RouteListItem;
|
||||
export type RouteStop = {
|
||||
stop_sequence: number;
|
||||
station_id: number;
|
||||
code: string;
|
||||
name_th: string;
|
||||
city_th: string | null;
|
||||
province_th: string | null;
|
||||
station_type: string;
|
||||
attributes: Record<string, unknown>;
|
||||
};
|
||||
export type StopListItem = {
|
||||
id: number;
|
||||
code: string;
|
||||
name_th: string;
|
||||
city_th: string | null;
|
||||
province_th: string | null;
|
||||
station_type: string;
|
||||
attributes: Record<string, unknown>;
|
||||
images: ImageRef[];
|
||||
lng: number | null;
|
||||
lat: number | null;
|
||||
};
|
||||
export type StopDetail = StopListItem & {
|
||||
metadata: Record<string, unknown>;
|
||||
routes: {
|
||||
route_id: string;
|
||||
name_th: string;
|
||||
vehicle_type: string;
|
||||
route_group_code: string;
|
||||
route_group_label_th: string;
|
||||
}[];
|
||||
};
|
||||
export type Schedule = {
|
||||
id: number;
|
||||
route_id: string;
|
||||
station_id: number;
|
||||
station_code: string;
|
||||
station_name_th: string;
|
||||
direction_note: string | null;
|
||||
departure_times: string[];
|
||||
variants: Record<string, unknown>;
|
||||
schedule_note: string | null;
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
"use client";
|
||||
import { useEffect } from "react";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { api } from "./api";
|
||||
|
||||
const KEY = "tx_visitor_id";
|
||||
|
||||
export function VisitTracker({ path }: { path: string }) {
|
||||
useEffect(() => {
|
||||
let vid = typeof window !== "undefined" ? localStorage.getItem(KEY) : null;
|
||||
if (!vid) {
|
||||
vid = uuidv4();
|
||||
try { localStorage.setItem(KEY, vid); } catch {}
|
||||
}
|
||||
api.recordVisit({ page_path: path, visitor_id: vid }).catch(() => {});
|
||||
}, [path]);
|
||||
return null;
|
||||
}
|
||||
Reference in new issue
Block a user