Add src/lib/actions/pressable.ts and clickOutside.ts (Svelte actions; role/tabindex stay static in markup for SSR accessibility, the action only adds click + Enter/Space) and src/lib/toggle.svelte.ts (createToggle), used by playlists.svelte.ts and queuePanel.svelte.ts. format.ts: adds plural(n, one, many); migrates the repo's 15 manual pluralizations, unifying them to lowercase (visible diff in Playlists, Home, liked, Explore). player.svelte.ts: adds toQueueItem, isQueueCurrent, playAllOrToggle, playShuffled; renames addToQueue -> playNextItem (the old name was misleading: it inserts next, not at the end). Migrates the 5 places that repeated the isCurrentQueue/playAll pattern (album, playlist, liked, mix, Home). Simplifies liked.svelte.ts and recentlyPlayed.ts with object spread instead of rebuilding every field by hand. navigation.svelte.ts: adds searchHref (migrates the duplicated buildHref from TopBar and Explore) and appNavLinks (added; its adoption in Sidebar/TabsBar is left for a later pass, as noted there). menus.svelte.ts: createTrackMenu() replaces the manual context-menu state (contextMenu + contextMenuStateFor + addToQueue) in Home, Explore and Mix. Deliberately left pending: removing tracks.ts's TrackTarget wrapper and its 8 accessors is deferred — it's the riskiest change in the plan, touches types across Home/Explore/Mix/menus, and couldn't be visually verified without Docker this session. Verified with npm run check/build.
90 lines
2.9 KiB
Svelte
90 lines
2.9 KiB
Svelte
<script lang="ts">
|
|
import { player, toQueueItems, isQueueCurrent, playAllOrToggle } from '$lib/player/player.svelte';
|
|
import Page from '$lib/components/ui/Page.svelte';
|
|
import Modal from '$lib/components/ui/Modal.svelte';
|
|
import Alert from '$lib/components/ui/Alert.svelte';
|
|
import AlbumForm from '$lib/components/ui/AlbumForm.svelte';
|
|
import Button from '$lib/components/ui/Button.svelte';
|
|
import AlbumHeader from './components/AlbumHeader.svelte';
|
|
import AlbumTrackTable from './components/AlbumTrackTable.svelte';
|
|
import LibraryPicker from './components/LibraryPicker.svelte';
|
|
|
|
let { data, form } = $props();
|
|
|
|
const album = $derived(data.album);
|
|
const tracks = $derived(data.tracks);
|
|
const library = $derived(data.library);
|
|
const isOwner = $derived(data.isOwner);
|
|
|
|
let editing = $state(false);
|
|
let confirmingDelete = $state(false);
|
|
|
|
const isCurrentQueue = $derived(isQueueCurrent(tracks));
|
|
|
|
function playAll() {
|
|
playAllOrToggle(toQueueItems(tracks));
|
|
}
|
|
</script>
|
|
|
|
<svelte:head>
|
|
<title>{album.title}</title>
|
|
<meta name="description" content="Álbum {album.title}." />
|
|
</svelte:head>
|
|
|
|
<Page>
|
|
<AlbumHeader
|
|
title={album.title}
|
|
description={album.description ?? undefined}
|
|
releaseYear={album.releaseYear === null ? undefined : Number(album.releaseYear)}
|
|
trackIds={tracks.map((track) => track.id)}
|
|
coverUrl="/api/albums/{album.id}/cover?size=large"
|
|
playing={isCurrentQueue && player.playing}
|
|
{isOwner}
|
|
onPlayAll={playAll}
|
|
onEdit={() => (editing = true)}
|
|
onDelete={() => (confirmingDelete = true)}
|
|
/>
|
|
|
|
{#if form?.message}
|
|
<Alert tone="danger" class="mt-6">{form.message}</Alert>
|
|
{/if}
|
|
|
|
{#if tracks.length > 0}
|
|
<AlbumTrackTable {tracks} {isOwner} />
|
|
{/if}
|
|
|
|
{#if isOwner && library.length > 0}
|
|
<LibraryPicker {library} />
|
|
{/if}
|
|
</Page>
|
|
|
|
<Modal open={editing} onClose={() => (editing = false)} title="Editar álbum">
|
|
<AlbumForm
|
|
action="?/edit"
|
|
initialTitle={album.title}
|
|
initialDescription={album.description ?? ''}
|
|
initialReleaseYear={album.releaseYear === null ? undefined : Number(album.releaseYear)}
|
|
coverFallbackUrl="/api/albums/{album.id}/cover?size=medium"
|
|
formMessage={form?.message}
|
|
submitLabel="Guardar"
|
|
submittingLabel="Guardando…"
|
|
onCancel={() => (editing = false)}
|
|
onSuccess={() => (editing = false)}
|
|
/>
|
|
</Modal>
|
|
|
|
<Modal open={confirmingDelete} onClose={() => (confirmingDelete = false)} maxWidth="max-w-sm">
|
|
<h2 class="text-lg font-semibold tracking-tight text-fg">
|
|
¿Eliminar «{album.title}»?
|
|
</h2>
|
|
<p class="mt-2.5 text-sm leading-[1.65] text-fg-2">
|
|
Esta acción no se puede deshacer. Las canciones que contiene seguirán en tu biblioteca.
|
|
</p>
|
|
<div class="mt-6 flex items-center justify-end gap-3">
|
|
<Button variant="secondary" onclick={() => (confirmingDelete = false)}>Cancelar</Button>
|
|
<form method="POST" action="?/delete">
|
|
<Button type="submit" variant="danger">Eliminar</Button>
|
|
</form>
|
|
</div>
|
|
</Modal>
|