Commit c55e7092 authored by Aryan Noshirvnai's avatar Aryan Noshirvnai

Make the webapp mobile-friendly

- index.html: viewport-fit=cover (enables safe-area-inset-* for notches/
  home indicators), theme-color, mobile/apple-web-app-capable meta tags
- Layout: fixed bottom tab bar on mobile (sm:hidden) with icons, thumb-
  reachable instead of the old horizontal top nav, which stays for sm+
  screens instead; main content gets pb-24 on mobile so it doesn't sit
  under the fixed tab bar
- RoomView (full-screen, doesn't use Layout so needed its own handling):
  h-dvh instead of min-h-screen so the chat input actually stays pinned to
  the visible viewport bottom with the keyboard open; safe-area padding on
  header/input bar
- All interactive buttons/inputs bumped to a real ~44px touch target
  (Discovery's swipe buttons and Channels' follow button were the worst
  offenders, py-1/py-1.5 only)
- Text inputs explicitly text-base (16px): anything smaller triggers iOS
  Safari's auto-zoom-on-focus, which is jarring

Typechecks clean, production build succeeds. Couldn't visually verify in a
real browser this session (no browser tooling available) - worth an actual
phone check.
Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
parent dccf71fe
...@@ -3,8 +3,12 @@ ...@@ -3,8 +3,12 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" /> <link rel="icon" type="image/svg+xml" href="/favicon.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>stax_webapp</title> <meta name="theme-color" content="#0a0a0a" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<title>Stax</title>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
......
...@@ -3,12 +3,12 @@ import { Link, useLocation } from 'react-router-dom' ...@@ -3,12 +3,12 @@ import { Link, useLocation } from 'react-router-dom'
import { useAuth } from '../context/AuthContext' import { useAuth } from '../context/AuthContext'
const NAV_ITEMS = [ const NAV_ITEMS = [
{ to: '/library', label: 'Library' }, { to: '/library', label: 'Library', icon: '🎵' },
{ to: '/upload', label: 'Upload' }, { to: '/upload', label: 'Upload', icon: '⬆️' },
{ to: '/discovery', label: 'Discovery' }, { to: '/discovery', label: 'Discover', icon: '🔍' },
{ to: '/rooms', label: 'Rooms' }, { to: '/rooms', label: 'Rooms', icon: '🎧' },
{ to: '/channels', label: 'Channels' }, { to: '/channels', label: 'Channels', icon: '📡' },
{ to: '/remix', label: 'Remix' }, { to: '/remix', label: 'Remix', icon: '🎛️' },
] ]
export function Layout({ title, children }: { title: string; children: ReactNode }) { export function Layout({ title, children }: { title: string; children: ReactNode }) {
...@@ -24,16 +24,24 @@ export function Layout({ title, children }: { title: string; children: ReactNode ...@@ -24,16 +24,24 @@ export function Layout({ title, children }: { title: string; children: ReactNode
return ( return (
<div className="min-h-screen bg-neutral-950 text-white"> <div className="min-h-screen bg-neutral-950 text-white">
<header className="border-b border-neutral-800 px-6 py-4"> {/* Top bar: branding + logout everywhere; the nav links move down here only on
<div className="mb-3 flex items-center justify-between"> screens wide enough to show all six comfortably without scrolling. */}
<header
className="sticky top-0 z-10 border-b border-neutral-800 bg-neutral-950/95 px-4 backdrop-blur sm:px-6"
style={{ paddingTop: 'env(safe-area-inset-top)' }}
>
<div className="flex h-14 items-center justify-between">
<Link to="/library" className="text-lg font-semibold"> <Link to="/library" className="text-lg font-semibold">
🎧 Stax 🎧 Stax
</Link> </Link>
<button onClick={handleLogout} className="text-sm text-neutral-400 hover:text-white"> <button
onClick={handleLogout}
className="min-h-[44px] px-2 text-sm text-neutral-400 hover:text-white"
>
Log out Log out
</button> </button>
</div> </div>
<nav className="flex gap-4 overflow-x-auto text-sm"> <nav className="hidden gap-4 pb-3 text-sm sm:flex">
{NAV_ITEMS.map((item) => ( {NAV_ITEMS.map((item) => (
<Link <Link
key={item.to} key={item.to}
...@@ -49,10 +57,31 @@ export function Layout({ title, children }: { title: string; children: ReactNode ...@@ -49,10 +57,31 @@ export function Layout({ title, children }: { title: string; children: ReactNode
))} ))}
</nav> </nav>
</header> </header>
<main className="mx-auto max-w-2xl px-6 py-8">
<main className="mx-auto max-w-2xl px-4 py-6 pb-24 sm:px-6 sm:py-8 sm:pb-8">
<h1 className="mb-6 text-xl font-semibold">{title}</h1> <h1 className="mb-6 text-xl font-semibold">{title}</h1>
{children} {children}
</main> </main>
{/* Bottom tab bar: mobile only, fixed, thumb-reachable. Hidden entirely at sm+ where
the top nav takes over instead. */}
<nav
className="fixed inset-x-0 bottom-0 z-10 flex border-t border-neutral-800 bg-neutral-950/95 backdrop-blur sm:hidden"
style={{ paddingBottom: 'env(safe-area-inset-bottom)' }}
>
{NAV_ITEMS.map((item) => (
<Link
key={item.to}
to={item.to}
className={`flex min-h-[56px] flex-1 flex-col items-center justify-center gap-0.5 text-[11px] ${
location.pathname === item.to ? 'text-emerald-400' : 'text-neutral-500'
}`}
>
<span className="text-lg leading-none">{item.icon}</span>
{item.label}
</Link>
))}
</nav>
</div> </div>
) )
} }
...@@ -10,6 +10,7 @@ export function RoomView({ roomId, onLeave }: { roomId: number; onLeave: () => v ...@@ -10,6 +10,7 @@ export function RoomView({ roomId, onLeave }: { roomId: number; onLeave: () => v
const [djQueue, setDjQueue] = useState<number[]>([]) const [djQueue, setDjQueue] = useState<number[]>([])
const [text, setText] = useState('') const [text, setText] = useState('')
const wsRef = useRef<WebSocket | null>(null) const wsRef = useRef<WebSocket | null>(null)
const messagesEndRef = useRef<HTMLDivElement | null>(null)
useEffect(() => { useEffect(() => {
if (userId === null) return if (userId === null) return
...@@ -40,6 +41,10 @@ export function RoomView({ roomId, onLeave }: { roomId: number; onLeave: () => v ...@@ -40,6 +41,10 @@ export function RoomView({ roomId, onLeave }: { roomId: number; onLeave: () => v
return () => ws.close() return () => ws.close()
}, [roomId, userId]) }, [roomId, userId])
useEffect(() => {
messagesEndRef.current?.scrollIntoView({ block: 'end' })
}, [messages])
function handleSend(e: React.FormEvent) { function handleSend(e: React.FormEvent) {
e.preventDefault() e.preventDefault()
if (!text.trim() || !wsRef.current) return if (!text.trim() || !wsRef.current) return
...@@ -48,17 +53,23 @@ export function RoomView({ roomId, onLeave }: { roomId: number; onLeave: () => v ...@@ -48,17 +53,23 @@ export function RoomView({ roomId, onLeave }: { roomId: number; onLeave: () => v
} }
return ( return (
<div className="flex min-h-screen flex-col bg-neutral-950 text-white"> // h-dvh (dynamic viewport height), not min-h-screen: on mobile, min-h-screen can end up
<header className="flex items-center justify-between border-b border-neutral-800 px-6 py-4"> // taller than what's actually visible once browser chrome/the keyboard are accounted
<button onClick={onLeave} className="text-sm text-neutral-400 hover:text-white"> // for, which breaks the "input pinned to the bottom of the screen" layout this needs.
← Leave room <div className="flex h-dvh flex-col bg-neutral-950 text-white">
<header
className="flex shrink-0 items-center justify-between border-b border-neutral-800 px-4 py-3"
style={{ paddingTop: 'calc(env(safe-area-inset-top) + 0.75rem)' }}
>
<button onClick={onLeave} className="min-h-[44px] px-1 text-sm text-neutral-400 hover:text-white">
← Leave
</button> </button>
<div className="text-sm text-neutral-400"> <div className="text-sm text-neutral-400">
DJ #{djId} {fireCount > 0 && <span className="ml-2">🔥 {fireCount}</span>} DJ #{djId} {fireCount > 0 && <span className="ml-2">🔥 {fireCount}</span>}
</div> </div>
</header> </header>
<div className="flex-1 overflow-y-auto px-6 py-4"> <div className="flex-1 overflow-y-auto px-4 py-4">
<ul className="space-y-2"> <ul className="space-y-2">
{messages.map((m, i) => ( {messages.map((m, i) => (
<li key={i} className="text-sm"> <li key={i} className="text-sm">
...@@ -66,20 +77,24 @@ export function RoomView({ roomId, onLeave }: { roomId: number; onLeave: () => v ...@@ -66,20 +77,24 @@ export function RoomView({ roomId, onLeave }: { roomId: number; onLeave: () => v
</li> </li>
))} ))}
</ul> </ul>
<div ref={messagesEndRef} />
</div> </div>
<div className="border-t border-neutral-800 px-6 py-4"> <div
className="shrink-0 border-t border-neutral-800 px-4 pt-3"
style={{ paddingBottom: 'calc(env(safe-area-inset-bottom) + 0.75rem)' }}
>
<div className="mb-3 flex gap-2"> <div className="mb-3 flex gap-2">
<button <button
onClick={() => wsRef.current && sendReaction(wsRef.current)} onClick={() => wsRef.current && sendReaction(wsRef.current)}
className="rounded-full bg-neutral-800 px-3 py-1.5 text-sm hover:bg-neutral-700" className="min-h-[40px] rounded-full bg-neutral-800 px-3 text-sm hover:bg-neutral-700"
> >
🔥 React 🔥 React
</button> </button>
{djId !== userId && ( {djId !== userId && (
<button <button
onClick={() => wsRef.current && requestAux(wsRef.current)} onClick={() => wsRef.current && requestAux(wsRef.current)}
className="rounded-full bg-neutral-800 px-3 py-1.5 text-sm hover:bg-neutral-700" className="min-h-[40px] rounded-full bg-neutral-800 px-3 text-sm hover:bg-neutral-700"
> >
🙋 Request aux {djQueue.includes(userId ?? -1) ? '(queued)' : ''} 🙋 Request aux {djQueue.includes(userId ?? -1) ? '(queued)' : ''}
</button> </button>
...@@ -90,9 +105,11 @@ export function RoomView({ roomId, onLeave }: { roomId: number; onLeave: () => v ...@@ -90,9 +105,11 @@ export function RoomView({ roomId, onLeave }: { roomId: number; onLeave: () => v
value={text} value={text}
onChange={(e) => setText(e.target.value)} onChange={(e) => setText(e.target.value)}
placeholder="Say something…" placeholder="Say something…"
className="flex-1 rounded-lg border border-neutral-700 bg-neutral-800 px-3 py-2 text-white placeholder-neutral-500 outline-none focus:border-emerald-500" // text-base (16px), not the browser default/text-sm: anything smaller makes iOS
// Safari auto-zoom the whole page in on focus, which is jarring in a chat input.
className="min-h-[44px] flex-1 rounded-lg border border-neutral-700 bg-neutral-800 px-3 text-base text-white placeholder-neutral-500 outline-none focus:border-emerald-500"
/> />
<button className="rounded-lg bg-emerald-500 px-4 py-2 font-medium text-neutral-950 hover:bg-emerald-400"> <button className="min-h-[44px] rounded-lg bg-emerald-500 px-4 font-medium text-neutral-950 hover:bg-emerald-400">
Send Send
</button> </button>
</form> </form>
......
...@@ -55,9 +55,9 @@ export function Channels() { ...@@ -55,9 +55,9 @@ export function Channels() {
value={newName} value={newName}
onChange={(e) => setNewName(e.target.value)} onChange={(e) => setNewName(e.target.value)}
placeholder="New channel name" placeholder="New channel name"
className="flex-1 rounded-lg border border-neutral-700 bg-neutral-800 px-3 py-2 text-white placeholder-neutral-500 outline-none focus:border-emerald-500" className="min-h-[44px] flex-1 rounded-lg border border-neutral-700 bg-neutral-800 px-3 text-base text-white placeholder-neutral-500 outline-none focus:border-emerald-500"
/> />
<button className="rounded-lg bg-emerald-500 px-4 py-2 font-medium text-neutral-950 hover:bg-emerald-400"> <button className="min-h-[44px] rounded-lg bg-emerald-500 px-4 font-medium text-neutral-950 hover:bg-emerald-400">
Create Create
</button> </button>
</form> </form>
...@@ -66,10 +66,10 @@ export function Channels() { ...@@ -66,10 +66,10 @@ export function Channels() {
{channels.map((channel) => ( {channels.map((channel) => (
<li <li
key={channel.id} key={channel.id}
className="flex items-center justify-between rounded-lg border border-neutral-800 bg-neutral-900 px-4 py-3" className="flex min-h-[44px] items-center justify-between gap-3 rounded-lg border border-neutral-800 bg-neutral-900 px-4 py-3"
> >
<div> <div className="min-w-0">
<p className="font-medium text-white">{channel.name}</p> <p className="truncate font-medium text-white">{channel.name}</p>
<p className="text-xs text-neutral-500"> <p className="text-xs text-neutral-500">
{followerCounts[channel.id] ?? 0} followers · owner #{channel.owner_id} {followerCounts[channel.id] ?? 0} followers · owner #{channel.owner_id}
</p> </p>
...@@ -77,7 +77,7 @@ export function Channels() { ...@@ -77,7 +77,7 @@ export function Channels() {
{channel.owner_id !== userId && ( {channel.owner_id !== userId && (
<button <button
onClick={() => toggleFollow(channel.id)} onClick={() => toggleFollow(channel.id)}
className="rounded-full bg-neutral-800 px-4 py-1.5 text-sm text-white hover:bg-neutral-700" className="min-h-[40px] shrink-0 rounded-full bg-neutral-800 px-4 text-sm text-white hover:bg-neutral-700"
> >
{followedIds.has(channel.id) ? 'Unfollow' : 'Follow'} {followedIds.has(channel.id) ? 'Unfollow' : 'Follow'}
</button> </button>
......
...@@ -67,13 +67,13 @@ export function Discovery() { ...@@ -67,13 +67,13 @@ export function Discovery() {
</div> </div>
<button <button
onClick={() => handleSwipe(song.id, true)} onClick={() => handleSwipe(song.id, true)}
className={`rounded-full px-2 py-1 text-lg ${song.liked === true ? 'opacity-100' : 'opacity-40 hover:opacity-100'}`} className={`flex min-h-[44px] min-w-[44px] items-center justify-center rounded-full text-lg ${song.liked === true ? 'opacity-100' : 'opacity-40 hover:opacity-100'}`}
> >
❤️ ❤️
</button> </button>
<button <button
onClick={() => handleSwipe(song.id, false)} onClick={() => handleSwipe(song.id, false)}
className={`rounded-full px-2 py-1 text-lg ${song.liked === false ? 'opacity-100' : 'opacity-40 hover:opacity-100'}`} className={`flex min-h-[44px] min-w-[44px] items-center justify-center rounded-full text-lg ${song.liked === false ? 'opacity-100' : 'opacity-40 hover:opacity-100'}`}
> >
✖️ ✖️
</button> </button>
......
...@@ -80,7 +80,7 @@ export function Library() { ...@@ -80,7 +80,7 @@ export function Library() {
<button <button
onClick={() => handlePlay(song)} onClick={() => handlePlay(song)}
disabled={streamLoading === song.id} disabled={streamLoading === song.id}
className="shrink-0 rounded-full bg-neutral-800 px-4 py-1.5 text-sm text-white transition hover:bg-neutral-700 disabled:opacity-50" className="min-h-[40px] shrink-0 rounded-full bg-neutral-800 px-4 text-sm text-white transition hover:bg-neutral-700 disabled:opacity-50"
> >
{streamLoading === song.id ? '…' : playingId === song.id ? 'Pause' : 'Play'} {streamLoading === song.id ? '…' : playingId === song.id ? 'Pause' : 'Play'}
</button> </button>
......
...@@ -62,11 +62,11 @@ export function Remix() { ...@@ -62,11 +62,11 @@ export function Remix() {
onChange={(e) => setPrompt(e.target.value)} onChange={(e) => setPrompt(e.target.value)}
rows={2} rows={2}
placeholder="e.g. Blend the vocals of the first song over the drums of the second, slowed down with heavy reverb" placeholder="e.g. Blend the vocals of the first song over the drums of the second, slowed down with heavy reverb"
className="w-full rounded-lg border border-neutral-700 bg-neutral-800 px-3 py-2 text-white placeholder-neutral-500 outline-none focus:border-emerald-500" className="w-full rounded-lg border border-neutral-700 bg-neutral-800 px-3 py-2 text-base text-white placeholder-neutral-500 outline-none focus:border-emerald-500"
/> />
<button <button
disabled={submitting || files.length === 0 || !prompt.trim()} disabled={submitting || files.length === 0 || !prompt.trim()}
className="rounded-lg bg-emerald-500 px-5 py-2 font-medium text-neutral-950 transition hover:bg-emerald-400 disabled:opacity-40" className="min-h-[44px] rounded-lg bg-emerald-500 px-5 font-medium text-neutral-950 transition hover:bg-emerald-400 disabled:opacity-40"
> >
{submitting ? 'Starting…' : 'Create Remix'} {submitting ? 'Starting…' : 'Create Remix'}
</button> </button>
......
...@@ -34,9 +34,9 @@ export function Rooms() { ...@@ -34,9 +34,9 @@ export function Rooms() {
value={newRoomName} value={newRoomName}
onChange={(e) => setNewRoomName(e.target.value)} onChange={(e) => setNewRoomName(e.target.value)}
placeholder="Room name" placeholder="Room name"
className="flex-1 rounded-lg border border-neutral-700 bg-neutral-800 px-3 py-2 text-white placeholder-neutral-500 outline-none focus:border-emerald-500" className="min-h-[44px] flex-1 rounded-lg border border-neutral-700 bg-neutral-800 px-3 text-base text-white placeholder-neutral-500 outline-none focus:border-emerald-500"
/> />
<button className="rounded-lg bg-emerald-500 px-4 py-2 font-medium text-neutral-950 hover:bg-emerald-400"> <button className="min-h-[44px] rounded-lg bg-emerald-500 px-4 font-medium text-neutral-950 hover:bg-emerald-400">
Start Start
</button> </button>
</form> </form>
...@@ -46,7 +46,7 @@ export function Rooms() { ...@@ -46,7 +46,7 @@ export function Rooms() {
<li key={room.id}> <li key={room.id}>
<button <button
onClick={() => setActiveRoomId(room.id)} onClick={() => setActiveRoomId(room.id)}
className="flex w-full items-center justify-between rounded-lg border border-neutral-800 bg-neutral-900 px-4 py-3 text-left hover:border-neutral-700" className="flex min-h-[44px] w-full items-center justify-between rounded-lg border border-neutral-800 bg-neutral-900 px-4 py-3 text-left hover:border-neutral-700"
> >
<span className="font-medium text-white">{room.name}</span> <span className="font-medium text-white">{room.name}</span>
<span className="text-xs text-neutral-500">DJ #{room.dj_id}</span> <span className="text-xs text-neutral-500">DJ #{room.dj_id}</span>
......
...@@ -40,7 +40,7 @@ export function Upload() { ...@@ -40,7 +40,7 @@ export function Upload() {
<button <button
onClick={handleUpload} onClick={handleUpload}
disabled={!file || busy} disabled={!file || busy}
className="rounded-lg bg-emerald-500 px-5 py-2 font-medium text-neutral-950 transition hover:bg-emerald-400 disabled:opacity-40" className="min-h-[44px] rounded-lg bg-emerald-500 px-5 font-medium text-neutral-950 transition hover:bg-emerald-400 disabled:opacity-40"
> >
{busy ? 'Identifying & tagging…' : 'Upload'} {busy ? 'Identifying & tagging…' : 'Upload'}
</button> </button>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment