Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect, useState } from 'react';
import { ConnectScreen } from './components/ConnectScreen';
import { DedupeScreen } from './components/DedupeScreen';
import { Loading } from './components/Loading';
import { PlaylistPicker, type Mode } from './components/PlaylistPicker';
import { SwipeScreen } from './components/SwipeScreen';
import { createHistoryStore } from './core/historyStore';
Expand Down Expand Up @@ -101,7 +102,11 @@ export function App() {

switch (screen.name) {
case 'loading':
return <main className="center muted">Connecting to Spotify…</main>;
return (
<main className="center">
<Loading>Connecting to Spotify…</Loading>
</main>
);
case 'connect':
return <ConnectScreen clientIdMissing={!CLIENT_ID} error={screen.error} onConnect={() => void auth.login()} />;
case 'picker':
Expand Down
8 changes: 7 additions & 1 deletion src/components/DedupeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useSnapshot } from '../hooks/useSnapshot';
import type { SpotifyApi } from '../spotify/api';
import { AuthError, describeError } from '../spotify/errors';
import { HistoryPanel } from './HistoryPanel';
import { Loading } from './Loading';
import { Toast } from './Toast';

interface Props {
Expand Down Expand Up @@ -76,7 +77,12 @@ export function DedupeScreen(props: Props) {
</main>
);
}
if (!loaded) return <main className="center muted">Loading songs…</main>;
if (!loaded)
return (
<main className="center">
<Loading>Loading songs…</Loading>
</main>
);
return (
<DedupeView
key={loaded.runId}
Expand Down
14 changes: 14 additions & 0 deletions src/components/Loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/** Bouncing equalizer bars above a status message while we wait on Spotify. */
export function Loading({ children }: { children: string }) {
return (
<div className="loading" role="status">
<span className="eq" aria-hidden="true">
<span />
<span />
<span />
<span />
</span>
{children}
</div>
);
}
3 changes: 2 additions & 1 deletion src/components/PlaylistPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';
import { editablePlaylists, LIKED_SONGS_ID, type PlaylistSummary } from '../core/playlists';
import type { SpotifyApi } from '../spotify/api';
import { AuthError, describeError } from '../spotify/errors';
import { Loading } from './Loading';

export type Mode = 'swipe' | 'dedupe';

Expand Down Expand Up @@ -84,7 +85,7 @@ export function PlaylistPicker({ api, mode, onModeChange, onPick, onAuthLost, on
{error} <button onClick={() => setAttempt((n) => n + 1)}>Retry</button>
</p>
)}
{!error && !playlists && <p className="muted">Loading your playlists…</p>}
{!error && !playlists && <Loading>Loading your playlists…</Loading>}
{playlists?.length === 0 && <p className="muted">You don't own or collaborate on any playlists yet.</p>}
{playlists && (
<div className="grid">
Expand Down
8 changes: 7 additions & 1 deletion src/components/SwipeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { AuthError, describeError } from '../spotify/errors';
import type { WebPlayer } from '../spotify/player';
import { DoneScreen } from './DoneScreen';
import { HistoryPanel } from './HistoryPanel';
import { Loading } from './Loading';
import { PlayerControls } from './PlayerControls';
import { SwipeCard, type SwipeDirection } from './SwipeCard';
import { Toast } from './Toast';
Expand Down Expand Up @@ -63,7 +64,12 @@ export function SwipeScreen(props: Props) {
</main>
);
}
if (!loaded) return <main className="center muted">Loading songs…</main>;
if (!loaded)
return (
<main className="center">
<Loading>Loading songs…</Loading>
</main>
);
return <SwipeView {...props} controller={loaded.controller} sessionId={loaded.sessionId} />;
}

Expand Down
16 changes: 16 additions & 0 deletions src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ button.link:hover { color: var(--text); }
.error { color: var(--red); }
.center { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; padding: 1rem; text-align: center; }
.row { display: flex; gap: 0.75rem; justify-content: center; }
.loading { display: flex; flex-direction: column; align-items: center; gap: 0.9rem; padding: 1.5rem 0; color: var(--muted); }
.eq { display: flex; align-items: flex-end; gap: 4px; height: 28px; }
.eq span { width: 6px; height: 100%; border-radius: 3px; background: var(--green); transform-origin: bottom; animation: eq 1s ease-in-out infinite; }
.eq span:nth-child(2) { animation-duration: 0.8s; animation-delay: -0.4s; }
.eq span:nth-child(3) { animation-duration: 1.1s; animation-delay: -0.2s; }
.eq span:nth-child(4) { animation-duration: 0.9s; animation-delay: -0.6s; }
@keyframes eq {
0%, 100% { transform: scaleY(0.3); }
50% { transform: scaleY(1); }
}
@media (prefers-reduced-motion: reduce) {
.eq span { animation: none; transform: scaleY(0.5); }
.eq span:nth-child(2) { transform: scaleY(0.9); }
.eq span:nth-child(3) { transform: scaleY(0.4); }
.eq span:nth-child(4) { transform: scaleY(0.7); }
}

/* Playlist picker */
.picker { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }
Expand Down
Loading