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 @@
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>stax_webapp</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
<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>
<body>
<div id="root"></div>
......
......@@ -3,12 +3,12 @@ import { Link, useLocation } from 'react-router-dom'
import { useAuth } from '../context/AuthContext'
const NAV_ITEMS = [
{ to: '/library', label: 'Library' },
{ to: '/upload', label: 'Upload' },
{ to: '/discovery', label: 'Discovery' },
{ to: '/rooms', label: 'Rooms' },
{ to: '/channels', label: 'Channels' },
{ to: '/remix', label: 'Remix' },
{ to: '/library', label: 'Library', icon: '🎵' },
{ to: '/upload', label: 'Upload', icon: '⬆️' },
{ to: '/discovery', label: 'Discover', icon: '🔍' },
{ to: '/rooms', label: 'Rooms', icon: '🎧' },
{ to: '/channels', label: 'Channels', icon: '📡' },
{ to: '/remix', label: 'Remix', icon: '🎛️' },
]
export function Layout({ title, children }: { title: string; children: ReactNode }) {
......@@ -24,16 +24,24 @@ export function Layout({ title, children }: { title: string; children: ReactNode
return (
<div className="min-h-screen bg-neutral-950 text-white">
<header className="border-b border-neutral-800 px-6 py-4">
<div className="mb-3 flex items-center justify-between">
{/* Top bar: branding + logout everywhere; the nav links move down here only on
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">
🎧 Stax
</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
</button>
</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) => (
<Link
key={item.to}
......@@ -49,10 +57,31 @@ export function Layout({ title, children }: { title: string; children: ReactNode
))}
</nav>
</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>
{children}
</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>
)
}
......@@ -10,6 +10,7 @@ export function RoomView({ roomId, onLeave }: { roomId: number; onLeave: () => v
const [djQueue, setDjQueue] = useState<number[]>([])
const [text, setText] = useState('')
const wsRef = useRef<WebSocket | null>(null)
const messagesEndRef = useRef<HTMLDivElement | null>(null)
useEffect(() => {
if (userId === null) return
......@@ -40,6 +41,10 @@ export function RoomView({ roomId, onLeave }: { roomId: number; onLeave: () => v
return () => ws.close()
}, [roomId, userId])
useEffect(() => {
messagesEndRef.current?.scrollIntoView({ block: 'end' })
}, [messages])
function handleSend(e: React.FormEvent) {
e.preventDefault()
if (!text.trim() || !wsRef.current) return
......@@ -48,17 +53,23 @@ export function RoomView({ roomId, onLeave }: { roomId: number; onLeave: () => v
}
return (
<div className="flex min-h-screen flex-col bg-neutral-950 text-white">
<header className="flex items-center justify-between border-b border-neutral-800 px-6 py-4">
<button onClick={onLeave} className="text-sm text-neutral-400 hover:text-white">
← Leave room
// h-dvh (dynamic viewport height), not min-h-screen: on mobile, min-h-screen can end up
// taller than what's actually visible once browser chrome/the keyboard are accounted
// for, which breaks the "input pinned to the bottom of the screen" layout this needs.
<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>
<div className="text-sm text-neutral-400">
DJ #{djId} {fireCount > 0 && <span className="ml-2">🔥 {fireCount}</span>}
</div>
</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">
{messages.map((m, i) => (
<li key={i} className="text-sm">
......@@ -66,20 +77,24 @@ export function RoomView({ roomId, onLeave }: { roomId: number; onLeave: () => v
</li>
))}
</ul>
<div ref={messagesEndRef} />
</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">
<button
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
</button>
{djId !== userId && (
<button
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)' : ''}
</button>
......@@ -90,9 +105,11 @@ export function RoomView({ roomId, onLeave }: { roomId: number; onLeave: () => v
value={text}
onChange={(e) => setText(e.target.value)}
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
</button>
</form>
......
......@@ -55,9 +55,9 @@ export function Channels() {
value={newName}
onChange={(e) => setNewName(e.target.value)}
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
</button>
</form>
......@@ -66,10 +66,10 @@ export function Channels() {
{channels.map((channel) => (
<li
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>
<p className="font-medium text-white">{channel.name}</p>
<div className="min-w-0">
<p className="truncate font-medium text-white">{channel.name}</p>
<p className="text-xs text-neutral-500">
{followerCounts[channel.id] ?? 0} followers · owner #{channel.owner_id}
</p>
......@@ -77,7 +77,7 @@ export function Channels() {
{channel.owner_id !== userId && (
<button
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'}
</button>
......
......@@ -67,13 +67,13 @@ export function Discovery() {
</div>
<button
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
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>
......
......@@ -80,7 +80,7 @@ export function Library() {
<button
onClick={() => handlePlay(song)}
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'}
</button>
......
......@@ -62,11 +62,11 @@ export function Remix() {
onChange={(e) => setPrompt(e.target.value)}
rows={2}
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
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'}
</button>
......
......@@ -34,9 +34,9 @@ export function Rooms() {
value={newRoomName}
onChange={(e) => setNewRoomName(e.target.value)}
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
</button>
</form>
......@@ -46,7 +46,7 @@ export function Rooms() {
<li key={room.id}>
<button
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="text-xs text-neutral-500">DJ #{room.dj_id}</span>
......
......@@ -40,7 +40,7 @@ export function Upload() {
<button
onClick={handleUpload}
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'}
</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