Skip to content

Commit ed4b352

Browse files
committed
improve Queue page
1 parent 9f5787f commit ed4b352

2 files changed

Lines changed: 105 additions & 55 deletions

File tree

‎src/lib/components/ListTrack.svelte‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,10 @@
237237
ondrop={onDrop}
238238
ondragend={onDragEnd}
239239
>
240-
<div class="flex min-w-0 items-center gap-3">
241-
<span class="text-on-surface-variant w-4 shrink-0 text-right">{index}</span>
240+
<div class="flex min-w-0 items-center gap-4">
241+
<span class="text-on-surface-variant w-8 shrink-0 text-right text-sm tabular-nums"
242+
>{index}</span
243+
>
242244
{#if showThumbnail}
243245
{#if track.image}
244246
{#await OPFS.getImageUrl(track.image as string) then imageUrl}

‎src/lib/components/Queue.svelte‎

Lines changed: 101 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -82,61 +82,109 @@
8282
}
8383
</script>
8484

85-
<div
86-
class="bg-secondary-container fixed inset-0 bottom-24 left-0 overflow-y-auto p-4 md:bottom-30 md:left-23 md:p-6"
87-
>
88-
<div class="flex flex-col gap-6">
89-
<h1 class="text-on-surface text-2xl font-bold">Queue</h1>
90-
<div class="bg-surface-container rounded-xl">
91-
<ul class="divide-outline-variant divide-y">
92-
{#each itemsCache as item, index (item.id)}
93-
<li
94-
animate:flip={{ duration: 300, easing: cubicOut }}
95-
class={$queueState.currentIndex === index ? 'bg-primary-container/30' : ''}
85+
<div class="bg-surface fixed inset-0 bottom-24 left-0 overflow-y-auto md:bottom-30 md:left-23">
86+
<div class="flex h-full flex-col">
87+
<div class="bg-surface-container-high/80 sticky top-0 z-10 backdrop-blur-md">
88+
<div class="flex items-center gap-4 p-4 md:p-6">
89+
<div class="bg-primary-container flex h-10 w-10 items-center justify-center rounded-full">
90+
<svg
91+
xmlns="http://www.w3.org/2000/svg"
92+
width="20"
93+
height="20"
94+
viewBox="0 0 24 24"
95+
class="text-on-primary-container"
9696
>
97-
<ListTrack
98-
track={item}
99-
index={index + 1}
100-
trackNo={item.trackNumber}
101-
showThumbnail={true}
102-
showDropIndicator={dropIndex === index + 1}
103-
onRemove={() => removeQueueItem(index)}
104-
draggable={canDrag}
105-
playbackContext={itemsCache}
106-
playbackSource={$queueState.source}
107-
onDragStart={(e) => {
108-
if (!canDrag) return;
109-
dragIndex = index;
110-
dropIndex = index + 1;
111-
e.dataTransfer?.setData('text/plain', String(index));
112-
e.dataTransfer?.setDragImage(e.currentTarget as Element, 16, 16);
113-
}}
114-
onDragOver={(e) => {
115-
if (!canDrag) return;
116-
e.preventDefault();
117-
e.dataTransfer && (e.dataTransfer.dropEffect = 'move');
118-
dropIndex = index + 1;
119-
}}
120-
onDrop={(e) => {
121-
if (!canDrag) return;
122-
e.preventDefault();
123-
const fromIndex = dragIndex ?? Number(e.dataTransfer?.getData('text/plain'));
124-
const targetIndex = index;
125-
dragIndex = null;
126-
dropIndex = null;
127-
if (Number.isFinite(fromIndex)) {
128-
const adjustedTarget = fromIndex < targetIndex ? targetIndex - 1 : targetIndex;
129-
moveQueueItem(fromIndex, Math.max(0, adjustedTarget));
130-
}
131-
}}
132-
onDragEnd={() => {
133-
dragIndex = null;
134-
dropIndex = null;
135-
}}
97+
<path
98+
fill="currentColor"
99+
d="M14 6H4c-.55 0-1 .45-1 1s.45 1 1 1h10c.55 0 1-.45 1-1s-.45-1-1-1m0 4H4c-.55 0-1 .45-1 1s.45 1 1 1h10c.55 0 1-.45 1-1s-.45-1-1-1M4 16h6c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1M19 6c-1.1 0-2 .9-2 2v6.18c-.31-.11-.65-.18-1-.18c-1.84 0-3.28 1.64-2.95 3.54c.21 1.21 1.2 2.2 2.41 2.41c1.9.33 3.54-1.11 3.54-2.95V8h2c.55 0 1-.45 1-1s-.45-1-1-1z"
136100
/>
137-
</li>
138-
{/each}
139-
</ul>
101+
</svg>
102+
</div>
103+
<div class="flex flex-col">
104+
<h1 class="queue-title">Queue</h1>
105+
<p class="text-on-surface-variant text-sm">
106+
{itemsCache.length}
107+
{itemsCache.length === 1 ? 'track' : 'tracks'}
108+
</p>
109+
</div>
110+
</div>
111+
</div>
112+
113+
<div class="flex-1 p-4 pt-2 md:px-6 md:pb-6">
114+
<div class="bg-surface-container rounded-2xl shadow-sm">
115+
<ul class="divide-outline-variant/50 divide-y">
116+
{#each itemsCache as item, index (item.id)}
117+
<li
118+
animate:flip={{ duration: 300, easing: cubicOut }}
119+
class={$queueState.currentIndex === index ? 'bg-primary-container/30' : ''}
120+
>
121+
<ListTrack
122+
track={item}
123+
index={index + 1}
124+
trackNo={item.trackNumber}
125+
showThumbnail={true}
126+
showDropIndicator={dropIndex === index + 1}
127+
onRemove={() => removeQueueItem(index)}
128+
draggable={canDrag}
129+
playbackContext={itemsCache}
130+
playbackSource={$queueState.source}
131+
onDragStart={(e) => {
132+
if (!canDrag) return;
133+
dragIndex = index;
134+
dropIndex = index + 1;
135+
e.dataTransfer?.setData('text/plain', String(index));
136+
e.dataTransfer?.setDragImage(e.currentTarget as Element, 16, 16);
137+
}}
138+
onDragOver={(e) => {
139+
if (!canDrag) return;
140+
e.preventDefault();
141+
e.dataTransfer && (e.dataTransfer.dropEffect = 'move');
142+
dropIndex = index + 1;
143+
}}
144+
onDrop={(e) => {
145+
if (!canDrag) return;
146+
e.preventDefault();
147+
const fromIndex = dragIndex ?? Number(e.dataTransfer?.getData('text/plain'));
148+
const targetIndex = index;
149+
dragIndex = null;
150+
dropIndex = null;
151+
if (Number.isFinite(fromIndex)) {
152+
const adjustedTarget = fromIndex < targetIndex ? targetIndex - 1 : targetIndex;
153+
moveQueueItem(fromIndex, Math.max(0, adjustedTarget));
154+
}
155+
}}
156+
onDragEnd={() => {
157+
dragIndex = null;
158+
dropIndex = null;
159+
}}
160+
/>
161+
</li>
162+
{/each}
163+
</ul>
164+
</div>
140165
</div>
141166
</div>
142167
</div>
168+
169+
<style>
170+
.queue-title {
171+
color: var(--color-secondary);
172+
font-size: 20px;
173+
font-family: 'Roboto Flex', sans-serif;
174+
font-weight: 700;
175+
font-style: normal;
176+
line-height: 24px;
177+
font-variation-settings:
178+
'slnt' 0,
179+
'wdth' 115,
180+
'GRAD' 50,
181+
'XOPQ' 96,
182+
'XTRA' 468,
183+
'YOPQ' 75,
184+
'YTAS' 750,
185+
'YTDE' -203,
186+
'YTFI' 728,
187+
'YTLC' 514,
188+
'YTUC' 712;
189+
}
190+
</style>

0 commit comments

Comments
 (0)