From 87d36722aa465c466c7a6b80b04c7191ed3269aa Mon Sep 17 00:00:00 2001 From: XShine555 Date: Tue, 21 Jul 2026 18:50:17 +0200 Subject: [PATCH] refactor(web-player): let TrackTable declare its own columns Every one of the seven tables repeated the same header markup and hand written grid templates, always in the same shape: an optional index, the title, optional desktop-only meta columns, the duration and an optional action. TrackTable now takes that shape as props and builds both grid templates and the headers itself. --- .../src/lib/components/ui/TrackTable.svelte | 47 +++++++++++++++---- .../[id]/components/AlbumTrackTable.svelte | 14 +----- .../[id]/components/LibraryPicker.svelte | 7 +-- .../albums/youtube/[albumId]/+page.svelte | 7 +-- .../src/routes/(app)/library/+page.svelte | 16 +++---- .../src/routes/(app)/mixes/[id]/+page.svelte | 7 +-- .../[id]/components/PlaylistTrackTable.svelte | 13 +---- .../[id]/components/SuggestionsTable.svelte | 7 +-- 8 files changed, 51 insertions(+), 67 deletions(-) diff --git a/web-player/src/lib/components/ui/TrackTable.svelte b/web-player/src/lib/components/ui/TrackTable.svelte index 6f0301b..42d81ed 100644 --- a/web-player/src/lib/components/ui/TrackTable.svelte +++ b/web-player/src/lib/components/ui/TrackTable.svelte @@ -5,6 +5,11 @@ readonly columns: string; readonly columnsMobile: string; } + + export interface TrackMetaColumn { + label: string; + width: string; + } @@ -36,9 +57,19 @@
- {@render headers()} + {#if index} + # + {/if} + Título + {#each meta as column (column.label)} + + {/each} + + {#if action} + + {/if}
{@render children()} diff --git a/web-player/src/routes/(app)/albums/[id]/components/AlbumTrackTable.svelte b/web-player/src/routes/(app)/albums/[id]/components/AlbumTrackTable.svelte index 02a970d..ca611f7 100644 --- a/web-player/src/routes/(app)/albums/[id]/components/AlbumTrackTable.svelte +++ b/web-player/src/routes/(app)/albums/[id]/components/AlbumTrackTable.svelte @@ -30,19 +30,7 @@ } - - {#snippet headers()} - # - Título - - {#if isOwner} - - {/if} - {/snippet} + {#each tracks as track, i (track.id)} - - {#snippet headers()} - Título - - - {/snippet} + {#each library as track, i (track.id)} {data.album.description}

{/if} - - {#snippet headers()} - # - Título - - {/snippet} + {#each tracks as track, i (track.videoId)} (contextMenu = contextMenuStateFor(e, targetFor(i)))}> 0} - {#snippet headers()} - # - Título - - - - - {/snippet} {#each items as track, i (track.id)} {form.message} {/if} - - {#snippet headers()} - # - Título - - {/snippet} + {#each items as item, i (mixItemKey(item))} (contextMenu = contextMenuStateFor(e, targets[i]))}> - - {#snippet headers()} - # - Título - - - - {/snippet} + {#each tracks as track, i (track.id)} - - {#snippet headers()} - Título - - - {/snippet} + {#each suggestions as item, i (idFor(item))} openContextMenu(e, item)}>