mastoradio-fork/src/components/Queue.svelte

56 lines
1.3 KiB
Svelte
Raw Normal View History

2020-01-13 14:39:22 +01:00
<div>
2020-01-20 04:49:38 +01:00
<h6>PLAY NEXT</h6>
2020-02-14 16:48:49 +01:00
2020-01-20 04:49:38 +01:00
{#if $next}
2020-02-14 16:48:49 +01:00
<div class="entry" on:click={() => select($next)}>
2020-02-15 23:12:53 +01:00
<div class="title">{$next.title}</div>
2020-02-17 01:23:35 +01:00
<div class="user">shared by {$next.referer.username} <DistanceDate date={$next.date} /></div>
2020-01-20 04:49:38 +01:00
</div>
2020-02-18 19:18:46 +01:00
{:else}
NO NEXT TRACK
2020-01-20 04:49:38 +01:00
{/if}
2020-02-18 19:18:46 +01:00
2020-01-20 04:49:38 +01:00
{#if $enqueueing}
2020-02-18 19:18:46 +01:00
ENQUEING
2020-01-20 04:49:38 +01:00
{/if}
<h6>HISTORY</h6>
2020-01-13 14:39:22 +01:00
2020-02-15 23:12:53 +01:00
{#each history as track}
2020-02-14 16:48:49 +01:00
<div class="entry" class:active={track === $current} on:click={() => select(track)}>
2020-02-15 23:12:53 +01:00
<div class>{track.title}</div>
2020-02-17 01:23:35 +01:00
<div class>shared by {track.referer.username} <DistanceDate date={track.date} /></div>
2020-01-13 14:39:22 +01:00
</div>
{/each}
</div>
<script>
import { getContext } from 'svelte'
2020-02-17 01:23:35 +01:00
import DistanceDate from '/components/DistanceDate.svelte'
2020-01-13 14:39:22 +01:00
const current = getContext('current')
const enqueueing = getContext('enqueueing')
const next = getContext('next')
const queue = getContext('queue')
const select = getContext('select')
2020-02-14 16:48:49 +01:00
$: history = $queue.filter(x => x !== $next).reverse()
2020-01-13 14:39:22 +01:00
</script>
<style>
.entry {
2020-01-20 04:49:38 +01:00
padding: 1em 2em;
2020-02-14 16:48:49 +01:00
cursor: pointer;
2020-01-13 14:39:22 +01:00
}
.entry.active {
background-color: plum;
}
2020-02-14 16:48:49 +01:00
.entry.active::before {
content: "▶️";
}
2020-01-13 14:39:22 +01:00
</style>