Commit 4a6f7e60 authored by Aryan Noshirvnai's avatar Aryan Noshirvnai

Refine UI: real icons, reusable primitives, fluid transitions

Replaces every emoji (nav icons, swipe buttons, room reactions, logo) with
lucide-react icons - consistent stroke weight/sizing instead of whatever
each OS/browser renders emoji as.

Adds src/components/ui/: Button (3 variants, consistent 44px targets,
active:scale press feedback), Input/Textarea (consistent 16px text sizing),
Skeleton/SkeletonRow (replaces plain "Loading…" text so the layout doesn't
jump once real content arrives), EmptyState (consistent icon+message empty
states) - eliminates the repeated ad-hoc Tailwind strings that had drifted
slightly inconsistent across the 6 pages built one at a time.

Fluid touches: transition-colors/transition-all with real durations on
nav/buttons/cards instead of instant state changes, a custom
@keyframes message-enter for new chat messages (tailwindcss-animate isn't
installed and may not support Tailwind v4 cleanly, so this is a small
hand-written animation instead of an unverified dependency), a pulsing
live-room indicator dot, smooth chat auto-scroll.

Typechecks clean, production build succeeds, dev server HMR'd every change
without errors.
Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
parent c55e7092
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
"name": "stax_webapp", "name": "stax_webapp",
"version": "0.0.0", "version": "0.0.0",
"dependencies": { "dependencies": {
"lucide-react": "^1.31.0",
"react": "^19.2.8", "react": "^19.2.8",
"react-dom": "^19.2.8", "react-dom": "^19.2.8",
"react-router-dom": "^7.18.2" "react-router-dom": "^7.18.2"
...@@ -1596,6 +1597,15 @@ ...@@ -1596,6 +1597,15 @@
"url": "https://opencollective.com/parcel" "url": "https://opencollective.com/parcel"
} }
}, },
"node_modules/lucide-react": {
"version": "1.31.0",
"resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-1.31.0.tgz",
"integrity": "sha512-G8u2eEtoHUnUa9f8lbvqDhCiORMnYLdUEo06EEG9MQvHQrInKcX3Pa2TH39MM5qyzRcWETxB0+aOwAPI1g1kEg==",
"license": "ISC",
"peerDependencies": {
"react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0"
}
},
"node_modules/magic-string": { "node_modules/magic-string": {
"version": "0.30.21", "version": "0.30.21",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
"preview": "vite preview" "preview": "vite preview"
}, },
"dependencies": { "dependencies": {
"lucide-react": "^1.31.0",
"react": "^19.2.8", "react": "^19.2.8",
"react-dom": "^19.2.8", "react-dom": "^19.2.8",
"react-router-dom": "^7.18.2" "react-router-dom": "^7.18.2"
......
import type { ReactNode } from 'react' import type { ReactNode } from 'react'
import { Link, useLocation } from 'react-router-dom' import { Link, useLocation } from 'react-router-dom'
import { Compass, Headphones, Library, LogOut, Radio, Rss, Upload, Wand2, type LucideIcon } from 'lucide-react'
import { useAuth } from '../context/AuthContext' import { useAuth } from '../context/AuthContext'
import { Button } from './ui/Button'
const NAV_ITEMS = [ const NAV_ITEMS: { to: string; label: string; icon: LucideIcon }[] = [
{ to: '/library', label: 'Library', icon: '🎵' }, { to: '/library', label: 'Library', icon: Library },
{ to: '/upload', label: 'Upload', icon: '⬆️' }, { to: '/upload', label: 'Upload', icon: Upload },
{ to: '/discovery', label: 'Discover', icon: '🔍' }, { to: '/discovery', label: 'Discover', icon: Compass },
{ to: '/rooms', label: 'Rooms', icon: '🎧' }, { to: '/rooms', label: 'Rooms', icon: Radio },
{ to: '/channels', label: 'Channels', icon: '📡' }, { to: '/channels', label: 'Channels', icon: Rss },
{ to: '/remix', label: 'Remix', icon: '🎛️' }, { to: '/remix', label: 'Remix', icon: Wand2 },
] ]
export function Layout({ title, children }: { title: string; children: ReactNode }) { export function Layout({ title, children }: { title: string; children: ReactNode }) {
...@@ -27,60 +29,66 @@ export function Layout({ title, children }: { title: string; children: ReactNode ...@@ -27,60 +29,66 @@ export function Layout({ title, children }: { title: string; children: ReactNode
{/* Top bar: branding + logout everywhere; the nav links move down here only on {/* Top bar: branding + logout everywhere; the nav links move down here only on
screens wide enough to show all six comfortably without scrolling. */} screens wide enough to show all six comfortably without scrolling. */}
<header <header
className="sticky top-0 z-10 border-b border-neutral-800 bg-neutral-950/95 px-4 backdrop-blur sm:px-6" className="sticky top-0 z-10 border-b border-neutral-800/80 bg-neutral-950/95 px-4 backdrop-blur sm:px-6"
style={{ paddingTop: 'env(safe-area-inset-top)' }} style={{ paddingTop: 'env(safe-area-inset-top)' }}
> >
<div className="flex h-14 items-center justify-between"> <div className="flex h-14 items-center justify-between">
<Link to="/library" className="text-lg font-semibold"> <Link to="/library" className="flex items-center gap-2 text-[15px] font-semibold tracking-tight">
🎧 Stax <Headphones size={20} strokeWidth={2} className="text-emerald-400" />
Stax
</Link> </Link>
<button <Button variant="ghost" size="sm" onClick={handleLogout} className="gap-1.5 !px-3">
onClick={handleLogout} <LogOut size={15} strokeWidth={2} />
className="min-h-[44px] px-2 text-sm text-neutral-400 hover:text-white"
>
Log out Log out
</button> </Button>
</div> </div>
<nav className="hidden gap-4 pb-3 text-sm sm:flex"> <nav className="hidden gap-1 pb-2 text-sm sm:flex">
{NAV_ITEMS.map((item) => ( {NAV_ITEMS.map((item) => {
<Link const active = location.pathname === item.to
key={item.to} return (
to={item.to} <Link
className={`whitespace-nowrap pb-1 ${ key={item.to}
location.pathname === item.to to={item.to}
? 'border-b-2 border-emerald-500 text-white' className={`flex items-center gap-1.5 rounded-full px-3 py-1.5 transition-colors duration-150 ${
: 'text-neutral-400 hover:text-white' active ? 'bg-neutral-900 text-white' : 'text-neutral-400 hover:text-white'
}`} }`}
> >
{item.label} <item.icon size={15} strokeWidth={2} className={active ? 'text-emerald-400' : ''} />
</Link> {item.label}
))} </Link>
)
})}
</nav> </nav>
</header> </header>
<main className="mx-auto max-w-2xl px-4 py-6 pb-24 sm:px-6 sm:py-8 sm:pb-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 tracking-tight">{title}</h1>
{children} {children}
</main> </main>
{/* Bottom tab bar: mobile only, fixed, thumb-reachable. Hidden entirely at sm+ where {/* Bottom tab bar: mobile only, fixed, thumb-reachable. Hidden entirely at sm+ where
the top nav takes over instead. */} the top nav takes over instead. */}
<nav <nav
className="fixed inset-x-0 bottom-0 z-10 flex border-t border-neutral-800 bg-neutral-950/95 backdrop-blur sm:hidden" className="fixed inset-x-0 bottom-0 z-10 flex border-t border-neutral-800/80 bg-neutral-950/95 backdrop-blur sm:hidden"
style={{ paddingBottom: 'env(safe-area-inset-bottom)' }} style={{ paddingBottom: 'env(safe-area-inset-bottom)' }}
> >
{NAV_ITEMS.map((item) => ( {NAV_ITEMS.map((item) => {
<Link const active = location.pathname === item.to
key={item.to} return (
to={item.to} <Link
className={`flex min-h-[56px] flex-1 flex-col items-center justify-center gap-0.5 text-[11px] ${ key={item.to}
location.pathname === item.to ? 'text-emerald-400' : 'text-neutral-500' to={item.to}
}`} className="flex min-h-[56px] flex-1 flex-col items-center justify-center gap-1 text-[10.5px] transition-colors duration-150"
> >
<span className="text-lg leading-none">{item.icon}</span> <item.icon
{item.label} size={20}
</Link> strokeWidth={active ? 2.25 : 1.75}
))} className={`transition-transform duration-150 ${active ? 'scale-110 text-emerald-400' : 'text-neutral-500'}`}
/>
<span className={active ? 'text-white' : 'text-neutral-500'}>{item.label}</span>
</Link>
)
})}
</nav> </nav>
</div> </div>
) )
......
import { useEffect, useRef, useState } from 'react' import { useEffect, useRef, useState } from 'react'
import { ArrowLeft, Flame, Hand, Send } from 'lucide-react'
import { getCurrentUserId } from '../api/jwt' import { getCurrentUserId } from '../api/jwt'
import { connectToRoom, sendChat, sendReaction, requestAux, type ChatMessage } from '../api/roomSocket' import { connectToRoom, sendChat, sendReaction, requestAux, type ChatMessage } from '../api/roomSocket'
import { Button } from './ui/Button'
import { Input } from './ui/Input'
export function RoomView({ roomId, onLeave }: { roomId: number; onLeave: () => void }) { export function RoomView({ roomId, onLeave }: { roomId: number; onLeave: () => void }) {
const userId = getCurrentUserId() const userId = getCurrentUserId()
...@@ -42,7 +45,7 @@ export function RoomView({ roomId, onLeave }: { roomId: number; onLeave: () => v ...@@ -42,7 +45,7 @@ export function RoomView({ roomId, onLeave }: { roomId: number; onLeave: () => v
}, [roomId, userId]) }, [roomId, userId])
useEffect(() => { useEffect(() => {
messagesEndRef.current?.scrollIntoView({ block: 'end' }) messagesEndRef.current?.scrollIntoView({ block: 'end', behavior: 'smooth' })
}, [messages]) }, [messages])
function handleSend(e: React.FormEvent) { function handleSend(e: React.FormEvent) {
...@@ -58,21 +61,31 @@ export function RoomView({ roomId, onLeave }: { roomId: number; onLeave: () => v ...@@ -58,21 +61,31 @@ export function RoomView({ roomId, onLeave }: { roomId: number; onLeave: () => v
// for, which breaks the "input pinned to the bottom of the screen" layout this needs. // 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"> <div className="flex h-dvh flex-col bg-neutral-950 text-white">
<header <header
className="flex shrink-0 items-center justify-between border-b border-neutral-800 px-4 py-3" className="flex shrink-0 items-center justify-between border-b border-neutral-800/80 px-4 py-3"
style={{ paddingTop: 'calc(env(safe-area-inset-top) + 0.75rem)' }} 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"> <button
← Leave onClick={onLeave}
className="flex min-h-[44px] items-center gap-1.5 pr-2 text-sm text-neutral-400 transition-colors hover:text-white"
>
<ArrowLeft size={16} strokeWidth={2} />
Leave
</button> </button>
<div className="text-sm text-neutral-400"> <div className="flex items-center gap-2 text-sm text-neutral-400">
DJ #{djId} {fireCount > 0 && <span className="ml-2">🔥 {fireCount}</span>} DJ #{djId}
{fireCount > 0 && (
<span className="flex items-center gap-1 text-orange-400">
<Flame size={14} strokeWidth={2} fill="currentColor" />
{fireCount}
</span>
)}
</div> </div>
</header> </header>
<div className="flex-1 overflow-y-auto px-4 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="animate-message-enter text-sm">
<span className="text-neutral-500">#{m.user_id}:</span> {m.text} <span className="text-neutral-500">#{m.user_id}:</span> {m.text}
</li> </li>
))} ))}
...@@ -81,37 +94,26 @@ export function RoomView({ roomId, onLeave }: { roomId: number; onLeave: () => v ...@@ -81,37 +94,26 @@ export function RoomView({ roomId, onLeave }: { roomId: number; onLeave: () => v
</div> </div>
<div <div
className="shrink-0 border-t border-neutral-800 px-4 pt-3" className="shrink-0 border-t border-neutral-800/80 px-4 pt-3"
style={{ paddingBottom: 'calc(env(safe-area-inset-bottom) + 0.75rem)' }} 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 variant="secondary" size="sm" onClick={() => wsRef.current && sendReaction(wsRef.current)}>
onClick={() => wsRef.current && sendReaction(wsRef.current)} <Flame size={15} strokeWidth={2} />
className="min-h-[40px] rounded-full bg-neutral-800 px-3 text-sm hover:bg-neutral-700" React
> </Button>
🔥 React
</button>
{djId !== userId && ( {djId !== userId && (
<button <Button variant="secondary" size="sm" onClick={() => wsRef.current && requestAux(wsRef.current)}>
onClick={() => wsRef.current && requestAux(wsRef.current)} <Hand size={15} strokeWidth={2} />
className="min-h-[40px] rounded-full bg-neutral-800 px-3 text-sm hover:bg-neutral-700" {djQueue.includes(userId ?? -1) ? 'Queued' : 'Request aux'}
> </Button>
🙋 Request aux {djQueue.includes(userId ?? -1) ? '(queued)' : ''}
</button>
)} )}
</div> </div>
<form onSubmit={handleSend} className="flex gap-2"> <form onSubmit={handleSend} className="flex gap-2">
<input <Input value={text} onChange={(e) => setText(e.target.value)} placeholder="Say something…" />
value={text} <Button size="icon" aria-label="Send">
onChange={(e) => setText(e.target.value)} <Send size={17} strokeWidth={2} />
placeholder="Say something…" </Button>
// 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="min-h-[44px] rounded-lg bg-emerald-500 px-4 font-medium text-neutral-950 hover:bg-emerald-400">
Send
</button>
</form> </form>
</div> </div>
</div> </div>
......
import { forwardRef, type ButtonHTMLAttributes } from 'react'
type Variant = 'primary' | 'secondary' | 'ghost'
type Size = 'default' | 'sm' | 'icon'
const VARIANT_CLASSES: Record<Variant, string> = {
primary: 'bg-emerald-500 text-neutral-950 hover:bg-emerald-400 disabled:hover:bg-emerald-500',
secondary: 'bg-neutral-800 text-white hover:bg-neutral-700 disabled:hover:bg-neutral-800',
ghost: 'bg-transparent text-neutral-400 hover:bg-neutral-900 hover:text-white',
}
const SIZE_CLASSES: Record<Size, string> = {
default: 'min-h-[44px] px-5 text-sm',
sm: 'min-h-[40px] px-4 text-sm',
icon: 'min-h-[44px] min-w-[44px] p-0',
}
interface Props extends ButtonHTMLAttributes<HTMLButtonElement> {
variant?: Variant
size?: Size
}
export const Button = forwardRef<HTMLButtonElement, Props>(function Button(
{ variant = 'primary', size = 'default', className = '', ...props },
ref,
) {
return (
<button
ref={ref}
className={`inline-flex items-center justify-center gap-1.5 rounded-full font-medium transition-all duration-150 ease-out active:scale-[0.96] disabled:cursor-not-allowed disabled:opacity-40 disabled:active:scale-100 ${VARIANT_CLASSES[variant]} ${SIZE_CLASSES[size]} ${className}`}
{...props}
/>
)
})
import type { LucideIcon } from 'lucide-react'
export function EmptyState({ icon: Icon, message }: { icon: LucideIcon; message: string }) {
return (
<div className="flex flex-col items-center gap-3 py-16 text-center text-neutral-500">
<Icon size={28} strokeWidth={1.5} />
<p className="max-w-xs text-sm">{message}</p>
</div>
)
}
import { forwardRef, type InputHTMLAttributes, type TextareaHTMLAttributes } from 'react'
const FIELD_CLASSES =
// text-base (16px), not smaller: anything under 16px triggers iOS Safari's auto-zoom-on-focus
'min-h-[44px] w-full rounded-lg border border-neutral-700 bg-neutral-800 px-3.5 text-base text-white placeholder-neutral-500 outline-none transition-colors duration-150 focus:border-emerald-500'
export const Input = forwardRef<HTMLInputElement, InputHTMLAttributes<HTMLInputElement>>(function Input(
{ className = '', ...props },
ref,
) {
return <input ref={ref} className={`${FIELD_CLASSES} ${className}`} {...props} />
})
export const Textarea = forwardRef<HTMLTextAreaElement, TextareaHTMLAttributes<HTMLTextAreaElement>>(
function Textarea({ className = '', ...props }, ref) {
return <textarea ref={ref} className={`${FIELD_CLASSES} py-2.5 ${className}`} {...props} />
},
)
export function Skeleton({ className = '' }: { className?: string }) {
return <div className={`animate-pulse rounded-md bg-neutral-800/80 ${className}`} />
}
/** A row shaped like a library/discovery list item, for use while data is loading instead of
* a plain "Loading…" string - avoids the layout jumping once real content arrives. */
export function SkeletonRow() {
return (
<div className="flex items-center gap-4 py-3">
<Skeleton className="h-12 w-12 shrink-0" />
<div className="flex-1 space-y-2">
<Skeleton className="h-4 w-2/3" />
<Skeleton className="h-3 w-1/3" />
</div>
</div>
)
}
@import "tailwindcss"; @import "tailwindcss";
@keyframes message-enter {
from {
opacity: 0;
transform: translateY(4px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.animate-message-enter {
animation: message-enter 200ms ease-out;
}
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { Rss } from 'lucide-react'
import { Layout } from '../components/Layout' import { Layout } from '../components/Layout'
import { Button } from '../components/ui/Button'
import { Input } from '../components/ui/Input'
import { EmptyState } from '../components/ui/EmptyState'
import { SkeletonRow } from '../components/ui/Skeleton'
import { createChannel, followChannel, getChannel, listChannels, unfollowChannel, type Channel } from '../api/channels' import { createChannel, followChannel, getChannel, listChannels, unfollowChannel, type Channel } from '../api/channels'
import { getCurrentUserId } from '../api/jwt' import { getCurrentUserId } from '../api/jwt'
export function Channels() { export function Channels() {
const userId = getCurrentUserId() const userId = getCurrentUserId()
const [channels, setChannels] = useState<Channel[]>([]) const [channels, setChannels] = useState<Channel[]>([])
const [loading, setLoading] = useState(true)
const [followerCounts, setFollowerCounts] = useState<Record<number, number>>({}) const [followerCounts, setFollowerCounts] = useState<Record<number, number>>({})
const [followedIds, setFollowedIds] = useState<Set<number>>(new Set()) const [followedIds, setFollowedIds] = useState<Set<number>>(new Set())
const [newName, setNewName] = useState('') const [newName, setNewName] = useState('')
...@@ -13,6 +19,7 @@ export function Channels() { ...@@ -13,6 +19,7 @@ export function Channels() {
async function refresh() { async function refresh() {
const list = await listChannels() const list = await listChannels()
setChannels(list) setChannels(list)
setLoading(false)
const counts: Record<number, number> = {} const counts: Record<number, number> = {}
await Promise.all( await Promise.all(
list.map(async (c) => { list.map(async (c) => {
...@@ -51,22 +58,25 @@ export function Channels() { ...@@ -51,22 +58,25 @@ export function Channels() {
return ( return (
<Layout title="Channels"> <Layout title="Channels">
<form onSubmit={handleCreate} className="mb-6 flex gap-2"> <form onSubmit={handleCreate} className="mb-6 flex gap-2">
<input <Input value={newName} onChange={(e) => setNewName(e.target.value)} placeholder="New channel name" />
value={newName} <Button type="submit">Create</Button>
onChange={(e) => setNewName(e.target.value)}
placeholder="New channel name"
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="min-h-[44px] rounded-lg bg-emerald-500 px-4 font-medium text-neutral-950 hover:bg-emerald-400">
Create
</button>
</form> </form>
{loading && (
<div className="space-y-2">
<SkeletonRow />
<SkeletonRow />
</div>
)}
{!loading && channels.length === 0 && (
<EmptyState icon={Rss} message="No channels yet - start one to publish vibe sets and stories." />
)}
<ul className="space-y-2"> <ul className="space-y-2">
{channels.map((channel) => ( {channels.map((channel) => (
<li <li
key={channel.id} key={channel.id}
className="flex min-h-[44px] items-center justify-between gap-3 rounded-lg border border-neutral-800 bg-neutral-900 px-4 py-3" className="flex min-h-[52px] items-center justify-between gap-3 rounded-lg border border-neutral-800 bg-neutral-900 px-4 py-3 transition-colors duration-150 hover:border-neutral-700"
> >
<div className="min-w-0"> <div className="min-w-0">
<p className="truncate font-medium text-white">{channel.name}</p> <p className="truncate font-medium text-white">{channel.name}</p>
...@@ -75,16 +85,17 @@ export function Channels() { ...@@ -75,16 +85,17 @@ export function Channels() {
</p> </p>
</div> </div>
{channel.owner_id !== userId && ( {channel.owner_id !== userId && (
<button <Button
variant={followedIds.has(channel.id) ? 'secondary' : 'primary'}
size="sm"
onClick={() => toggleFollow(channel.id)} onClick={() => toggleFollow(channel.id)}
className="min-h-[40px] shrink-0 rounded-full bg-neutral-800 px-4 text-sm text-white hover:bg-neutral-700" className="shrink-0"
> >
{followedIds.has(channel.id) ? 'Unfollow' : 'Follow'} {followedIds.has(channel.id) ? 'Unfollow' : 'Follow'}
</button> </Button>
)} )}
</li> </li>
))} ))}
{channels.length === 0 && <p className="text-neutral-500">No channels yet.</p>}
</ul> </ul>
</Layout> </Layout>
) )
......
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { Ear, Heart, Music2, X } from 'lucide-react'
import { Layout } from '../components/Layout' import { Layout } from '../components/Layout'
import { getDiscoveryHistory, listen, swipe, type DiscoveredSong } from '../api/discovery' import { getDiscoveryHistory, listen, swipe, type DiscoveredSong } from '../api/discovery'
import { SkeletonRow } from '../components/ui/Skeleton'
import { EmptyState } from '../components/ui/EmptyState'
export function Discovery() { export function Discovery() {
const [history, setHistory] = useState<DiscoveredSong[]>([]) const [history, setHistory] = useState<DiscoveredSong[]>([])
const [loading, setLoading] = useState(true)
const [busy, setBusy] = useState(false) const [busy, setBusy] = useState(false)
const [message, setMessage] = useState<string | null>(null) const [message, setMessage] = useState<string | null>(null)
function refresh() { function refresh() {
getDiscoveryHistory().then((res) => setHistory(res.history)) getDiscoveryHistory()
.then((res) => setHistory(res.history))
.finally(() => setLoading(false))
} }
useEffect(refresh, []) useEffect(refresh, [])
...@@ -38,28 +44,41 @@ export function Discovery() { ...@@ -38,28 +44,41 @@ export function Discovery() {
return ( return (
<Layout title="Discovery"> <Layout title="Discovery">
<div className="mb-6 rounded-xl border border-dashed border-neutral-700 p-6 text-center"> <label className="mb-8 flex cursor-pointer flex-col items-center gap-3 rounded-xl border border-dashed border-neutral-700 p-8 text-center transition-colors duration-150 hover:border-neutral-600 hover:bg-neutral-900/50">
<p className="mb-3 text-sm text-neutral-400">Drop a short clip of what's playing to identify it</p> <Ear size={26} strokeWidth={1.5} className="text-neutral-500" />
<span className="text-sm text-neutral-400">Drop a short clip of what's playing to identify it</span>
<input <input
type="file" type="file"
accept="audio/*" accept="audio/*"
disabled={busy} disabled={busy}
onChange={(e) => e.target.files?.[0] && handleListen(e.target.files[0])} onChange={(e) => e.target.files?.[0] && handleListen(e.target.files[0])}
className="block w-full text-sm text-neutral-300 file:mr-3 file:rounded-full file:border-0 file:bg-neutral-800 file:px-4 file:py-2 file:text-white hover:file:bg-neutral-700" className="hidden"
/> />
{message && <p className="mt-3 text-sm text-emerald-400">{message}</p>} {busy && <span className="text-xs text-neutral-500">Listening…</span>}
</div> </label>
{message && <p className="-mt-4 mb-6 text-sm text-emerald-400">{message}</p>}
<h2 className="mb-3 text-sm font-medium uppercase tracking-wide text-neutral-500"> <h2 className="mb-3 text-xs font-medium uppercase tracking-wider text-neutral-500">Last 24 hours</h2>
Last 24 hours
</h2> {loading && (
<ul className="divide-y divide-neutral-800"> <div className="divide-y divide-neutral-800/80">
<SkeletonRow />
<SkeletonRow />
</div>
)}
{!loading && history.length === 0 && (
<EmptyState icon={Music2} message="Nothing identified in the last 24 hours yet." />
)}
<ul className="divide-y divide-neutral-800/80">
{history.map((song) => ( {history.map((song) => (
<li key={song.id} className="flex items-center gap-4 py-3"> <li key={song.id} className="flex items-center gap-4 py-3">
{song.coverart ? ( {song.coverart ? (
<img src={song.coverart} alt="" className="h-10 w-10 rounded-md object-cover" /> <img src={song.coverart} alt="" className="h-10 w-10 shrink-0 rounded-md object-cover" />
) : ( ) : (
<div className="h-10 w-10 rounded-md bg-neutral-800" /> <div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-md bg-neutral-800 text-neutral-600">
<Music2 size={16} strokeWidth={1.75} />
</div>
)} )}
<div className="min-w-0 flex-1"> <div className="min-w-0 flex-1">
<p className="truncate font-medium text-white">{song.title}</p> <p className="truncate font-medium text-white">{song.title}</p>
...@@ -67,15 +86,21 @@ export function Discovery() { ...@@ -67,15 +86,21 @@ export function Discovery() {
</div> </div>
<button <button
onClick={() => handleSwipe(song.id, true)} onClick={() => handleSwipe(song.id, true)}
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'}`} aria-label="Like"
className={`flex min-h-[44px] min-w-[44px] items-center justify-center rounded-full transition-all duration-150 active:scale-90 ${
song.liked === true ? 'text-emerald-400' : 'text-neutral-600 hover:text-neutral-300'
}`}
> >
❤️ <Heart size={19} strokeWidth={2} fill={song.liked === true ? 'currentColor' : 'none'} />
</button> </button>
<button <button
onClick={() => handleSwipe(song.id, false)} onClick={() => handleSwipe(song.id, false)}
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'}`} aria-label="Dismiss"
className={`flex min-h-[44px] min-w-[44px] items-center justify-center rounded-full transition-all duration-150 active:scale-90 ${
song.liked === false ? 'text-red-400' : 'text-neutral-600 hover:text-neutral-300'
}`}
> >
✖️ <X size={19} strokeWidth={2} />
</button> </button>
</li> </li>
))} ))}
......
import { useEffect, useRef, useState } from 'react' import { useEffect, useRef, useState } from 'react'
import { Music2, Pause, Play } from 'lucide-react'
import { getLibrary, type LibrarySong } from '../api/library' import { getLibrary, type LibrarySong } from '../api/library'
import { fetchStreamUrl } from '../api/stream' import { fetchStreamUrl } from '../api/stream'
import { ApiError } from '../api/client' import { ApiError } from '../api/client'
import { Layout } from '../components/Layout' import { Layout } from '../components/Layout'
import { Button } from '../components/ui/Button'
import { SkeletonRow } from '../components/ui/Skeleton'
import { EmptyState } from '../components/ui/EmptyState'
export function Library() { export function Library() {
const [songs, setSongs] = useState<LibrarySong[]>([]) const [songs, setSongs] = useState<LibrarySong[]>([])
...@@ -54,20 +58,26 @@ export function Library() { ...@@ -54,20 +58,26 @@ export function Library() {
<Layout title="Library"> <Layout title="Library">
<audio ref={audioRef} onEnded={() => setPlayingId(null)} className="hidden" /> <audio ref={audioRef} onEnded={() => setPlayingId(null)} className="hidden" />
{loading && <p className="text-neutral-500">Loading…</p>} {loading && (
{error && <p className="text-red-400">{error}</p>} <div className="divide-y divide-neutral-800/80">
<SkeletonRow />
<SkeletonRow />
<SkeletonRow />
</div>
)}
{error && <p className="text-sm text-red-400">{error}</p>}
{!loading && !error && songs.length === 0 && ( {!loading && !error && songs.length === 0 && (
<p className="text-neutral-500">No songs yet - tag something from Telegram to see it here.</p> <EmptyState icon={Music2} message="No songs yet - tag something from Telegram to see it here." />
)} )}
<ul className="divide-y divide-neutral-800"> <ul className="divide-y divide-neutral-800/80">
{songs.map((song) => ( {songs.map((song) => (
<li key={song.id} className="flex items-center gap-4 py-3"> <li key={song.id} className="flex items-center gap-4 py-3">
{song.coverart ? ( {song.coverart ? (
<img src={song.coverart} alt="" className="h-12 w-12 rounded-md object-cover" /> <img src={song.coverart} alt="" className="h-12 w-12 shrink-0 rounded-md object-cover" />
) : ( ) : (
<div className="flex h-12 w-12 items-center justify-center rounded-md bg-neutral-800 text-neutral-600"> <div className="flex h-12 w-12 shrink-0 items-center justify-center rounded-md bg-neutral-800 text-neutral-600">
♪ <Music2 size={18} strokeWidth={1.75} />
</div> </div>
)} )}
<div className="min-w-0 flex-1"> <div className="min-w-0 flex-1">
...@@ -77,13 +87,21 @@ export function Library() { ...@@ -77,13 +87,21 @@ export function Library() {
{song.album ? ` · ${song.album}` : ''} {song.album ? ` · ${song.album}` : ''}
</p> </p>
</div> </div>
<button <Button
variant="secondary"
size="icon"
onClick={() => handlePlay(song)} onClick={() => handlePlay(song)}
disabled={streamLoading === song.id} disabled={streamLoading === song.id}
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" aria-label={playingId === song.id ? 'Pause' : 'Play'}
> >
{streamLoading === song.id ? '…' : playingId === song.id ? 'Pause' : 'Play'} {streamLoading === song.id ? (
</button> <span className="h-3.5 w-3.5 animate-spin rounded-full border-2 border-neutral-600 border-t-white" />
) : playingId === song.id ? (
<Pause size={16} strokeWidth={2} fill="currentColor" />
) : (
<Play size={16} strokeWidth={2} fill="currentColor" className="ml-0.5" />
)}
</Button>
</li> </li>
))} ))}
</ul> </ul>
......
import { useEffect, useRef, useState } from 'react' import { useEffect, useRef, useState } from 'react'
import { AlertCircle, Music2, Sparkles, X } from 'lucide-react'
import { Layout } from '../components/Layout' import { Layout } from '../components/Layout'
import { Button } from '../components/ui/Button'
import { Textarea } from '../components/ui/Input'
import { createRemix, getRemixStatus, type RemixStatus } from '../api/remix' import { createRemix, getRemixStatus, type RemixStatus } from '../api/remix'
const STAGES: RemixStatus['status'][] = ['queued', 'planning', 'separating', 'mixing', 'mastering', 'tagging', 'done'] const STAGES: RemixStatus['status'][] = ['queued', 'planning', 'separating', 'mixing', 'mastering', 'tagging', 'done']
...@@ -18,6 +21,10 @@ export function Remix() { ...@@ -18,6 +21,10 @@ export function Remix() {
} }
}, []) }, [])
function removeFile(index: number) {
setFiles((f) => f.filter((_, i) => i !== index))
}
async function handleSubmit(e: React.FormEvent) { async function handleSubmit(e: React.FormEvent) {
e.preventDefault() e.preventDefault()
if (files.length === 0 || !prompt.trim()) return if (files.length === 0 || !prompt.trim()) return
...@@ -44,35 +51,64 @@ export function Remix() { ...@@ -44,35 +51,64 @@ export function Remix() {
return ( return (
<Layout title="AI Remix"> <Layout title="AI Remix">
<p className="mb-6 text-sm text-neutral-400"> <p className="mb-6 text-sm leading-relaxed text-neutral-400">
Upload 1-5 songs and describe the remix in plain language. Gemini directs the arrangement, Upload 1-5 songs and describe the remix in plain language. Gemini directs the arrangement,
Demucs does the stem separation. Demucs does the stem separation.
</p> </p>
<form onSubmit={handleSubmit} className="space-y-4"> <form onSubmit={handleSubmit} className="space-y-4">
<input <label className="flex cursor-pointer flex-col items-center gap-2 rounded-xl border border-dashed border-neutral-700 p-6 text-center transition-colors duration-150 hover:border-neutral-600 hover:bg-neutral-900/50">
type="file" <Music2 size={22} strokeWidth={1.5} className="text-neutral-500" />
accept="audio/*" <span className="text-sm text-neutral-400">Choose up to 5 audio files</span>
multiple <input
onChange={(e) => setFiles(Array.from(e.target.files ?? []).slice(0, 5))} type="file"
className="block w-full text-sm text-neutral-300 file:mr-3 file:rounded-full file:border-0 file:bg-neutral-800 file:px-4 file:py-2 file:text-white hover:file:bg-neutral-700" accept="audio/*"
/> multiple
<textarea onChange={(e) => setFiles(Array.from(e.target.files ?? []).slice(0, 5))}
className="hidden"
/>
</label>
{files.length > 0 && (
<ul className="space-y-1.5">
{files.map((f, i) => (
<li
key={`${f.name}-${i}`}
className="flex items-center justify-between rounded-lg bg-neutral-900 px-3 py-2 text-sm text-neutral-300"
>
<span className="truncate">{f.name}</span>
<button
type="button"
onClick={() => removeFile(i)}
aria-label="Remove file"
className="ml-2 flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-neutral-500 hover:bg-neutral-800 hover:text-white"
>
<X size={14} strokeWidth={2} />
</button>
</li>
))}
</ul>
)}
<Textarea
value={prompt} value={prompt}
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-base text-white placeholder-neutral-500 outline-none focus:border-emerald-500"
/> />
<button
disabled={submitting || files.length === 0 || !prompt.trim()} <Button type="submit" disabled={submitting || files.length === 0 || !prompt.trim()} className="w-full">
className="min-h-[44px] rounded-lg bg-emerald-500 px-5 font-medium text-neutral-950 transition hover:bg-emerald-400 disabled:opacity-40" <Sparkles size={16} strokeWidth={2} />
>
{submitting ? 'Starting…' : 'Create Remix'} {submitting ? 'Starting…' : 'Create Remix'}
</button> </Button>
</form> </form>
{error && <p className="mt-4 text-sm text-red-400">{error}</p>} {error && (
<p className="mt-4 flex items-center gap-1.5 text-sm text-red-400">
<AlertCircle size={14} strokeWidth={2} />
{error}
</p>
)}
{status && ( {status && (
<div className="mt-6 rounded-xl border border-neutral-800 bg-neutral-900 p-4"> <div className="mt-6 rounded-xl border border-neutral-800 bg-neutral-900 p-4">
...@@ -80,7 +116,7 @@ export function Remix() { ...@@ -80,7 +116,7 @@ export function Remix() {
{STAGES.slice(0, -1).map((stage, i) => ( {STAGES.slice(0, -1).map((stage, i) => (
<div <div
key={stage} key={stage}
className={`h-1.5 flex-1 rounded-full ${i <= stageIndex ? 'bg-emerald-500' : 'bg-neutral-800'}`} className={`h-1.5 flex-1 rounded-full transition-colors duration-300 ${i <= stageIndex ? 'bg-emerald-500' : 'bg-neutral-800'}`}
/> />
))} ))}
</div> </div>
......
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { ChevronRight, Radio } from 'lucide-react'
import { Layout } from '../components/Layout' import { Layout } from '../components/Layout'
import { Button } from '../components/ui/Button'
import { Input } from '../components/ui/Input'
import { EmptyState } from '../components/ui/EmptyState'
import { createRoom, getActiveRooms, type LiveRoom } from '../api/social' import { createRoom, getActiveRooms, type LiveRoom } from '../api/social'
import { RoomView } from '../components/RoomView' import { RoomView } from '../components/RoomView'
export function Rooms() { export function Rooms() {
const [rooms, setRooms] = useState<LiveRoom[]>([]) const [rooms, setRooms] = useState<LiveRoom[]>([])
const [loading, setLoading] = useState(true)
const [newRoomName, setNewRoomName] = useState('') const [newRoomName, setNewRoomName] = useState('')
const [activeRoomId, setActiveRoomId] = useState<number | null>(null) const [activeRoomId, setActiveRoomId] = useState<number | null>(null)
function refresh() { function refresh() {
getActiveRooms().then(setRooms) getActiveRooms()
.then(setRooms)
.finally(() => setLoading(false))
} }
useEffect(refresh, []) useEffect(refresh, [])
...@@ -30,30 +37,39 @@ export function Rooms() { ...@@ -30,30 +37,39 @@ export function Rooms() {
return ( return (
<Layout title="Pass-the-Aux Rooms"> <Layout title="Pass-the-Aux Rooms">
<form onSubmit={handleCreate} className="mb-6 flex gap-2"> <form onSubmit={handleCreate} className="mb-6 flex gap-2">
<input <Input
value={newRoomName} value={newRoomName}
onChange={(e) => setNewRoomName(e.target.value)} onChange={(e) => setNewRoomName(e.target.value)}
placeholder="Room name" placeholder="Room name"
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="min-h-[44px] rounded-lg bg-emerald-500 px-4 font-medium text-neutral-950 hover:bg-emerald-400"> <Button type="submit">Start</Button>
Start
</button>
</form> </form>
{!loading && rooms.length === 0 && (
<EmptyState icon={Radio} message="No active rooms right now - start one to get the aux passing." />
)}
<ul className="space-y-2"> <ul className="space-y-2">
{rooms.map((room) => ( {rooms.map((room) => (
<li key={room.id}> <li key={room.id}>
<button <button
onClick={() => setActiveRoomId(room.id)} onClick={() => setActiveRoomId(room.id)}
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" className="flex min-h-[52px] w-full items-center justify-between gap-3 rounded-lg border border-neutral-800 bg-neutral-900 px-4 py-3 text-left transition-colors duration-150 hover:border-neutral-700 hover:bg-neutral-900/70"
> >
<span className="font-medium text-white">{room.name}</span> <div className="flex items-center gap-3">
<span className="text-xs text-neutral-500">DJ #{room.dj_id}</span> <span className="relative flex h-2 w-2">
<span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-75" />
<span className="relative inline-flex h-2 w-2 rounded-full bg-emerald-500" />
</span>
<div>
<p className="font-medium text-white">{room.name}</p>
<p className="text-xs text-neutral-500">DJ #{room.dj_id}</p>
</div>
</div>
<ChevronRight size={18} strokeWidth={2} className="shrink-0 text-neutral-600" />
</button> </button>
</li> </li>
))} ))}
{rooms.length === 0 && <p className="text-neutral-500">No active rooms right now.</p>}
</ul> </ul>
</Layout> </Layout>
) )
......
import { useState } from 'react' import { useState } from 'react'
import { UploadCloud } from 'lucide-react'
import { Layout } from '../components/Layout' import { Layout } from '../components/Layout'
import { Button } from '../components/ui/Button'
import { uploadDirect, type TagResponse } from '../api/music' import { uploadDirect, type TagResponse } from '../api/music'
export function Upload() { export function Upload() {
...@@ -25,26 +27,27 @@ export function Upload() { ...@@ -25,26 +27,27 @@ export function Upload() {
return ( return (
<Layout title="Upload &amp; Tag"> <Layout title="Upload &amp; Tag">
<p className="mb-6 text-sm text-neutral-400"> <p className="mb-6 text-sm leading-relaxed text-neutral-400">
Upload an untagged track - it's fingerprinted, tagged with title/artist/album/art/lyrics, and Upload an untagged track - it's fingerprinted, tagged with title/artist/album/art/lyrics, and
added to your library. added to your library.
</p> </p>
<div className="rounded-xl border border-dashed border-neutral-700 p-8 text-center"> <label className="flex cursor-pointer flex-col items-center gap-3 rounded-xl border border-dashed border-neutral-700 p-10 text-center transition-colors duration-150 hover:border-neutral-600 hover:bg-neutral-900/50">
<UploadCloud size={28} strokeWidth={1.5} className="text-neutral-500" />
<span className="text-sm text-neutral-400">
{file ? file.name : 'Choose an audio file, or drag one here'}
</span>
<input <input
type="file" type="file"
accept="audio/*" accept="audio/*"
onChange={(e) => setFile(e.target.files?.[0] ?? null)} onChange={(e) => setFile(e.target.files?.[0] ?? null)}
className="mb-4 block w-full text-sm text-neutral-300 file:mr-3 file:rounded-full file:border-0 file:bg-neutral-800 file:px-4 file:py-2 file:text-white hover:file:bg-neutral-700" className="hidden"
/> />
<button </label>
onClick={handleUpload}
disabled={!file || busy} <Button onClick={handleUpload} disabled={!file || busy} className="mt-4 w-full">
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>
{busy ? 'Identifying & tagging…' : 'Upload'}
</button>
</div>
{error && <p className="mt-4 text-sm text-red-400">{error}</p>} {error && <p className="mt-4 text-sm text-red-400">{error}</p>}
......
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