fix: improve mobile terminal region tabs
This commit is contained in:
@@ -15,7 +15,7 @@ export function MobileRegionTabs({
|
||||
onSelectTab: (key: string) => void;
|
||||
}) {
|
||||
return (
|
||||
<div className="mobile-region-tabs flex overflow-x-auto border-b border-slate-200 bg-white px-2">
|
||||
<div className="mobile-region-tabs flex min-h-11 snap-x gap-1 overflow-x-auto border-b border-slate-200 bg-white px-2 [-webkit-overflow-scrolling:touch] [scrollbar-width:none]">
|
||||
{groups.map((g) => {
|
||||
const label = isEn ? g.labelEn : g.labelZh;
|
||||
const isActive = activeTab === g.key;
|
||||
@@ -23,9 +23,10 @@ export function MobileRegionTabs({
|
||||
<button
|
||||
key={g.key}
|
||||
type="button"
|
||||
aria-pressed={isActive}
|
||||
onClick={() => onSelectTab(g.key)}
|
||||
className={clsx(
|
||||
"shrink-0 px-3 py-2.5 text-xs font-bold whitespace-nowrap border-b-2 transition-colors",
|
||||
"flex min-h-11 shrink-0 snap-start items-center border-b-2 px-3 text-xs font-bold whitespace-nowrap transition-colors",
|
||||
isActive
|
||||
? "border-blue-600 text-blue-700"
|
||||
: "border-transparent text-slate-500 hover:text-slate-700"
|
||||
|
||||
@@ -36,6 +36,10 @@ export function runTests() {
|
||||
path.join(projectRoot, "components", "dashboard", "scan-terminal", "use-scan-terminal-query.ts"),
|
||||
"utf8",
|
||||
);
|
||||
const mobileRegionTabsSource = fs.readFileSync(
|
||||
path.join(projectRoot, "components", "dashboard", "scan-terminal", "MobileRegionTabs.tsx"),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
assert(
|
||||
dashboardSource.includes("MAX_TERMINAL_CHARTS = 9"),
|
||||
@@ -57,6 +61,16 @@ export function runTests() {
|
||||
dashboardSource.includes("disableClose={true}"),
|
||||
"mobile terminal should render one selected chart and suggest landscape for the full grid",
|
||||
);
|
||||
assert(
|
||||
dashboardSource.includes("mobile-region-tabs-shell") &&
|
||||
dashboardSource.includes("handleMobileSelectTab") &&
|
||||
dashboardSource.includes("mobileSelectedRowInActiveGroup") &&
|
||||
dashboardSource.includes("mobileActiveGroup?.rows[0]") &&
|
||||
mobileRegionTabsSource.includes("min-h-11") &&
|
||||
mobileRegionTabsSource.includes("snap-x") &&
|
||||
mobileRegionTabsSource.includes("aria-pressed={isActive}"),
|
||||
"mobile region navigation must stay visible above the landscape hint, remain touch-friendly, and switch the visible chart with the active region",
|
||||
);
|
||||
assert(
|
||||
!dashboardSource.includes("disableClose={visibleSlots.filter(Boolean).length <= 1}"),
|
||||
"desktop chart slots must allow clearing the last visible city so users can close a 1x1 chart",
|
||||
|
||||
Reference in New Issue
Block a user