shared playlists: a follow with news says so through a toast, and a follower's rows keep the owner's catalog ids
This commit is contained in:
1 parent
594a33a302
commit
8285b97cbe
5 files changed
+320
-5
No files matched your search
@@ -0,0 +1,123 @@
|
||||
<script>
|
||||
// A playlist this device follows has news. The follow poll runs every
|
||||
// ten minutes without a word, and its Inbox card is only on the Inbox,
|
||||
// so the owner's new tracks would otherwise arrive in silence — the
|
||||
// same gap the proposal toast closes for the board. Same slot, pill and
|
||||
// motion; like that toast, several playlists inside the window count up
|
||||
// in one pill rather than stacking.
|
||||
import Icon from "./Icon.svelte";
|
||||
import { followNewsToast } from "../lib/state.svelte.js";
|
||||
|
||||
const HOLD_MS = 4200;
|
||||
const LEAVE_MS = 280;
|
||||
|
||||
const line = $derived.by(() => {
|
||||
const t = followNewsToast;
|
||||
const tracks = (n) => `${n} new ${n === 1 ? "track" : "tracks"}`;
|
||||
if (t.count > 1) return { lead: `${t.count} playlists you follow`, rest: " have new tracks" };
|
||||
if (t.added) return { lead: t.name, rest: `: ${tracks(t.added)} since you imported it${t.removed ? ` · ${t.removed} removed` : ""}` };
|
||||
return { lead: t.name, rest: `: the owner removed ${t.removed} ${t.removed === 1 ? "track" : "tracks"}` };
|
||||
});
|
||||
|
||||
let shown = $state(false);
|
||||
let leaving = $state(false);
|
||||
let holdTimer = 0;
|
||||
let leaveTimer = 0;
|
||||
|
||||
$effect(() => {
|
||||
const seq = followNewsToast.seq;
|
||||
if (!seq) return;
|
||||
clearTimeout(holdTimer);
|
||||
clearTimeout(leaveTimer);
|
||||
leaving = false;
|
||||
shown = true;
|
||||
holdTimer = setTimeout(() => {
|
||||
leaving = true;
|
||||
leaveTimer = setTimeout(() => {
|
||||
shown = false;
|
||||
leaving = false;
|
||||
}, LEAVE_MS);
|
||||
}, HOLD_MS);
|
||||
return () => {
|
||||
clearTimeout(holdTimer);
|
||||
clearTimeout(leaveTimer);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if shown}
|
||||
<div class="layer" aria-live="polite">
|
||||
<div class="toast" class:leaving>
|
||||
<span class="mark"><Icon name="playlist" size={14} /></span>
|
||||
<span class="text"><b>{line.lead}</b>{line.rest}</span>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
/* The shared toast slot — UploadToast's geometry verbatim. */
|
||||
.layer {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: calc(var(--player-height, 62px) + 8px + 26px);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
z-index: 80;
|
||||
pointer-events: none;
|
||||
}
|
||||
.toast {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
max-width: min(70vw, 560px);
|
||||
padding: 9px 16px;
|
||||
border-radius: 99px;
|
||||
background: rgba(22, 23, 28, 0.94);
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
backdrop-filter: blur(14px);
|
||||
-webkit-backdrop-filter: blur(14px);
|
||||
box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55);
|
||||
font-size: 12.5px;
|
||||
font-weight: 700;
|
||||
color: #fff;
|
||||
animation: toast-in 340ms cubic-bezier(0.22, 1, 0.36, 1) both;
|
||||
}
|
||||
.toast.leaving {
|
||||
animation: toast-out 260ms ease both;
|
||||
}
|
||||
@keyframes toast-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(16px) scale(0.95);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
@keyframes toast-out {
|
||||
to {
|
||||
opacity: 0;
|
||||
transform: translateY(12px) scale(0.97);
|
||||
}
|
||||
}
|
||||
.mark {
|
||||
display: inline-flex;
|
||||
color: var(--accent);
|
||||
}
|
||||
.text {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
b {
|
||||
font-weight: 800;
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.toast,
|
||||
.toast.leaving {
|
||||
animation-duration: 1ms;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user