From eabcff197c7c43700987d3a3af58c260b5b555eb Mon Sep 17 00:00:00 2001 From: Bkk1234 Date: Wed, 4 Nov 2026 01:37:50 +0700 Subject: [PATCH] navbar: rebuild mock header from the Next implementation (source of truth) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - markup: lang + theme moved into .mu-topbar-tools (theme first, then lang), same order as web-at-transit: brand, nav, menu, tools, CTA - CSS: replaced mock's .mu-lang-*/.mu-theme-* buttons with the Next rules (.mu-pop / .mu-pop-btn / .mu-pop-btn-lang / .mu-pop-panel / .mu-pop-item, 40px tall, radius 8px, surface bg, 44px on coarse pointers) - lang button keeps short label + 12px chevron; menu items use .mu-pop-item-th/.mu-pop-item-en and data-active for the selected row - nav 0.95rem (was .92rem), header border -> var(--c-border) - theme.js was never included in the shell (regex missed the versioned src) — added after i18n.js + precached with theme.css; that was why the theme menu did not open in the previous build - VERSION 2026.09.27.120 --- ui/_shared.css | 113 ++++++++++++++++++++++++++++------------------ ui/i18n.js | 1 + ui/index.html | 111 +++++++++++++++++++++++---------------------- ui/responsive.css | 4 +- ui/sw.js | 4 +- ui/theme.js | 1 + ui/version.json | 2 +- 7 files changed, 134 insertions(+), 102 deletions(-) diff --git a/ui/_shared.css b/ui/_shared.css index 5aff477..4870271 100644 --- a/ui/_shared.css +++ b/ui/_shared.css @@ -406,85 +406,108 @@ body:has(.mu-site-footer) .mu-footer { display: none; } padding: 10px 12px 10px 38px; } -/* ---------- ปุ่มสลับภาษา (dropdown เดียว — ไทย / English) ---------- */ -.mu-lang-switch { - position: relative; - display: inline-flex; +/* ============================================================ + ปุ่มเครื่องมือในแถบนำทาง — พอร์ตจาก web-at-transit (ต้นทางความจริง) + ธีม 1 ปุ่ม · ภาษา 1 ปุ่ม · แต่ละปุ่มมีเมนูของตัวเอง + radius 8px · สูง 40px (44px บนจอสัมผัส) + ============================================================ */ +.mu-topbar-tools { + display: flex; align-items: center; + gap: 8px; /* WCAG 2.5.8 — เว้นระหว่างเป้ากด ≥ 8px */ flex-shrink: 0; } -.mu-lang-btn { + +.mu-pop { position: relative; display: inline-flex; } + +.mu-pop-btn { display: inline-flex; align-items: center; - gap: 6px; - min-height: 34px; - padding: 6px 12px; - border: 1px solid #e4dcf2; - border-radius: 999px; - background: var(--c-surface-3); + justify-content: center; + gap: 4px; + min-width: 40px; + height: 40px; + padding: 0 8px; + border: 1px solid var(--c-border); + border-radius: var(--radius); + background: var(--c-surface); color: var(--c-brand-ink); font-family: inherit; + font-size: .78rem; font-weight: 700; - font-size: .76rem; line-height: 1; cursor: pointer; - transition: background .15s ease, color .15s ease, border-color .15s ease; + transition: border-color .15s ease, background .15s ease; } -.mu-lang-btn:hover { color: var(--c-brand-ink); border-color: var(--c-border); } -.mu-lang-btn[aria-expanded="true"] { background: var(--c-surface); border-color: #cbb8ea; } -.mu-lang-btn .ic { width: 15px; height: 15px; } -.mu-lang-caret { - width: 0 !important; - height: 0 !important; - margin-left: 1px; - border: 4px solid transparent; - border-top-color: currentColor; - transition: transform .18s ease; +.mu-pop-btn-lang { min-width: 56px; padding: 0 10px; } +.mu-pop-btn:hover { border-color: #d8c9f2; background: var(--c-surface-2); } +.mu-pop-btn:active { transform: translateY(1px); } +.mu-pop-btn:focus-visible { + outline: 2px solid var(--c-focus); + outline-offset: 2px; } -.mu-lang-btn[aria-expanded="true"] .mu-lang-caret { transform: rotate(180deg); } -.mu-lang-menu { +.mu-pop-btn[aria-expanded="true"] { + border-color: var(--c-brand-ink); + background: var(--c-surface-2); +} +.mu-pop-btn .ic { width: 18px; height: 18px; } + +/* เมนูที่กางออก */ +.mu-pop-panel { position: absolute; top: calc(100% + 6px); right: 0; z-index: 1200; min-width: 168px; padding: 6px; - background: var(--c-surface); border: 1px solid var(--c-border); - border-radius: 12px; - box-shadow: 0 10px 28px rgba(15, 23, 42, .14); + border-radius: var(--radius); + background: var(--c-surface); + box-shadow: 0 10px 24px var(--c-shadow); } -.mu-lang-menu[hidden] { display: none; } -.mu-lang-menu button { +.mu-pop-panel[hidden] { display: none; } + +.mu-pop-item { display: flex; align-items: center; gap: 8px; width: 100%; - min-height: 38px; + min-height: 40px; padding: 8px 10px; border: 0; - border-radius: 8px; + border-radius: var(--radius-sm); background: transparent; color: var(--c-ink); font-family: inherit; - font-size: .84rem; + font-size: .85rem; font-weight: 600; - text-align: left; + text-align: start; cursor: pointer; } -.mu-lang-menu button:hover { background: #f6f2ff; } -.mu-lang-menu button[aria-checked="true"] { color: var(--c-brand-ink); font-weight: 800; background: var(--c-brand-soft); } -.mu-lang-menu button .mu-lang-code { - margin-left: auto; - font-family: ui-monospace, "IBM Plex Mono", monospace; - font-size: .72rem; - color: var(--c-ink-3); +.mu-pop-item:hover { background: var(--c-surface-2); } +.mu-pop-item:focus-visible { + outline: 2px solid var(--c-focus); + outline-offset: -2px; } +.mu-pop-item[data-active="1"] { + background: var(--c-tint-purple); + color: var(--c-brand-ink); + font-weight: 700; +} +.mu-pop-item-th { flex: 1 1 auto; } +.mu-pop-item-en { + flex: 0 0 auto; + font-size: .72rem; + font-weight: 600; + color: var(--c-ink-2); + letter-spacing: .04em; +} +.mu-pop-item[data-active="1"] .mu-pop-item-en { color: var(--c-brand-ink); } -/* ---------- ปุ่มธีม (dropdown 3 โหมด — สว่าง / มืด / ตามอุปกรณ์) ---------- */ -.mu-theme-btn { padding: 6px 9px; } -.mu-theme-icon { display: inline-flex; } -.mu-theme-icon svg { width: 16px; height: 16px; } +@media (pointer: coarse) { + .mu-pop-btn { min-width: 44px; height: 44px; } + .mu-pop-btn-lang { min-width: 60px; } +} /* ============================================================ ปุ่ม + ฟอร์มคอนโทรล (shared — ทุกหน้าใช้ร่วมกัน) diff --git a/ui/i18n.js b/ui/i18n.js index ebb3125..bd97437 100644 --- a/ui/i18n.js +++ b/ui/i18n.js @@ -100,6 +100,7 @@ var on = btn.getAttribute('data-i18n-switch') === current; btn.classList.toggle('active', on); btn.setAttribute('aria-checked', on ? 'true' : 'false'); + if (on) btn.setAttribute('data-active', '1'); else btn.removeAttribute('data-active'); }); var label = document.getElementById('lang-label'); if (label) label.textContent = current === 'en' ? 'EN' : 'ไทย'; diff --git a/ui/index.html b/ui/index.html index d0576ab..6ec7df7 100644 --- a/ui/index.html +++ b/ui/index.html @@ -19,16 +19,16 @@ หน้าแรก | Atroute (mockup) - + - - - - - - + + + + + +