Declutter navbar: one button per tool (theme, language)

The topbar carried five small buttons in a row (3 theme + 2 language).
Replaced with two single buttons that open their own popover menu:

- ThemeSwitch: single icon button showing the active mode, menu with
  light/dark/auto as menuitemradio
- LangSwitch: new component showing the active code (ไทย / EN), menu
  keeps the existing [data-i18n-switch] mechanism from i18n.ts
- .mu-topbar-tools wrapper, 8px gap (WCAG 2.5.8), 40px buttons / 44px on touch
- popovers close on select, outside click and Escape (focus returns to button)

Also fixed two bugs found on /stops:
- .mu-btn.outline had no CSS rule, so the browser painted a light grey
  background that ignored the dark theme
- deleted the unused StopSearch component which still carried the old
  number pad and its delete key, plus the now-unused stops.padDelete key

Verified at 375px: no horizontal overflow, buttons 40x40 and 59x40,
8px gap; menus open/close correctly in both themes.
This commit is contained in:
Bkk1234 committed 2026-10-23 23:37:44 +07:00
1 parent bf42076b52
commit cb4905a12d
11 files changed
+338 -283

No files matched your search

+117 -72
View File
@@ -417,79 +417,7 @@ body:has(.mu-site-footer) .mu-footer { display: none; }
padding: 3px;
flex-shrink: 0;
}
.mu-lang-btn {
border: 0;
background: transparent;
color: var(--c-brand-ink);
font-family: inherit;
font-weight: 700;
font-size: .72rem;
line-height: 1;
padding: 6px 10px;
border-radius: var(--radius-pill);
cursor: pointer;
transition: background .15s ease, color .15s ease;
}
.mu-lang-btn:hover { color: var(--c-brand-ink); }
.mu-lang-btn.active {
background: var(--c-surface);
color: var(--c-brand-ink);
box-shadow: 0 1px 4px rgba(63, 43, 94, .18);
}
/* ---------- ตัวสลับธีม (สว่าง / มืด / ตามเวลา) ---------- */
.mu-theme-switch {
display: inline-flex;
align-items: center;
gap: 2px;
background: var(--c-tint-purple);
border: 1px solid #e4dcf2;
border-radius: var(--radius-pill);
padding: 3px;
flex-shrink: 0;
}
.mu-theme-btn {
display: inline-flex;
align-items: center;
justify-content: center;
width: 34px;
height: 34px;
min-width: 34px;
border: 0;
border-radius: var(--radius-pill);
background: transparent;
color: var(--c-brand-ink);
cursor: pointer;
transition: background .15s ease, color .15s ease;
}
.mu-theme-btn:hover { color: var(--c-brand-ink); }
.mu-theme-btn.active {
background: var(--c-surface);
color: var(--c-brand-ink);
box-shadow: 0 1px 4px rgba(63, 43, 94, .18);
}
/* โฟกัสคีย์บอร์ดต้องเห็นชัด (WCAG 2.4.7) */
.mu-theme-btn:focus-visible,
.mu-lang-btn:focus-visible {
outline: 2px solid var(--c-focus);
outline-offset: 2px;
}
:root[data-theme="dark"] .mu-theme-switch,
:root[data-theme="dark"] .mu-lang-switch {
background: var(--c-surface-3);
border-color: var(--c-border);
}
:root[data-theme="dark"] .mu-theme-btn,
:root[data-theme="dark"] .mu-lang-btn { color: var(--c-ink-2); }
:root[data-theme="dark"] .mu-theme-btn:hover,
:root[data-theme="dark"] .mu-lang-btn:hover { color: var(--c-ink); }
:root[data-theme="dark"] .mu-lang-btn { background: transparent; }
/* จอสัมผัส: ขยายเป้ากดให้ถึง 44px (WCAG 2.5.5) */
@media (pointer: coarse) {
.mu-theme-btn { width: 40px; height: 40px; min-width: 40px; }
.mu-theme-switch { padding: 2px; }
}
/* ============================================================
ปุ่ม + ฟอร์มคอนโทรล (shared — ทุกหน้าใช้ร่วมกัน)
@@ -548,6 +476,18 @@ body:has(.mu-site-footer) .mu-footer { display: none; }
outline-offset: 2px;
}
/* ปุ่มขอบ (outline) — ตัวอักษร/ขอบม่วง พื้นโปร่งใส
เดิมไม่มีกฎนี้ → เบราว์เซอร์ใส่พื้นเทาอ่อนเอง ทำให้โหมดมืดหลุดธีม */
.mu-btn.outline {
background: transparent;
border-color: var(--c-brand-ink);
color: var(--c-brand-ink);
}
.mu-btn.outline:hover {
background: var(--c-tint-purple);
border-color: var(--c-brand-ink);
}
/* ---------- ปุ่มติดตั้งแอป (PWA — inject จาก pwa.js) ---------- */
.mu-install-btn {
position: fixed;
@@ -665,3 +605,108 @@ body:has(.mu-site-footer) .mu-footer { display: none; }
@media (pointer: coarse) {
.mu-share-btn { min-height: 48px; }
}
/* ============================================================
ปุ่มเครื่องมือในแถบนำทาง — ปุ่มละเรื่อง (ไม่ใช่กลุ่มปุ่มเรียง)
เดิม: ธีม 3 ปุ่ม + ภาษา 2 ปุ่ม = 5 ปุ่มในแถวเดียว → navbar แน่น
ตอนนี้: ธีม 1 ปุ่ม · ภาษา 1 ปุ่ม แต่ละปุ่มกดแล้วเปิดเมนูของตัวเอง
ตรงสเกลเดียวกับ .mu-btn (radius 8px · min-height 44px บนจอสัมผัส)
============================================================ */
.mu-topbar-tools {
display: flex;
align-items: center;
gap: 8px; /* WCAG 2.5.8 — เว้นระหว่างเป้ากด ≥ 8px */
flex-shrink: 0;
}
.mu-pop { position: relative; display: inline-flex; }
.mu-pop-btn {
display: inline-flex;
align-items: center;
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;
line-height: 1;
cursor: pointer;
transition: border-color .15s ease, background .15s 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-pop-btn[aria-expanded="true"] {
border-color: var(--c-brand-ink);
background: var(--c-surface-2);
}
/* เมนูที่กางออก */
.mu-pop-panel {
position: absolute;
top: calc(100% + 6px);
right: 0;
z-index: 1200; /* เหนือ topbar (1100) แต่ใต้ visitor dialog (3000) */
min-width: 168px;
padding: 6px;
border: 1px solid var(--c-border);
border-radius: var(--radius);
background: var(--c-surface);
box-shadow: 0 10px 24px var(--c-shadow);
}
.mu-pop-item {
display: flex;
align-items: center;
gap: 8px;
width: 100%;
min-height: 40px;
padding: 8px 10px;
border: 0;
border-radius: var(--radius-sm);
background: transparent;
color: var(--c-ink);
font-family: inherit;
font-size: .85rem;
font-weight: 600;
text-align: start;
cursor: pointer;
}
.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); }
/* จอสัมผัส: เป้ากด 44px */
@media (pointer: coarse) {
.mu-pop-btn { min-width: 44px; height: 44px; }
.mu-pop-btn-lang { min-width: 60px; }
.mu-pop-item { min-height: 44px; }
}