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 @@
"name": "stax_webapp",
"version": "0.0.0",
"dependencies": {
"lucide-react": "^1.31.0",
"react": "^19.2.8",
"react-dom": "^19.2.8",
"react-router-dom": "^7.18.2"
......@@ -1596,6 +1597,15 @@
"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": {
"version": "0.30.21",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",
......
......@@ -10,6 +10,7 @@
"preview": "vite preview"
},
"dependencies": {
"lucide-react": "^1.31.0",
"react": "^19.2.8",
"react-dom": "^19.2.8",
"react-router-dom": "^7.18.2"
......
import type { ReactNode } from 'react'
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 { Button } from './ui/Button'
const NAV_ITEMS = [
{ 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: '🎛️' },
const NAV_ITEMS: { to: string; label: string; icon: LucideIcon }[] = [
{ to: '/library', label: 'Library', icon: Library },
{ to: '/upload', label: 'Upload', icon: Upload },
{ to: '/discovery', label: 'Discover', icon: Compass },
{ to: '/rooms', label: 'Rooms', icon: Radio },
{ to: '/channels', label: 'Channels', icon: Rss },
{ to: '/remix', label: 'Remix', icon: Wand2 },
]
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
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"
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)' }}
>
<div className="flex h-14 items-center justify-between">
<Link to="/library" className="text-lg font-semibold">
🎧 Stax
<Link to="/library" className="flex items-center gap-2 text-[15px] font-semibold tracking-tight">
<Headphones size={20} strokeWidth={2} className="text-emerald-400" />
Stax
</Link>
<button
onClick={handleLogout}
className="min-h-[44px] px-2 text-sm text-neutral-400 hover:text-white"
>
<Button variant="ghost" size="sm" onClick={handleLogout} className="gap-1.5 !px-3">
<LogOut size={15} strokeWidth={2} />
Log out
</button>
</Button>
</div>
<nav className="hidden gap-4 pb-3 text-sm sm:flex">
{NAV_ITEMS.map((item) => (
<Link
key={item.to}
to={item.to}
className={`whitespace-nowrap pb-1 ${
location.pathname === item.to
? 'border-b-2 border-emerald-500 text-white'
: 'text-neutral-400 hover:text-white'
}`}
>
{item.label}
</Link>
))}
<nav className="hidden gap-1 pb-2 text-sm sm:flex">
{NAV_ITEMS.map((item) => {
const active = location.pathname === item.to
return (
<Link
key={item.to}
to={item.to}
className={`flex items-center gap-1.5 rounded-full px-3 py-1.5 transition-colors duration-150 ${
active ? 'bg-neutral-900 text-white' : 'text-neutral-400 hover:text-white'
}`}
>
<item.icon size={15} strokeWidth={2} className={active ? 'text-emerald-400' : ''} />
{item.label}
</Link>
)
})}
</nav>
</header>
<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}
</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"
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)' }}
>
{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_ITEMS.map((item) => {
const active = location.pathname === item.to
return (
<Link
key={item.to}
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"
>
<item.icon
size={20}
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>
</div>
)
......
import { useEffect, useRef, useState } from 'react'
import { ArrowLeft, Flame, Hand, Send } from 'lucide-react'
import { getCurrentUserId } from '../api/jwt'
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 }) {
const userId = getCurrentUserId()
......@@ -42,7 +45,7 @@ export function RoomView({ roomId, onLeave }: { roomId: number; onLeave: () => v
}, [roomId, userId])
useEffect(() => {
messagesEndRef.current?.scrollIntoView({ block: 'end' })
messagesEndRef.current?.scrollIntoView({ block: 'end', behavior: 'smooth' })
}, [messages])
function handleSend(e: React.FormEvent) {
......@@ -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.
<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"
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)' }}
>
<button onClick={onLeave} className="min-h-[44px] px-1 text-sm text-neutral-400 hover:text-white">
← Leave
<button
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>
<div className="text-sm text-neutral-400">
DJ #{djId} {fireCount > 0 && <span className="ml-2">🔥 {fireCount}</span>}
<div className="flex items-center gap-2 text-sm text-neutral-400">
DJ #{djId}
{fireCount > 0 && (
<span className="flex items-center gap-1 text-orange-400">
<Flame size={14} strokeWidth={2} fill="currentColor" />
{fireCount}
</span>
)}
</div>
</header>
<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">
<li key={i} className="animate-message-enter text-sm">
<span className="text-neutral-500">#{m.user_id}:</span> {m.text}
</li>
))}
......@@ -81,37 +94,26 @@ export function RoomView({ roomId, onLeave }: { roomId: number; onLeave: () => v
</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)' }}
>
<div className="mb-3 flex gap-2">
<button
onClick={() => wsRef.current && sendReaction(wsRef.current)}
className="min-h-[40px] rounded-full bg-neutral-800 px-3 text-sm hover:bg-neutral-700"
>
🔥 React
</button>
<Button variant="secondary" size="sm" onClick={() => wsRef.current && sendReaction(wsRef.current)}>
<Flame size={15} strokeWidth={2} />
React
</Button>
{djId !== userId && (
<button
onClick={() => wsRef.current && requestAux(wsRef.current)}
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>
<Button variant="secondary" size="sm" onClick={() => wsRef.current && requestAux(wsRef.current)}>
<Hand size={15} strokeWidth={2} />
{djQueue.includes(userId ?? -1) ? 'Queued' : 'Request aux'}
</Button>
)}
</div>
<form onSubmit={handleSend} className="flex gap-2">
<input
value={text}
onChange={(e) => setText(e.target.value)}
placeholder="Say something…"
// 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>
<Input value={text} onChange={(e) => setText(e.target.value)} placeholder="Say something…" />
<Button size="icon" aria-label="Send">
<Send size={17} strokeWidth={2} />
</Button>
</form>
</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";
@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 { Rss } from 'lucide-react'
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 { getCurrentUserId } from '../api/jwt'
export function Channels() {
const userId = getCurrentUserId()
const [channels, setChannels] = useState<Channel[]>([])
const [loading, setLoading] = useState(true)
const [followerCounts, setFollowerCounts] = useState<Record<number, number>>({})
const [followedIds, setFollowedIds] = useState<Set<number>>(new Set())
const [newName, setNewName] = useState('')
......@@ -13,6 +19,7 @@ export function Channels() {
async function refresh() {
const list = await listChannels()
setChannels(list)
setLoading(false)
const counts: Record<number, number> = {}
await Promise.all(
list.map(async (c) => {
......@@ -51,22 +58,25 @@ export function Channels() {
return (
<Layout title="Channels">
<form onSubmit={handleCreate} className="mb-6 flex gap-2">
<input
value={newName}
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>
<Input value={newName} onChange={(e) => setNewName(e.target.value)} placeholder="New channel name" />
<Button type="submit">Create</Button>
</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">
{channels.map((channel) => (
<li
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">
<p className="truncate font-medium text-white">{channel.name}</p>
......@@ -75,16 +85,17 @@ export function Channels() {
</p>
</div>
{channel.owner_id !== userId && (
<button
<Button
variant={followedIds.has(channel.id) ? 'secondary' : 'primary'}
size="sm"
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'}
</button>
</Button>
)}
</li>
))}
{channels.length === 0 && <p className="text-neutral-500">No channels yet.</p>}
</ul>
</Layout>
)
......
import { useEffect, useState } from 'react'
import { Ear, Heart, Music2, X } from 'lucide-react'
import { Layout } from '../components/Layout'
import { getDiscoveryHistory, listen, swipe, type DiscoveredSong } from '../api/discovery'
import { SkeletonRow } from '../components/ui/Skeleton'
import { EmptyState } from '../components/ui/EmptyState'
export function Discovery() {
const [history, setHistory] = useState<DiscoveredSong[]>([])
const [loading, setLoading] = useState(true)
const [busy, setBusy] = useState(false)
const [message, setMessage] = useState<string | null>(null)
function refresh() {
getDiscoveryHistory().then((res) => setHistory(res.history))
getDiscoveryHistory()
.then((res) => setHistory(res.history))
.finally(() => setLoading(false))
}
useEffect(refresh, [])
......@@ -38,28 +44,41 @@ export function Discovery() {
return (
<Layout title="Discovery">
<div className="mb-6 rounded-xl border border-dashed border-neutral-700 p-6 text-center">
<p className="mb-3 text-sm text-neutral-400">Drop a short clip of what's playing to identify it</p>
<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">
<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
type="file"
accept="audio/*"
disabled={busy}
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>}
</div>
{busy && <span className="text-xs text-neutral-500">Listening…</span>}
</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">
Last 24 hours
</h2>
<ul className="divide-y divide-neutral-800">
<h2 className="mb-3 text-xs font-medium uppercase tracking-wider text-neutral-500">Last 24 hours</h2>
{loading && (
<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) => (
<li key={song.id} className="flex items-center gap-4 py-3">
{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">
<p className="truncate font-medium text-white">{song.title}</p>
......@@ -67,15 +86,21 @@ export function Discovery() {
</div>
<button
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
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>
</li>
))}
......
import { useEffect, useRef, useState } from 'react'
import { Music2, Pause, Play } from 'lucide-react'
import { getLibrary, type LibrarySong } from '../api/library'
import { fetchStreamUrl } from '../api/stream'
import { ApiError } from '../api/client'
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() {
const [songs, setSongs] = useState<LibrarySong[]>([])
......@@ -54,20 +58,26 @@ export function Library() {
<Layout title="Library">
<audio ref={audioRef} onEnded={() => setPlayingId(null)} className="hidden" />
{loading && <p className="text-neutral-500">Loading…</p>}
{error && <p className="text-red-400">{error}</p>}
{loading && (
<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 && (
<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) => (
<li key={song.id} className="flex items-center gap-4 py-3">
{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 className="min-w-0 flex-1">
......@@ -77,13 +87,21 @@ export function Library() {
{song.album ? ` · ${song.album}` : ''}
</p>
</div>
<button
<Button
variant="secondary"
size="icon"
onClick={() => handlePlay(song)}
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'}
</button>
{streamLoading === song.id ? (
<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>
))}
</ul>
......
import { useEffect, useRef, useState } from 'react'
import { AlertCircle, Music2, Sparkles, X } from 'lucide-react'
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'
const STAGES: RemixStatus['status'][] = ['queued', 'planning', 'separating', 'mixing', 'mastering', 'tagging', 'done']
......@@ -18,6 +21,10 @@ export function Remix() {
}
}, [])
function removeFile(index: number) {
setFiles((f) => f.filter((_, i) => i !== index))
}
async function handleSubmit(e: React.FormEvent) {
e.preventDefault()
if (files.length === 0 || !prompt.trim()) return
......@@ -44,35 +51,64 @@ export function Remix() {
return (
<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,
Demucs does the stem separation.
</p>
<form onSubmit={handleSubmit} className="space-y-4">
<input
type="file"
accept="audio/*"
multiple
onChange={(e) => setFiles(Array.from(e.target.files ?? []).slice(0, 5))}
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"
/>
<textarea
<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">
<Music2 size={22} strokeWidth={1.5} className="text-neutral-500" />
<span className="text-sm text-neutral-400">Choose up to 5 audio files</span>
<input
type="file"
accept="audio/*"
multiple
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}
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-base text-white placeholder-neutral-500 outline-none focus:border-emerald-500"
/>
<button
disabled={submitting || files.length === 0 || !prompt.trim()}
className="min-h-[44px] rounded-lg bg-emerald-500 px-5 font-medium text-neutral-950 transition hover:bg-emerald-400 disabled:opacity-40"
>
<Button type="submit" disabled={submitting || files.length === 0 || !prompt.trim()} className="w-full">
<Sparkles size={16} strokeWidth={2} />
{submitting ? 'Starting…' : 'Create Remix'}
</button>
</Button>
</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 && (
<div className="mt-6 rounded-xl border border-neutral-800 bg-neutral-900 p-4">
......@@ -80,7 +116,7 @@ export function Remix() {
{STAGES.slice(0, -1).map((stage, i) => (
<div
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>
......
import { useEffect, useState } from 'react'
import { ChevronRight, Radio } from 'lucide-react'
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 { RoomView } from '../components/RoomView'
export function Rooms() {
const [rooms, setRooms] = useState<LiveRoom[]>([])
const [loading, setLoading] = useState(true)
const [newRoomName, setNewRoomName] = useState('')
const [activeRoomId, setActiveRoomId] = useState<number | null>(null)
function refresh() {
getActiveRooms().then(setRooms)
getActiveRooms()
.then(setRooms)
.finally(() => setLoading(false))
}
useEffect(refresh, [])
......@@ -30,30 +37,39 @@ export function Rooms() {
return (
<Layout title="Pass-the-Aux Rooms">
<form onSubmit={handleCreate} className="mb-6 flex gap-2">
<input
<Input
value={newRoomName}
onChange={(e) => setNewRoomName(e.target.value)}
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">
Start
</button>
<Button type="submit">Start</Button>
</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">
{rooms.map((room) => (
<li key={room.id}>
<button
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>
<span className="text-xs text-neutral-500">DJ #{room.dj_id}</span>
<div className="flex items-center gap-3">
<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>
</li>
))}
{rooms.length === 0 && <p className="text-neutral-500">No active rooms right now.</p>}
</ul>
</Layout>
)
......
import { useState } from 'react'
import { UploadCloud } from 'lucide-react'
import { Layout } from '../components/Layout'
import { Button } from '../components/ui/Button'
import { uploadDirect, type TagResponse } from '../api/music'
export function Upload() {
......@@ -25,26 +27,27 @@ export function Upload() {
return (
<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
added to your library.
</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
type="file"
accept="audio/*"
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
onClick={handleUpload}
disabled={!file || busy}
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>
</div>
</label>
<Button onClick={handleUpload} disabled={!file || busy} className="mt-4 w-full">
{busy ? 'Identifying & tagging…' : 'Upload'}
</Button>
{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