fix: mobile nav FOUC + Pantry scan toggle responsive layout

- index.html: inline anti-FOUC CSS so sidebar stays hidden on mobile
  before the JS bundle hydrates (eliminates ~100ms flash of sidebar)
- InventoryList: scan-mode-toggle fills card width on <=480px so buttons
  don't overflow; mode button labels hidden on <=360px (icons only)
- Very narrow phones get icon-only mode toggle, all three buttons still
  accessible via aria-label
This commit is contained in:
pyr0ball 2026-04-03 11:10:39 -07:00
parent 32ec9d8a41
commit 6ff5a5709e
2 changed files with 42 additions and 6 deletions

View file

@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
<title>Kiwi — Pantry Tracker</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
@ -11,6 +11,18 @@
href="https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300..900;1,9..144,300..900&family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=DM+Sans:ital,opsz,wght@0,9..40,300..700;1,9..40,300..700&display=swap"
rel="stylesheet"
/>
<!-- Anti-FOUC: critical layout CSS inline so it's available before the JS bundle.
Without this, the sidebar flashes visible on mobile for ~100ms while the
bundle hydrates and injects component styles. -->
<style>
.sidebar { display: none; }
.bottom-nav { display: flex; }
@media (min-width: 769px) {
.sidebar { display: flex; flex-direction: column; }
.bottom-nav { display: none; }
.app-body { display: flex; flex-direction: column; flex: 1; }
}
</style>
</head>
<body>
<div id="app"></div>

View file

@ -507,10 +507,12 @@ const manualLoading = ref(false)
onMounted(async () => {
await store.fetchItems()
await store.fetchStats()
// Auto-focus scanner gun input
setTimeout(() => {
scannerGunInput.value?.focus()
}, 100)
// Auto-focus scanner gun input desktop only (avoids popping mobile keyboard)
if (!('ontouchstart' in window)) {
setTimeout(() => {
scannerGunInput.value?.focus()
}, 100)
}
})
function onFilterChange() {
@ -762,7 +764,7 @@ function getItemClass(item: InventoryItem): string {
display: flex;
flex-direction: column;
gap: var(--spacing-md);
padding: var(--spacing-xs) 0 var(--spacing-xl);
padding: var(--spacing-xs) 0 0;
}
/* ============================================
@ -1231,6 +1233,16 @@ function getItemClass(item: InventoryItem): string {
gap: var(--spacing-sm);
}
/* Mode toggle fills the card width when header stacks */
.scan-mode-toggle {
width: 100%;
}
.scan-mode-btn {
flex: 1;
justify-content: center;
}
.scan-meta-row {
flex-direction: column;
}
@ -1259,6 +1271,18 @@ function getItemClass(item: InventoryItem): string {
}
}
/* Very narrow phones (360px and below): hide mode button labels, keep icons */
@media (max-width: 360px) {
.scan-mode-btn span {
display: none;
}
.scan-mode-btn svg {
width: 16px;
height: 16px;
}
}
@media (min-width: 481px) and (max-width: 768px) {
.scan-meta-row {
flex-wrap: nowrap;