feat(player): restyle the floating media bar as liquid glass
Continuous Integration / build_web (push) Failing after 1s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped
Continuous Integration / build_web (push) Failing after 1s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped
- cover-tinted translucent surface with a specular rim, grain and glow - centered transport dock and right-hand control capsule - adaptive accent colour, glass cover treatment and shared artwork between the bar and the full player
This commit is contained in:
1 parent
72909fd3b2
commit
94decd674c
7 files changed
+695
-451
No files matched your search
@@ -1,499 +1,589 @@
|
||||
$art-size: 48px;
|
||||
/* Floating glass media bar — 2026 "liquid glass" treatment:
|
||||
translucent saturated blur, cover-tinted ambient light, a thin specular rim
|
||||
and an almost invisible grain layer so the surface reads as material rather
|
||||
than as a flat translucent box. */
|
||||
|
||||
/* The full audio player is a route; keep the floating bar in the DOM until
|
||||
the view transition has captured the old frame, then hide it. */
|
||||
html.player-full-open .audio-player {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.audio-player {
|
||||
--player-accent: #{$clr-accent-default};
|
||||
--player-base: #1b0f2e;
|
||||
--player-deep: #09040f;
|
||||
|
||||
position: fixed;
|
||||
bottom: 0.75rem;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
width: min(1100px, calc(100% - 1.5rem));
|
||||
height: 80px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0.9rem;
|
||||
margin: 0 auto;
|
||||
width: min(1460px, calc(100% - 2rem));
|
||||
height: 84px;
|
||||
box-sizing: border-box;
|
||||
z-index: 100;
|
||||
isolation: isolate;
|
||||
overflow: hidden;
|
||||
|
||||
display: grid;
|
||||
// Equal side columns keep the transport truly centred
|
||||
grid-template-columns: minmax(0, 1fr) minmax(0, 540px) minmax(0, 1fr);
|
||||
grid-template-columns:
|
||||
minmax(0, 1fr)
|
||||
minmax(320px, 560px)
|
||||
minmax(0, 1fr);
|
||||
align-items: center;
|
||||
gap: 1.5rem;
|
||||
padding: 0 0.75rem 0 1rem;
|
||||
gap: 1.1rem;
|
||||
padding: 0 0.75rem 0 0.85rem;
|
||||
color: #fff;
|
||||
border-radius: 24px;
|
||||
border: 1px solid rgb(255 255 255 / 0.14);
|
||||
|
||||
color: white;
|
||||
// Opaque bar: backdrop-filter over the virtualized grid caused constant
|
||||
// compositing/shifting on WebKit.
|
||||
background: rgb(18 18 24 / 0.98);
|
||||
border: 1px solid rgb(255 255 255 / 0.08);
|
||||
border-radius: 14px;
|
||||
box-shadow: 0 12px 40px rgb(0 0 0 / 0.45);
|
||||
background-color: rgb(14 11 24 / 0.55);
|
||||
background-image:
|
||||
radial-gradient(
|
||||
100% 190% at 0% 50%,
|
||||
rgb(255 255 255 / 0.08),
|
||||
transparent 62%
|
||||
),
|
||||
linear-gradient(
|
||||
120deg,
|
||||
rgb(255 255 255 / 0.11),
|
||||
rgb(255 255 255 / 0.025) 38%,
|
||||
rgb(7 5 14 / 0.38) 100%
|
||||
);
|
||||
background-image:
|
||||
radial-gradient(
|
||||
100% 190% at 0% 50%,
|
||||
color-mix(in srgb, var(--player-accent) 20%, transparent),
|
||||
transparent 62%
|
||||
),
|
||||
radial-gradient(
|
||||
90% 160% at 100% 30%,
|
||||
color-mix(in srgb, var(--player-deep) 42%, transparent),
|
||||
transparent 68%
|
||||
),
|
||||
linear-gradient(
|
||||
120deg,
|
||||
rgb(255 255 255 / 0.11),
|
||||
rgb(255 255 255 / 0.025) 38%,
|
||||
rgb(7 5 14 / 0.38) 100%
|
||||
);
|
||||
-webkit-backdrop-filter: blur(24px) saturate(170%) brightness(1.06);
|
||||
backdrop-filter: blur(24px) saturate(170%) brightness(1.06);
|
||||
box-shadow:
|
||||
0 28px 70px rgb(0 0 0 / 0.55),
|
||||
0 6px 18px rgb(0 0 0 / 0.35),
|
||||
inset 0 1px 0 rgb(255 255 255 / 0.18),
|
||||
inset 0 -1px 0 rgb(0 0 0 / 0.22);
|
||||
box-shadow:
|
||||
0 28px 70px rgb(0 0 0 / 0.55),
|
||||
0 6px 18px rgb(0 0 0 / 0.35),
|
||||
0 0 55px color-mix(in srgb, var(--player-accent) 13%, transparent),
|
||||
inset 0 1px 0 rgb(255 255 255 / 0.18),
|
||||
inset 0 -1px 0 rgb(0 0 0 / 0.22);
|
||||
|
||||
will-change: transform, opacity;
|
||||
transform-origin: 50% 100%;
|
||||
|
||||
/* Grain, kept below the content. */
|
||||
&::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 0;
|
||||
border-radius: inherit;
|
||||
pointer-events: none;
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
|
||||
background-size: 140px 140px;
|
||||
opacity: 0.035;
|
||||
mix-blend-mode: soft-light;
|
||||
}
|
||||
|
||||
/* Specular gradient rim. */
|
||||
&::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 1;
|
||||
border-radius: inherit;
|
||||
padding: 1px;
|
||||
pointer-events: none;
|
||||
background: linear-gradient(
|
||||
135deg,
|
||||
rgb(255 255 255 / 0.45),
|
||||
rgb(255 255 255 / 0.06) 30%,
|
||||
rgb(255 255 255 / 0.02) 62%,
|
||||
rgb(255 255 255 / 0.25)
|
||||
);
|
||||
-webkit-mask:
|
||||
linear-gradient(#000 0 0) content-box,
|
||||
linear-gradient(#000 0 0);
|
||||
-webkit-mask-composite: xor;
|
||||
mask:
|
||||
linear-gradient(#000 0 0) content-box,
|
||||
linear-gradient(#000 0 0);
|
||||
mask-composite: exclude;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
> * {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
}
|
||||
}
|
||||
|
||||
.media-bar {
|
||||
&-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.8rem;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
max-width: 380px;
|
||||
}
|
||||
|
||||
&-cover {
|
||||
position: relative;
|
||||
width: 58px;
|
||||
height: 58px;
|
||||
flex: 0 0 58px;
|
||||
padding: 0;
|
||||
border: 1px solid rgb(255 255 255 / 0.16);
|
||||
border-radius: 16px;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgb(255 255 255 / 0.08);
|
||||
color: rgb(255 255 255 / 0.55);
|
||||
cursor: pointer;
|
||||
box-shadow:
|
||||
0 8px 22px rgb(0 0 0 / 0.45),
|
||||
inset 0 0 0 1px rgb(255 255 255 / 0.06);
|
||||
box-shadow:
|
||||
0 8px 22px rgb(0 0 0 / 0.45),
|
||||
0 0 22px color-mix(in srgb, var(--player-accent) 22%, transparent),
|
||||
inset 0 0 0 1px rgb(255 255 255 / 0.06);
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
object-fit: cover;
|
||||
transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
|
||||
}
|
||||
|
||||
&::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
border-radius: inherit;
|
||||
pointer-events: none;
|
||||
background: linear-gradient(
|
||||
180deg,
|
||||
rgb(255 255 255 / 0.2),
|
||||
transparent 34%,
|
||||
rgb(0 0 0 / 0.2)
|
||||
);
|
||||
opacity: 0.55;
|
||||
}
|
||||
|
||||
&:hover img,
|
||||
&:focus-visible img {
|
||||
transform: scale(1.06);
|
||||
}
|
||||
|
||||
.material-symbols-rounded {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
&-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
gap: 3px;
|
||||
}
|
||||
|
||||
> .MuiIconButton-root {
|
||||
flex-shrink: 0;
|
||||
color: rgb(255 255 255 / 0.75);
|
||||
.material-symbols-rounded {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
}
|
||||
&-title {
|
||||
font-size: 0.92rem !important;
|
||||
font-weight: 650 !important;
|
||||
line-height: 1.2 !important;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
cursor: pointer;
|
||||
text-shadow: 0 1px 10px rgb(0 0 0 / 0.25);
|
||||
|
||||
&-text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&-title {
|
||||
all: unset;
|
||||
cursor: pointer;
|
||||
font-weight: 600 !important;
|
||||
line-height: 1.25 !important;
|
||||
// Wrap long titles onto a second line before truncating
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
overflow: hidden;
|
||||
overflow-wrap: anywhere;
|
||||
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
&-artist {
|
||||
opacity: 0.6;
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
text-decoration: underline;
|
||||
text-decoration-color: rgb(255 255 255 / 0.35);
|
||||
text-underline-offset: 3px;
|
||||
}
|
||||
}
|
||||
|
||||
&-image {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
z-index: 1;
|
||||
&-subtitle {
|
||||
font-size: 0.72rem !important;
|
||||
line-height: 1.3 !important;
|
||||
opacity: 0.55;
|
||||
letter-spacing: 0.01em;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
&-container {
|
||||
all: unset;
|
||||
position: relative;
|
||||
flex-shrink: 0;
|
||||
width: $art-size;
|
||||
height: $art-size;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
background: rgb(255 255 255 / 0.08);
|
||||
&-more {
|
||||
flex-shrink: 0;
|
||||
color: rgb(255 255 255 / 0.55) !important;
|
||||
transition:
|
||||
color 0.15s ease,
|
||||
background-color 0.15s ease;
|
||||
|
||||
&:hover .audio-player-image-expand,
|
||||
&:focus-visible .audio-player-image-expand {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
&-icon,
|
||||
&-expand {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
&-icon {
|
||||
font-size: 1.5rem !important;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
// "Open player" affordance shown over the art on hover
|
||||
&-expand {
|
||||
z-index: 2;
|
||||
inset: 0;
|
||||
transform: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgb(0 0 0 / 0.5);
|
||||
opacity: 0;
|
||||
transition: opacity 0.15s ease;
|
||||
&:hover {
|
||||
color: #fff !important;
|
||||
background: rgb(255 255 255 / 0.08) !important;
|
||||
}
|
||||
}
|
||||
|
||||
// Transport on top, compact seek row underneath
|
||||
&-center {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 1px;
|
||||
}
|
||||
|
||||
.player-controls {
|
||||
gap: 0.5rem !important;
|
||||
&-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
align-self: center;
|
||||
gap: 0.05rem;
|
||||
padding: 3px;
|
||||
border-radius: 999px;
|
||||
background: rgb(255 255 255 / 0.045);
|
||||
border: 1px solid rgb(255 255 255 / 0.07);
|
||||
box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.08);
|
||||
|
||||
.MuiFab-root {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
min-height: 36px;
|
||||
box-shadow: none;
|
||||
.MuiIconButton-root {
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
border-radius: 50%;
|
||||
color: rgb(255 255 255 / 0.68);
|
||||
transition:
|
||||
color 0.15s ease,
|
||||
background-color 0.15s ease,
|
||||
transform 0.15s ease;
|
||||
|
||||
.material-symbols-rounded {
|
||||
font-size: 1.6rem !important;
|
||||
}
|
||||
&:hover {
|
||||
color: #fff;
|
||||
background: rgb(255 255 255 / 0.09);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
&.active {
|
||||
color: var(--player-accent);
|
||||
background: color-mix(
|
||||
in srgb,
|
||||
var(--player-accent) 13%,
|
||||
transparent
|
||||
);
|
||||
}
|
||||
|
||||
.material-symbols-rounded {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&-play {
|
||||
width: 44px !important;
|
||||
height: 44px !important;
|
||||
margin: 0 0.3rem;
|
||||
background: #fff !important;
|
||||
color: #100a1b !important;
|
||||
box-shadow:
|
||||
0 8px 24px rgb(0 0 0 / 0.45),
|
||||
0 0 0 1px rgb(255 255 255 / 0.25);
|
||||
box-shadow:
|
||||
0 8px 24px rgb(0 0 0 / 0.45),
|
||||
0 0 0 1px rgb(255 255 255 / 0.25),
|
||||
0 0 26px color-mix(in srgb, var(--player-accent) 24%, transparent);
|
||||
transition:
|
||||
transform 0.16s ease,
|
||||
box-shadow 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
background: #fff !important;
|
||||
transform: scale(1.06);
|
||||
box-shadow:
|
||||
0 10px 28px rgb(0 0 0 / 0.5),
|
||||
0 0 0 1px rgb(255 255 255 / 0.35),
|
||||
0 0 34px color-mix(
|
||||
in srgb,
|
||||
var(--player-accent) 34%,
|
||||
transparent
|
||||
);
|
||||
}
|
||||
|
||||
.material-symbols-rounded {
|
||||
font-size: 1.55rem !important;
|
||||
font-variation-settings: "FILL" 1;
|
||||
}
|
||||
}
|
||||
|
||||
&-progress {
|
||||
gap: 0.6rem !important;
|
||||
|
||||
.MuiTypography-root {
|
||||
min-width: 2.75em !important;
|
||||
font-size: 0.7rem;
|
||||
opacity: 0.6 !important;
|
||||
}
|
||||
flex: 1;
|
||||
min-width: 140px;
|
||||
|
||||
.MuiSlider-root {
|
||||
padding: 8px 0;
|
||||
padding: 7px 0;
|
||||
color: var(--player-accent);
|
||||
}
|
||||
.MuiSlider-thumb {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
opacity: 0;
|
||||
transition: opacity 0.15s ease;
|
||||
}
|
||||
&:hover .MuiSlider-thumb,
|
||||
.MuiSlider-root.Mui-active .MuiSlider-thumb {
|
||||
|
||||
.MuiSlider-rail {
|
||||
height: 4px;
|
||||
border-radius: 999px;
|
||||
background: rgb(255 255 255 / 0.13);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.MuiSlider-track {
|
||||
height: 4px;
|
||||
border: 0;
|
||||
border-radius: 999px;
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
rgb(255 255 255 / 0.95),
|
||||
var(--player-accent)
|
||||
);
|
||||
box-shadow: 0 0 12px
|
||||
color-mix(in srgb, var(--player-accent) 45%, transparent);
|
||||
}
|
||||
|
||||
.MuiSlider-thumb {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
background: #fff;
|
||||
box-shadow:
|
||||
0 0 0 4px color-mix(
|
||||
in srgb,
|
||||
var(--player-accent) 16%,
|
||||
transparent
|
||||
),
|
||||
0 2px 8px rgb(0 0 0 / 0.5);
|
||||
transition:
|
||||
transform 0.15s ease,
|
||||
box-shadow 0.2s ease;
|
||||
|
||||
&:hover,
|
||||
&.Mui-focusVisible {
|
||||
transform: scale(1.15);
|
||||
box-shadow:
|
||||
0 0 0 6px color-mix(
|
||||
in srgb,
|
||||
var(--player-accent) 20%,
|
||||
transparent
|
||||
),
|
||||
0 2px 10px rgb(0 0 0 / 0.55);
|
||||
}
|
||||
}
|
||||
|
||||
.MuiTypography-root {
|
||||
min-width: 2.6em !important;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.66rem;
|
||||
opacity: 0.5 !important;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
}
|
||||
|
||||
&-actions {
|
||||
&-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 0.25rem;
|
||||
min-width: 0;
|
||||
gap: 0.05rem;
|
||||
flex-shrink: 0;
|
||||
padding: 3px 4px;
|
||||
border-radius: 999px;
|
||||
background: rgb(255 255 255 / 0.035);
|
||||
border: 1px solid rgb(255 255 255 / 0.055);
|
||||
box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06);
|
||||
|
||||
.MuiIconButton-root {
|
||||
color: rgb(255 255 255 / 0.75);
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
border-radius: 50%;
|
||||
color: rgb(255 255 255 / 0.62);
|
||||
transition:
|
||||
color 0.15s ease,
|
||||
background-color 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
color: white;
|
||||
color: #fff;
|
||||
background: rgb(255 255 255 / 0.08);
|
||||
}
|
||||
|
||||
.material-symbols-rounded {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&-volume {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
width: 92px !important;
|
||||
margin: 0 0.25rem 0 0 !important;
|
||||
color: var(--player-accent) !important;
|
||||
|
||||
// Secondary control: neutral and compact
|
||||
.MuiSlider-root {
|
||||
width: 5.5rem !important;
|
||||
color: rgb(255 255 255 / 0.85);
|
||||
.MuiSlider-rail {
|
||||
height: 3px;
|
||||
border-radius: 999px;
|
||||
background: rgb(255 255 255 / 0.14);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.audio-player-volume,
|
||||
.audio-player-progress .MuiTypography-root {
|
||||
display: none;
|
||||
.MuiSlider-track {
|
||||
height: 3px;
|
||||
border: 0;
|
||||
border-radius: 999px;
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
rgb(255 255 255 / 0.9),
|
||||
var(--player-accent)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
grid-template-columns: minmax(0, 1fr) auto auto;
|
||||
gap: 0.5rem;
|
||||
bottom: 0.5rem;
|
||||
width: calc(100% - 1rem);
|
||||
height: 64px;
|
||||
|
||||
.audio-player-center .player-controls > :not(:has(.MuiFab-root)),
|
||||
.audio-player-progress {
|
||||
display: none;
|
||||
}
|
||||
.audio-player-actions > :not(:last-child) {
|
||||
display: none;
|
||||
.MuiSlider-thumb {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
background: #fff;
|
||||
box-shadow: 0 0 0 3px
|
||||
color-mix(in srgb, var(--player-accent) 16%, transparent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Unified, minimal media bar (local playback + remote device control). */
|
||||
.audio-player {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: min(1440px, calc(100% - 1.5rem));
|
||||
height: 82px;
|
||||
gap: 1.25rem;
|
||||
padding: 0 0.9rem;
|
||||
background: #0b0816;
|
||||
border: 1px solid rgb(255 255 255 / 0.08);
|
||||
border-radius: 18px;
|
||||
@supports not (
|
||||
(backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))
|
||||
) {
|
||||
.audio-player {
|
||||
background: rgb(14 11 24 / 0.96);
|
||||
}
|
||||
|
||||
.media-bar {
|
||||
&-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
width: 30%;
|
||||
min-width: 220px;
|
||||
max-width: 360px;
|
||||
}
|
||||
.audio-player::before {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
&-cover {
|
||||
width: 52px;
|
||||
height: 52px;
|
||||
flex: 0 0 52px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
background: rgb(255 255 255 / 0.06);
|
||||
color: rgb(255 255 255 / 0.5);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
@media (prefers-reduced-transparency: reduce) {
|
||||
.audio-player {
|
||||
background: rgb(14 11 24 / 0.96);
|
||||
-webkit-backdrop-filter: none;
|
||||
backdrop-filter: none;
|
||||
}
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
.audio-player::before {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
&-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
@media (max-width: 1100px) {
|
||||
.audio-player {
|
||||
gap: 0.8rem;
|
||||
}
|
||||
|
||||
&-title {
|
||||
font-weight: 600 !important;
|
||||
line-height: 1.2 !important;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
cursor: pointer;
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
.media-bar-left {
|
||||
max-width: 320px;
|
||||
}
|
||||
|
||||
&-subtitle {
|
||||
opacity: 0.55;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
&-more {
|
||||
flex-shrink: 0;
|
||||
color: rgb(255 255 255 / 0.6);
|
||||
}
|
||||
|
||||
&-center {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1.25rem;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.15rem;
|
||||
flex-shrink: 0;
|
||||
|
||||
.MuiIconButton-root {
|
||||
color: rgb(255 255 255 / 0.7);
|
||||
transition: color 0.15s ease, transform 0.15s ease;
|
||||
&:hover {
|
||||
color: #fff;
|
||||
background: rgb(255 255 255 / 0.06);
|
||||
}
|
||||
&.active {
|
||||
color: $clr-accent-default;
|
||||
}
|
||||
.material-symbols-rounded {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&-play {
|
||||
width: 46px !important;
|
||||
height: 46px !important;
|
||||
margin: 0 0.5rem;
|
||||
background: #fff !important;
|
||||
border: 0;
|
||||
color: #0b0417 !important;
|
||||
box-shadow: 0 6px 18px rgb(0 0 0 / 0.35);
|
||||
transition: transform 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
background: #fff !important;
|
||||
transform: scale(1.04);
|
||||
}
|
||||
.material-symbols-rounded {
|
||||
font-size: 1.6rem !important;
|
||||
}
|
||||
}
|
||||
|
||||
&-progress {
|
||||
flex: 1;
|
||||
min-width: 140px;
|
||||
|
||||
.MuiSlider-root {
|
||||
padding: 10px 0;
|
||||
color: $clr-accent-default;
|
||||
}
|
||||
.MuiSlider-rail {
|
||||
background: rgb(255 255 255 / 0.16);
|
||||
opacity: 1;
|
||||
}
|
||||
.MuiSlider-track {
|
||||
border: 0;
|
||||
}
|
||||
.MuiSlider-thumb {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
background: #fff;
|
||||
box-shadow: none;
|
||||
&:hover,
|
||||
&.Mui-focusVisible {
|
||||
box-shadow: 0 0 0 6px rgb(124 199 255 / 0.16);
|
||||
}
|
||||
}
|
||||
.MuiTypography-root {
|
||||
opacity: 0.55;
|
||||
font-variant-numeric: tabular-nums;
|
||||
font-weight: 400;
|
||||
}
|
||||
}
|
||||
|
||||
&-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.1rem;
|
||||
flex-shrink: 0;
|
||||
|
||||
.MuiIconButton-root {
|
||||
color: rgb(255 255 255 / 0.65);
|
||||
&:hover {
|
||||
color: #fff;
|
||||
background: rgb(255 255 255 / 0.06);
|
||||
}
|
||||
.material-symbols-rounded {
|
||||
font-size: 1.3rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&-volume {
|
||||
width: 84px !important;
|
||||
margin: 0 0.35rem 0 0 !important;
|
||||
color: $clr-accent-default !important;
|
||||
|
||||
.MuiSlider-rail {
|
||||
background: rgb(255 255 255 / 0.16);
|
||||
opacity: 1;
|
||||
}
|
||||
.MuiSlider-thumb {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
background: #fff;
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
.media-bar-volume {
|
||||
width: 72px !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.audio-player {
|
||||
.media-bar-left {
|
||||
min-width: 160px;
|
||||
}
|
||||
.media-bar-volume,
|
||||
.media-bar-right .MuiSlider-root {
|
||||
display: none;
|
||||
}
|
||||
width: calc(100% - 1.5rem);
|
||||
}
|
||||
|
||||
.media-bar-left {
|
||||
min-width: 180px;
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.media-bar-volume,
|
||||
.media-bar-right .MuiSlider-root {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.audio-player {
|
||||
display: flex;
|
||||
width: calc(100% - 1rem);
|
||||
height: 66px;
|
||||
bottom: 0.5rem;
|
||||
height: 68px;
|
||||
bottom: 0.55rem;
|
||||
padding: 0 0.55rem;
|
||||
gap: 0.5rem;
|
||||
border-radius: 14px;
|
||||
box-sizing: border-box;
|
||||
gap: 0.45rem;
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
.media-bar-left {
|
||||
width: auto;
|
||||
min-width: 0;
|
||||
max-width: none;
|
||||
flex: 1 1 auto;
|
||||
gap: 0.55rem;
|
||||
}
|
||||
.media-bar-left {
|
||||
width: auto;
|
||||
min-width: 0;
|
||||
max-width: none;
|
||||
flex: 1 1 auto;
|
||||
gap: 0.55rem;
|
||||
}
|
||||
|
||||
.media-bar-cover {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
flex: 0 0 44px;
|
||||
}
|
||||
.media-bar-cover {
|
||||
width: 46px;
|
||||
height: 46px;
|
||||
flex: 0 0 46px;
|
||||
border-radius: 13px;
|
||||
}
|
||||
|
||||
.media-bar-more {
|
||||
.media-bar-more {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.media-bar-center {
|
||||
flex: 0 0 auto;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.media-bar-controls {
|
||||
padding: 2px;
|
||||
|
||||
> :first-child,
|
||||
> :last-child {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.media-bar-center {
|
||||
flex: 0 0 auto;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.media-bar-controls {
|
||||
gap: 0;
|
||||
|
||||
> :first-child,
|
||||
> :last-child {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.MuiIconButton-root {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
}
|
||||
}
|
||||
|
||||
.media-bar-play {
|
||||
width: 40px !important;
|
||||
height: 40px !important;
|
||||
margin: 0 0.1rem;
|
||||
}
|
||||
|
||||
.media-bar-progress,
|
||||
.media-bar-right {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.media-bar-title {
|
||||
font-size: 0.9rem;
|
||||
.MuiIconButton-root {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
}
|
||||
}
|
||||
|
||||
.media-bar-play {
|
||||
width: 40px !important;
|
||||
height: 40px !important;
|
||||
margin: 0 0.15rem;
|
||||
}
|
||||
|
||||
.media-bar-progress,
|
||||
.media-bar-right {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.media-bar-title {
|
||||
font-size: 0.86rem !important;
|
||||
}
|
||||
|
||||
.media-bar-subtitle {
|
||||
font-size: 0.67rem !important;
|
||||
}
|
||||
}
|
||||
@@ -18,13 +18,23 @@ import Tooltip from "@mui/material/Tooltip";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useLocation, useNavigate } from "@tanstack/react-router";
|
||||
import { AnimatePresence, motion } from "motion/react";
|
||||
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
||||
import { useSnackbar } from "notistack";
|
||||
import React, { type SyntheticEvent, useEffect, useRef, useState } from "react";
|
||||
import React, {
|
||||
type SyntheticEvent,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import QueueButton from "@/components/buttons/queueButton";
|
||||
import { secToTicks, ticksToSec } from "@/utils/date/time";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import { getCoverPalette } from "@/utils/methods/coverColor";
|
||||
import getImageUrlsApi, {
|
||||
getPlayerCoverUrl,
|
||||
} from "@/utils/methods/getImageUrlsApi";
|
||||
import { startInstantMix } from "@/utils/methods/instantMix";
|
||||
import { rememberAudioPlayerReturn } from "@/utils/methods/audioPlayerReturn";
|
||||
import {
|
||||
playOnSession,
|
||||
queueStartingWith,
|
||||
@@ -57,6 +67,8 @@ const AudioPlayer = () => {
|
||||
const user = useCentralStore((s) => s.currentUser);
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const reduceMotion = useReducedMotion();
|
||||
const previousPathRef = useRef(location.pathname);
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
const openRemoteDialog = useRemoteControlStore((s) => s.openDialog);
|
||||
|
||||
@@ -163,14 +175,15 @@ const AudioPlayer = () => {
|
||||
? `${artistNames.join(", ")} · ${remoteDevice}`
|
||||
: `Идёт на ${remoteDevice}`
|
||||
: artistNames.join(", ") || activeItem?.Album || "";
|
||||
const coverUrl =
|
||||
api && activeItem?.Id
|
||||
? getImageUrlsApi(api).getItemImageUrlById(
|
||||
activeItem.AlbumId ?? activeItem.Id,
|
||||
"Primary",
|
||||
{ quality: 85, fillHeight: 120, fillWidth: 120 },
|
||||
)
|
||||
: undefined;
|
||||
const coverUrl = getPlayerCoverUrl(api, activeItem, 600);
|
||||
const fullCoverUrl = getPlayerCoverUrl(api, item, 600);
|
||||
const palette = useMemo(() => getCoverPalette(activeItem), [activeItem]);
|
||||
useEffect(() => {
|
||||
if (!fullCoverUrl) return;
|
||||
const image = new Image();
|
||||
image.src = fullCoverUrl;
|
||||
void image.decode?.().catch(() => undefined);
|
||||
}, [fullCoverUrl]);
|
||||
const isPlaying = remote
|
||||
? !remote.PlayState?.IsPaused
|
||||
: playing;
|
||||
@@ -218,6 +231,22 @@ const AudioPlayer = () => {
|
||||
location.pathname === "/player" ||
|
||||
location.pathname === "/player/audio" ||
|
||||
location.pathname === "/remote";
|
||||
|
||||
// The audio route keeps the floating bar mounted (hidden by the
|
||||
// `player-full-open` class) until the view transition has captured the old
|
||||
// frame. Other full-screen pages can remove it immediately.
|
||||
const hideBarForFullPage =
|
||||
isFullPlayer && location.pathname !== "/player/audio";
|
||||
|
||||
// Returning from the full audio player: the bar must already be in its
|
||||
// final place when the view-transition snapshot is taken, otherwise the
|
||||
// cover would morph towards an off-screen/transparent target.
|
||||
const cameFromFullPlayer =
|
||||
previousPathRef.current === "/player/audio" && !isFullPlayer;
|
||||
useEffect(() => {
|
||||
previousPathRef.current = location.pathname;
|
||||
}, [location.pathname]);
|
||||
|
||||
useEffect(() => {
|
||||
const visible = barVisible && !isFullPlayer;
|
||||
document.body.classList.toggle("has-player-bar", visible);
|
||||
@@ -354,6 +383,7 @@ const AudioPlayer = () => {
|
||||
if (remote) {
|
||||
openRemoteDialog(remote.NowPlayingItem);
|
||||
} else {
|
||||
rememberAudioPlayerReturn();
|
||||
navigate({ to: "/player/audio" });
|
||||
}
|
||||
};
|
||||
@@ -576,19 +606,39 @@ const AudioPlayer = () => {
|
||||
/>
|
||||
) : null;
|
||||
|
||||
if (!barVisible && !display) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const bar = (
|
||||
<AnimatePresence mode="sync">
|
||||
<motion.div
|
||||
initial={{ transform: "translate(-50%, 150%)" }}
|
||||
animate={{ transform: "translate(-50%, 0%)" }}
|
||||
exit={{ transform: "translate(-50%, 150%)" }}
|
||||
transition={{ duration: 0.25, ease: "circOut" }}
|
||||
className="audio-player"
|
||||
>
|
||||
<motion.div
|
||||
key="audio-player-bar"
|
||||
initial={
|
||||
reduceMotion || cameFromFullPlayer
|
||||
? false
|
||||
: { opacity: 0, y: 90, scale: 0.96 }
|
||||
}
|
||||
animate={{ opacity: 1, y: 0, scale: 1 }}
|
||||
exit={
|
||||
reduceMotion
|
||||
? { opacity: 0, transition: { duration: 0 } }
|
||||
: {
|
||||
opacity: 0,
|
||||
y: 90,
|
||||
scale: 0.96,
|
||||
transition: { duration: 0.2, ease: [0.4, 0, 1, 1] },
|
||||
}
|
||||
}
|
||||
transition={
|
||||
reduceMotion
|
||||
? { duration: 0 }
|
||||
: { type: "spring", stiffness: 420, damping: 38, mass: 0.9 }
|
||||
}
|
||||
style={
|
||||
{
|
||||
"--player-accent": palette.accent,
|
||||
"--player-base": palette.base,
|
||||
"--player-deep": palette.deep,
|
||||
} as React.CSSProperties
|
||||
}
|
||||
className="audio-player"
|
||||
>
|
||||
<div className="media-bar-left">
|
||||
<button
|
||||
type="button"
|
||||
@@ -850,13 +900,14 @@ const AudioPlayer = () => {
|
||||
</Menu>
|
||||
|
||||
</motion.div>
|
||||
</AnimatePresence>
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
{audioElement}
|
||||
{barVisible && !isFullPlayer && bar}
|
||||
{!hideBarForFullPage && (
|
||||
<AnimatePresence>{barVisible && bar}</AnimatePresence>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -11,9 +11,15 @@ import {
|
||||
Tooltip,
|
||||
} from "@mui/material";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { createFileRoute, Link, useNavigate } from "@tanstack/react-router";
|
||||
import { createFileRoute, Link, useNavigate, useRouter } from "@tanstack/react-router";
|
||||
import { AnimatePresence, motion } from "motion/react";
|
||||
import React, { useEffect, useMemo, useRef, useState } from "react";
|
||||
import React, {
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import CastButton from "@/components/buttons/castButton";
|
||||
import LikeButton from "@/components/buttons/likeButton";
|
||||
import LyricsPanel, {
|
||||
@@ -23,8 +29,11 @@ import PlayerVolume from "@/components/playback/audioPlayer/components/PlayerVol
|
||||
import StatsPanel from "@/components/playback/audioPlayer/components/StatsPanel";
|
||||
import WindowControls from "@/components/windowControls";
|
||||
import { getRuntimeMusic, secToTicks, ticksToSec } from "@/utils/date/time";
|
||||
import { consumeAudioPlayerReturn } from "@/utils/methods/audioPlayerReturn";
|
||||
import { getCoverPalette } from "@/utils/methods/coverColor";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import getImageUrlsApi, {
|
||||
getPlayerCoverUrl,
|
||||
} from "@/utils/methods/getImageUrlsApi";
|
||||
import { getItemQueryOptions } from "@/utils/queries/items";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import {
|
||||
@@ -133,7 +142,7 @@ const CoverArt = ({ src, alt }: { src?: string; alt: string }) => {
|
||||
const [current, setCurrent] = useState<string | undefined>(src);
|
||||
const [previous, setPrevious] = useState<string | undefined>();
|
||||
const currentRef = useRef<string | undefined>(src);
|
||||
const hasSwappedRef = useRef(false);
|
||||
const hasSwappedRef = useRef(true);
|
||||
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -204,6 +213,7 @@ function AudioPlayerRoute() {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const user = useCentralStore((s) => s.currentUser);
|
||||
const navigate = useNavigate();
|
||||
const router = useRouter();
|
||||
const [queue, currentTrack, repeatMode] = useQueue((s) => [
|
||||
s.tracks,
|
||||
s.currentItemIndex,
|
||||
@@ -223,6 +233,15 @@ function AudioPlayerRoute() {
|
||||
const [menuAnchor, setMenuAnchor] = useState<HTMLElement | null>(null);
|
||||
const [statsOpen, setStatsOpen] = useState(false);
|
||||
|
||||
// Hide the floating bar only after this route has committed, so the view
|
||||
// transition still has it in the old frame and can morph its cover.
|
||||
useLayoutEffect(() => {
|
||||
document.documentElement.classList.add("player-full-open");
|
||||
return () => {
|
||||
document.documentElement.classList.remove("player-full-open");
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const player = audioPlayerRef?.current;
|
||||
if (!player) return;
|
||||
@@ -274,14 +293,8 @@ function AudioPlayerRoute() {
|
||||
};
|
||||
|
||||
const imageUrl = useMemo(
|
||||
() =>
|
||||
item?.ImageTags?.Primary
|
||||
? api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(item.Id ?? "", "Primary", {
|
||||
tag: item.ImageTags.Primary,
|
||||
})
|
||||
: undefined,
|
||||
[item?.Id, item?.ImageTags?.Primary, api],
|
||||
() => getPlayerCoverUrl(api, item, 600),
|
||||
[api, item?.Id, item?.AlbumId, item?.ImageTags?.Primary],
|
||||
);
|
||||
|
||||
const coverFor = (track: BaseItemDto) =>
|
||||
@@ -309,6 +322,15 @@ function AudioPlayerRoute() {
|
||||
setPanelOpen(true);
|
||||
};
|
||||
|
||||
const collapsePlayer = () => {
|
||||
const returnTo = consumeAudioPlayerReturn();
|
||||
if (returnTo) {
|
||||
void router.navigate({ href: returnTo });
|
||||
} else {
|
||||
void router.navigate({ to: "/home" });
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
@@ -340,7 +362,7 @@ function AudioPlayerRoute() {
|
||||
<button
|
||||
type="button"
|
||||
className="music-player-collapse"
|
||||
onClick={() => window.history.back()}
|
||||
onClick={collapsePlayer}
|
||||
aria-label="Свернуть плеер"
|
||||
>
|
||||
<span className="material-symbols-rounded">expand_more</span>
|
||||
|
||||
@@ -135,6 +135,29 @@ body {
|
||||
opacity: 0.35;
|
||||
}
|
||||
|
||||
// Shared cover morph between the floating bar and the full player.
|
||||
.media-bar-cover {
|
||||
view-transition-name: player-cover;
|
||||
}
|
||||
|
||||
.music-player-art {
|
||||
view-transition-name: player-cover;
|
||||
}
|
||||
|
||||
@supports (view-transition-name: none) {
|
||||
::view-transition-group(player-cover) {
|
||||
animation-duration: 420ms;
|
||||
animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
|
||||
}
|
||||
|
||||
::view-transition-old(player-cover),
|
||||
::view-transition-new(player-cover) {
|
||||
animation-duration: 420ms;
|
||||
animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
|
||||
mix-blend-mode: normal;
|
||||
}
|
||||
}
|
||||
|
||||
/* Page transitions: a short, soft crossfade with a gentle lift. The whole
|
||||
root is snapshotted, so the app bar and player stay in place visually while
|
||||
the content changes underneath them. */
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
const RETURN_KEY = "blink:audio-player-return";
|
||||
|
||||
/**
|
||||
* The full player is a route, so reconstructing the exact page to return to
|
||||
* keeps the SPA navigation (and its view transition) instead of using
|
||||
* `history.back()`, which TanStack Router does not wrap in a view transition.
|
||||
*/
|
||||
export const rememberAudioPlayerReturn = () => {
|
||||
sessionStorage.setItem(
|
||||
RETURN_KEY,
|
||||
`${window.location.pathname}${window.location.search}${window.location.hash}`,
|
||||
);
|
||||
};
|
||||
|
||||
export const consumeAudioPlayerReturn = () => {
|
||||
const value = sessionStorage.getItem(RETURN_KEY);
|
||||
sessionStorage.removeItem(RETURN_KEY);
|
||||
return value;
|
||||
};
|
||||
@@ -6,9 +6,15 @@ type Palette = {
|
||||
base: string;
|
||||
/** Darker end of the vertical gradient. */
|
||||
deep: string;
|
||||
/** Saturated cover hue used for glass highlights and controls. */
|
||||
accent: string;
|
||||
};
|
||||
|
||||
const FALLBACK: Palette = { base: "hsl(266 32% 22%)", deep: "hsl(266 40% 9%)" };
|
||||
const FALLBACK: Palette = {
|
||||
base: "hsl(266 32% 22%)",
|
||||
deep: "hsl(266 40% 9%)",
|
||||
accent: "hsl(337 96% 64%)",
|
||||
};
|
||||
|
||||
const clamp = (value: number, min: number, max: number) =>
|
||||
Math.min(max, Math.max(min, value));
|
||||
@@ -77,6 +83,11 @@ export const getCoverPalette = (item?: BaseItemDto | null): Palette => {
|
||||
return {
|
||||
base: hsl(h, wallSaturation, wallLightness),
|
||||
deep: hsl(h, wallSaturation, clamp(wallLightness * 0.45, 0.05, 0.12)),
|
||||
accent: hsl(
|
||||
h,
|
||||
clamp(s + 0.4, 0.55, 0.9),
|
||||
clamp(l + 0.28, 0.56, 0.7),
|
||||
),
|
||||
};
|
||||
} catch {
|
||||
return FALLBACK;
|
||||
|
||||
@@ -3,4 +3,32 @@ import { ImageUrlsApi } from "@jellyfin/sdk/lib/utils/api/image-urls-api";
|
||||
|
||||
const getImageUrlsApi = (api: Api) => new ImageUrlsApi(api.configuration);
|
||||
|
||||
export default getImageUrlsApi;
|
||||
type CoverItem = {
|
||||
Id?: string | null;
|
||||
AlbumId?: string | null;
|
||||
ImageTags?: { Primary?: string | null } | null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Shared cover URL for the floating bar and the full player, so the
|
||||
* view-transition morph always blends the same artwork.
|
||||
*/
|
||||
export const getPlayerCoverUrl = (
|
||||
api: Api | undefined,
|
||||
item: CoverItem | null | undefined,
|
||||
size = 600,
|
||||
) => {
|
||||
if (!api || !item?.Id) return undefined;
|
||||
return getImageUrlsApi(api).getItemImageUrlById(
|
||||
item.AlbumId ?? item.Id,
|
||||
"Primary",
|
||||
{
|
||||
quality: 90,
|
||||
fillHeight: size,
|
||||
fillWidth: size,
|
||||
...(item.AlbumId ? {} : { tag: item.ImageTags?.Primary ?? undefined }),
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
export default getImageUrlsApi;
|
||||
Reference in new issue
Block a user