feat(home): cinematic rounded home page with integrated hero
Continuous Integration / build_web (push) Failing after 0s
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 0s
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
Home is now a floating rounded window: an integrated header over full-bleed artwork, a large featured title with actions, and a Trending now rail that switches the hero. Existing home sections continue below in the same frame.
This commit is contained in:
1 parent
affbd00157
commit
d5c1bfac64
9 files changed
+873
-489
No files matched your search
@@ -28,6 +28,8 @@ const HIDDEN_PATHS = [
|
||||
"/settings",
|
||||
"/library",
|
||||
"/search",
|
||||
// The home page draws its own header inside the hero frame.
|
||||
"/home",
|
||||
];
|
||||
|
||||
export const AppBar = () => {
|
||||
|
||||
@@ -1,196 +1,481 @@
|
||||
.carousel {
|
||||
position: relative;
|
||||
overflow: visible;
|
||||
height: 65vh;
|
||||
margin-bottom: 3em;
|
||||
display: grid;
|
||||
grid-template-areas: "main sidebar";
|
||||
grid-template-columns: 1fr 340px;
|
||||
gap: 1.5em;
|
||||
@use "@/styles/variables.scss" as *;
|
||||
|
||||
&-slide-wrapper {
|
||||
grid-area: main;
|
||||
position: relative;
|
||||
height: 100%;
|
||||
min-width: 0;
|
||||
/* Cinematic home hero: full-bleed artwork, integrated type, bottom rail. */
|
||||
.cinema-hero {
|
||||
position: relative;
|
||||
height: calc(100vh - 32px);
|
||||
min-height: 620px;
|
||||
overflow: hidden;
|
||||
isolation: isolate;
|
||||
|
||||
.hero-carousel-slide {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
overflow: hidden;
|
||||
border-radius: 20px;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
&-sidebar {
|
||||
overflow-y: auto;
|
||||
.hero-carousel-background-container {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 0;
|
||||
|
||||
&::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 2;
|
||||
background:
|
||||
linear-gradient(
|
||||
90deg,
|
||||
rgb(6 8 12 / 0.94) 0%,
|
||||
rgb(6 8 12 / 0.72) 28%,
|
||||
rgb(6 8 12 / 0.28) 52%,
|
||||
rgb(6 8 12 / 0) 72%
|
||||
),
|
||||
linear-gradient(
|
||||
0deg,
|
||||
rgb(6 8 12 / 0.96) 0%,
|
||||
rgb(6 8 12 / 0.55) 26%,
|
||||
rgb(6 8 12 / 0) 56%
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
.hero-carousel-background-image {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
@include glass-effect($bg-color: rgba(10, 10, 14, 0.4));
|
||||
border-radius: 24px;
|
||||
grid-area: sidebar;
|
||||
object-fit: cover;
|
||||
object-position: center;
|
||||
|
||||
&.is-poster {
|
||||
filter: blur(42px) saturate(1.5) brightness(0.55);
|
||||
transform: scale(1.25);
|
||||
}
|
||||
}
|
||||
|
||||
.hero-carousel-background-blurhash {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100% !important;
|
||||
height: 100% !important;
|
||||
z-index: 0;
|
||||
filter: blur(40px) saturate(1.4);
|
||||
}
|
||||
|
||||
.hero-carousel-background-icon-container {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 0;
|
||||
background: linear-gradient(135deg, #12141a, #1d2028);
|
||||
|
||||
.material-symbols-rounded {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
font-size: 15em !important;
|
||||
opacity: 0.35;
|
||||
}
|
||||
}
|
||||
|
||||
.hero-carousel-detail {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 3;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 12px;
|
||||
gap: 8px;
|
||||
|
||||
// Ensure programmatic scroll respects padding
|
||||
scroll-padding-block: 24px;
|
||||
justify-content: flex-end;
|
||||
align-items: flex-start;
|
||||
gap: 0.9rem;
|
||||
max-width: none;
|
||||
padding: 0 clamp(2rem, 5vw, 4.5rem) calc(var(--home-trending-space, 200px) + 3rem);
|
||||
background: none;
|
||||
}
|
||||
|
||||
.hero-carousel-label {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
height: 34px;
|
||||
padding: 0 16px;
|
||||
border-radius: 10px;
|
||||
background: rgb(255 255 255 / 0.16);
|
||||
border: 1px solid rgb(255 255 255 / 0.18);
|
||||
backdrop-filter: blur(14px);
|
||||
color: #fff;
|
||||
font-size: 0.86rem;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.01em;
|
||||
}
|
||||
|
||||
.hero-carousel-text {
|
||||
display: block;
|
||||
overflow: visible;
|
||||
margin: 0;
|
||||
max-width: 16ch;
|
||||
font-size: clamp(2.4rem, 4.1vw, 4.4rem) !important;
|
||||
line-height: 0.98 !important;
|
||||
font-weight: 650 !important;
|
||||
letter-spacing: -0.035em;
|
||||
text-shadow: 0 2px 30px rgb(0 0 0 / 0.35);
|
||||
}
|
||||
|
||||
.hero-carousel-info {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.9em !important;
|
||||
margin-top: 0.1em !important;
|
||||
color: rgb(255 255 255 / 0.78);
|
||||
font-size: 0.9rem;
|
||||
text-shadow: 0 1px 2px rgb(0 0 0 / 0.6);
|
||||
|
||||
.MuiTypography-root {
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.MuiChip-root {
|
||||
height: 24px;
|
||||
background: rgb(255 255 255 / 0.14);
|
||||
color: #fff;
|
||||
font-size: 0.75rem;
|
||||
backdrop-filter: blur(8px);
|
||||
}
|
||||
|
||||
.hero-carousel-info-rating {
|
||||
gap: 0.2em;
|
||||
}
|
||||
}
|
||||
|
||||
.hero-carousel-overview {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 4;
|
||||
overflow: hidden;
|
||||
max-width: 34rem;
|
||||
margin: 0.15rem 0 0;
|
||||
color: rgb(255 255 255 / 0.82);
|
||||
font-size: 1rem;
|
||||
line-height: 1.55;
|
||||
text-shadow: 0 1px 3px rgb(0 0 0 / 0.55);
|
||||
}
|
||||
|
||||
.hero-carousel-button-container {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.85rem;
|
||||
width: auto;
|
||||
margin-top: 0.6rem;
|
||||
|
||||
.MuiButton-root {
|
||||
min-height: 50px;
|
||||
padding: 0 24px;
|
||||
border-radius: 999px;
|
||||
text-transform: none;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.01em;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.play-button .MuiButton-root,
|
||||
.MuiButton-contained {
|
||||
background: #f5f5f4;
|
||||
color: #101116;
|
||||
|
||||
&:hover {
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.material-symbols-rounded {
|
||||
color: #101116;
|
||||
}
|
||||
}
|
||||
|
||||
.MuiButton-outlined {
|
||||
border-color: rgb(255 255 255 / 0.34);
|
||||
color: #fff;
|
||||
backdrop-filter: blur(10px);
|
||||
|
||||
&:hover {
|
||||
background: rgb(255 255 255 / 0.1);
|
||||
border-color: rgb(255 255 255 / 0.6);
|
||||
}
|
||||
}
|
||||
|
||||
.MuiIconButton-root {
|
||||
color: rgb(255 255 255 / 0.75);
|
||||
|
||||
&:hover {
|
||||
color: #fff;
|
||||
background: rgb(255 255 255 / 0.1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Big cinematic arrows */
|
||||
.cinema-arrow {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
z-index: 7;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 50%;
|
||||
border: 1px solid rgb(255 255 255 / 0.18);
|
||||
background: rgb(14 16 21 / 0.36);
|
||||
backdrop-filter: blur(14px);
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
transform: translateY(-50%);
|
||||
opacity: 0;
|
||||
transition:
|
||||
opacity 0.2s ease,
|
||||
background-color 0.2s ease,
|
||||
color 0.2s ease;
|
||||
|
||||
&.left {
|
||||
left: 1.25rem;
|
||||
}
|
||||
|
||||
&.right {
|
||||
right: 1.25rem;
|
||||
}
|
||||
|
||||
.material-symbols-rounded {
|
||||
font-size: 1.7rem;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: #f5f5f4;
|
||||
color: #101116;
|
||||
}
|
||||
}
|
||||
|
||||
&:hover .cinema-arrow,
|
||||
&.paused .cinema-arrow {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/* Bottom rail */
|
||||
.cinema-trending {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 6;
|
||||
padding: 2rem clamp(2rem, 5vw, 4.5rem) 1.5rem;
|
||||
background: linear-gradient(
|
||||
0deg,
|
||||
rgb(7 8 12 / 0.98) 0%,
|
||||
rgb(7 8 12 / 0.9) 46%,
|
||||
rgb(7 8 12 / 0) 100%
|
||||
);
|
||||
}
|
||||
|
||||
.cinema-trending-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
margin-bottom: 0.9rem;
|
||||
|
||||
h3 {
|
||||
margin: 0;
|
||||
font-size: 1.1rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
}
|
||||
|
||||
.cinema-dots {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
|
||||
button {
|
||||
width: 26px;
|
||||
height: 3px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 999px;
|
||||
background: rgb(255 255 255 / 0.3);
|
||||
cursor: pointer;
|
||||
transition:
|
||||
background-color 0.2s ease,
|
||||
width 0.2s ease;
|
||||
|
||||
&.active {
|
||||
width: 38px;
|
||||
background: #fff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.cinema-trending-rail {
|
||||
display: flex;
|
||||
gap: 0.75rem;
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
padding-bottom: 2px;
|
||||
scrollbar-width: none;
|
||||
-ms-overflow-style: none;
|
||||
|
||||
// Hide scrollbar but keep functionality
|
||||
scrollbar-width: none;
|
||||
-ms-overflow-style: none;
|
||||
&::-webkit-scrollbar {
|
||||
width: 0;
|
||||
height: 0;
|
||||
display: none;
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
&-button {
|
||||
position: absolute !important;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
z-index: 100;
|
||||
|
||||
&.right {
|
||||
right: 0.5em;
|
||||
}
|
||||
|
||||
&.left {
|
||||
left: 0.5em;
|
||||
}
|
||||
}
|
||||
|
||||
&-ticker{
|
||||
overflow: hidden;
|
||||
height: 72px;
|
||||
display: flex;
|
||||
padding: 8px;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
|
||||
.cinema-trending-card {
|
||||
position: relative;
|
||||
border-radius: 12px; // Slightly smaller radius to work with the bar
|
||||
background: transparent;
|
||||
border: 1px solid transparent;
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: rgba(255, 255, 255, 0.08); // Subtle background
|
||||
|
||||
// Vertical Progress Bar
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
width: 4px;
|
||||
background-color: var(--mui-palette-primary-main, #fff);
|
||||
height: 0%;
|
||||
animation: ticker-v-progress 8s linear;
|
||||
}
|
||||
}
|
||||
|
||||
&-image {
|
||||
height: 56px;
|
||||
width: 100px;
|
||||
flex-shrink: 0;
|
||||
border-radius: 8px;
|
||||
object-fit: cover;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.2);
|
||||
|
||||
&.placeholder {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgb(100 100 100 / 0.1);
|
||||
color: rgb(200 200 200 / 0.7);
|
||||
font-size: 2rem;
|
||||
}
|
||||
}
|
||||
|
||||
& > div {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
min-width: 0; // flexible text truncation
|
||||
padding-left: 4px; // compensate for visual weight of potential bar
|
||||
|
||||
.carousel-ticker-title {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
font-weight: 500; // Slightly lighter
|
||||
font-size: 0.95rem;
|
||||
line-height: 1.2;
|
||||
margin-bottom: 2px;
|
||||
opacity: 0.9;
|
||||
}
|
||||
.carousel-ticker-year {
|
||||
font-size: 0.8rem;
|
||||
opacity: 0.6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Pause progress when carousel is paused
|
||||
&.paused {
|
||||
.carousel-ticker.active::after {
|
||||
animation-play-state: paused;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes ticker-v-progress {
|
||||
from { height: 0%; }
|
||||
to { height: 100%; }
|
||||
}
|
||||
|
||||
&-indicator {
|
||||
aspect-ratio: 1.77777;
|
||||
flex: 0 0 auto;
|
||||
width: clamp(200px, 21vw, 300px);
|
||||
aspect-ratio: 16 / 9;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
border-radius: 2px;
|
||||
padding: 2px;
|
||||
transition: opacity $transition-time-fast;
|
||||
opacity: 0.5;
|
||||
width: auto;
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
&-container {
|
||||
display: flex;
|
||||
gap: 1em;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
&-image {
|
||||
border: 1px solid rgb(255 255 255 / 0.12);
|
||||
border-radius: 12px;
|
||||
background: rgb(255 255 255 / 0.05);
|
||||
cursor: pointer;
|
||||
opacity: 0.72;
|
||||
transition:
|
||||
opacity 0.2s ease,
|
||||
border-color 0.2s ease,
|
||||
transform 0.2s ease;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
border-radius: 4px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
&-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgb(155 155 155 / 0.4);
|
||||
border-radius: 4px;
|
||||
|
||||
&::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: linear-gradient(0deg, rgb(0 0 0 / 0.35), transparent 55%);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
border-color: rgb(255 255 255 / 0.4);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
&.active {
|
||||
opacity: 1;
|
||||
|
||||
.material-symbols-rounded {
|
||||
|
||||
--fill: 1;
|
||||
}
|
||||
border-color: rgb(255 255 255 / 0.7);
|
||||
box-shadow: 0 0 0 1px rgb(255 255 255 / 0.25);
|
||||
}
|
||||
}
|
||||
|
||||
.cinema-trending-chip {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: 10px;
|
||||
z-index: 1;
|
||||
padding: 3px 10px;
|
||||
border-radius: 8px;
|
||||
background: rgb(245 245 244 / 0.9);
|
||||
color: #131419;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 500;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.cinema-trending-placeholder {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
color: rgb(255 255 255 / 0.5);
|
||||
|
||||
.material-symbols-rounded {
|
||||
font-size: 2rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
.carousel-ticker-wrapper {
|
||||
scroll-margin-block: 24px;
|
||||
|
||||
/* Reserve room for the floating player bar so the rail is never covered. */
|
||||
body:has(.audio-player) .cinema-trending {
|
||||
padding-bottom: 116px;
|
||||
}
|
||||
|
||||
/* With the player bar visible the hero has less vertical room, so keep the
|
||||
copy compact instead of pushing it under the header. */
|
||||
body:has(.audio-player) .cinema-hero .hero-carousel-text {
|
||||
font-size: clamp(2.1rem, 3.6vw, 4rem) !important;
|
||||
}
|
||||
|
||||
body:has(.audio-player) .cinema-hero .hero-carousel-overview {
|
||||
-webkit-line-clamp: 3;
|
||||
}
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
.cinema-hero {
|
||||
height: calc(100vh - 32px);
|
||||
min-height: 560px;
|
||||
|
||||
.hero-carousel-detail {
|
||||
padding-left: 2rem;
|
||||
padding-right: 2rem;
|
||||
padding-bottom: calc(var(--home-trending-space, 200px) + 1.5rem);
|
||||
}
|
||||
|
||||
.hero-carousel-text {
|
||||
font-size: 2.6rem !important;
|
||||
max-width: 14ch;
|
||||
}
|
||||
|
||||
.hero-carousel-overview {
|
||||
-webkit-line-clamp: 3;
|
||||
max-width: 30rem;
|
||||
}
|
||||
|
||||
.cinema-trending {
|
||||
padding-left: 2rem;
|
||||
padding-right: 2rem;
|
||||
}
|
||||
|
||||
.cinema-arrow.left {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.cinema-hero {
|
||||
min-height: 520px;
|
||||
|
||||
.hero-carousel-text {
|
||||
font-size: 2.1rem !important;
|
||||
}
|
||||
|
||||
.hero-carousel-info {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.hero-carousel-overview {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.cinema-arrow {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.cinema-trending-card {
|
||||
width: 160px;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,23 @@
|
||||
import React, { useCallback, useEffect, useState } from "react";
|
||||
import type { Api } from "@jellyfin/sdk";
|
||||
|
||||
import { useCarouselStore } from "../../utils/store/carousel";
|
||||
import "./carousel.scss";
|
||||
import {
|
||||
type BaseItemDto,
|
||||
BaseItemKind,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { useCarouselStore } from "../../utils/store/carousel";
|
||||
import "./carousel.scss";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import { resolveItemImage } from "@/utils/methods/itemImages";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import CarouselSlide from "../carouselSlide";
|
||||
import CarouselTickers from "./tickers";
|
||||
|
||||
const AUTOPLAY_MS = 9000;
|
||||
|
||||
// Memoize CarouselSlide to prevent unnecessary re-renders
|
||||
const MemoizedCarouselSlide = React.memo(CarouselSlide);
|
||||
|
||||
/** Sidebar thumbnail: prefer Thumb, fall back to Backdrop/Primary when missing. */
|
||||
const tickerImageUrl = (
|
||||
/** Wide artwork for the trending rail, falling back through the item's images. */
|
||||
const trendingImageUrl = (
|
||||
api: Api,
|
||||
item: BaseItemDto,
|
||||
): string | undefined => {
|
||||
@@ -27,13 +27,19 @@ const tickerImageUrl = (
|
||||
image.itemId,
|
||||
image.imageType,
|
||||
{
|
||||
quality: 90,
|
||||
fillHeight: 360,
|
||||
quality: 85,
|
||||
fillWidth: 480,
|
||||
tag: image.tag,
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
const trendingLabel = (item: BaseItemDto): string => {
|
||||
const genre = item.Genres?.[0];
|
||||
if (genre) return genre.charAt(0).toUpperCase() + genre.slice(1);
|
||||
return item.Type === BaseItemKind.Series ? "Series" : "Movie";
|
||||
};
|
||||
|
||||
const Carousel = ({
|
||||
content,
|
||||
onChange,
|
||||
@@ -43,107 +49,136 @@ const Carousel = ({
|
||||
}) => {
|
||||
const [currentSlide, setCurrentSlide] = useState(0);
|
||||
const [isPaused, setIsPaused] = useState(false);
|
||||
const sidebarRef = React.useRef<HTMLDivElement>(null);
|
||||
const tickerRefs = React.useRef<(HTMLDivElement | null)[]>([]);
|
||||
const currentSlideRef = React.useRef(currentSlide);
|
||||
|
||||
const [setDirection] = useCarouselStore((state) => [state.setDirection]);
|
||||
const api = useApiInContext((s) => s.api);
|
||||
|
||||
const total = content.length;
|
||||
|
||||
useEffect(() => {
|
||||
currentSlideRef.current = currentSlide;
|
||||
}, [currentSlide]);
|
||||
if (currentSlide >= total && total > 0) {
|
||||
setCurrentSlide(total - 1);
|
||||
}
|
||||
}, [currentSlide, total]);
|
||||
|
||||
useEffect(() => {
|
||||
onChange(currentSlide);
|
||||
}, [currentSlide, onChange]);
|
||||
|
||||
// Auto-scroll sidebar to keep active item in view
|
||||
const activeTicker = tickerRefs.current[currentSlide];
|
||||
const sidebar = sidebarRef.current;
|
||||
|
||||
if (activeTicker && sidebar) {
|
||||
const sidebarTop = sidebar.scrollTop;
|
||||
const sidebarBottom = sidebarTop + sidebar.clientHeight;
|
||||
const activeTickerTop = activeTicker.offsetTop;
|
||||
const activeTickerBottom =
|
||||
activeTicker.offsetTop + activeTicker.offsetHeight;
|
||||
|
||||
// If element is below the visible area
|
||||
if (activeTickerBottom > sidebarBottom) {
|
||||
sidebar.scrollTo({
|
||||
top: activeTickerBottom - sidebar.clientHeight + 24, // 24px padding
|
||||
behavior: "smooth",
|
||||
});
|
||||
}
|
||||
// If element is above the visible area
|
||||
else if (activeTickerTop < sidebarTop) {
|
||||
sidebar.scrollTo({
|
||||
top: activeTickerTop - 24, // 24px padding
|
||||
behavior: "smooth",
|
||||
});
|
||||
}
|
||||
}
|
||||
}, [currentSlide, content, onChange]);
|
||||
|
||||
// Autoplay functionality
|
||||
useEffect(() => {
|
||||
if (isPaused || content.length === 0) return;
|
||||
|
||||
const timer = setInterval(() => {
|
||||
setDirection("right");
|
||||
setCurrentSlide((prev) => (prev + 1) % content.length);
|
||||
}, 8000);
|
||||
|
||||
return () => clearInterval(timer);
|
||||
}, [isPaused, content.length, setDirection, currentSlide]);
|
||||
|
||||
const api = useApiInContext((s) => s.api);
|
||||
|
||||
const handleTickerClick = useCallback(
|
||||
const goTo = useCallback(
|
||||
(index: number) => {
|
||||
if (index === currentSlideRef.current) return;
|
||||
setDirection(index > currentSlideRef.current ? "right" : "left");
|
||||
if (index === currentSlide) return;
|
||||
setDirection(index > currentSlide ? "right" : "left");
|
||||
setCurrentSlide(index);
|
||||
},
|
||||
[setDirection],
|
||||
[currentSlide, setDirection],
|
||||
);
|
||||
|
||||
if (!api) return null;
|
||||
const next = useCallback(() => {
|
||||
if (total < 2) return;
|
||||
setDirection("right");
|
||||
setCurrentSlide((prev) => (prev + 1) % total);
|
||||
}, [total, setDirection]);
|
||||
|
||||
const previous = useCallback(() => {
|
||||
if (total < 2) return;
|
||||
setDirection("left");
|
||||
setCurrentSlide((prev) => (prev - 1 + total) % total);
|
||||
}, [total, setDirection]);
|
||||
|
||||
// Autoplay; pauses while the pointer is over the hero.
|
||||
useEffect(() => {
|
||||
if (isPaused || total < 2) return;
|
||||
const timer = window.setInterval(() => {
|
||||
setDirection("right");
|
||||
setCurrentSlide((prev) => (prev + 1) % total);
|
||||
}, AUTOPLAY_MS);
|
||||
return () => window.clearInterval(timer);
|
||||
}, [isPaused, total, setDirection]);
|
||||
|
||||
if (!api || total === 0) return null;
|
||||
|
||||
const currentItem = content[currentSlide];
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`carousel ${isPaused ? "paused" : ""}`}
|
||||
<section
|
||||
className={`cinema-hero ${isPaused ? "paused" : ""}`}
|
||||
aria-roledescription="carousel"
|
||||
aria-label="Featured"
|
||||
onMouseEnter={() => setIsPaused(true)}
|
||||
onMouseLeave={() => setIsPaused(false)}
|
||||
>
|
||||
<div className="hero-carousel-slide-wrapper">
|
||||
<MemoizedCarouselSlide item={content[currentSlide]} />
|
||||
</div>
|
||||
<div className="carousel-sidebar" ref={sidebarRef}>
|
||||
{content.map((item, index) => (
|
||||
<div
|
||||
key={item.Id}
|
||||
ref={(el) => {
|
||||
tickerRefs.current[index] = el;
|
||||
}}
|
||||
className="carousel-ticker-wrapper"
|
||||
<MemoizedCarouselSlide key={currentItem.Id} item={currentItem} />
|
||||
|
||||
{total > 1 && (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
className="cinema-arrow left"
|
||||
onClick={previous}
|
||||
aria-label="Previous"
|
||||
>
|
||||
<CarouselTickers
|
||||
imageUrl={tickerImageUrl(api, item)}
|
||||
isActive={index === currentSlide}
|
||||
itemName={item.Name ?? "Unknown"}
|
||||
itemYear={
|
||||
item.Type === BaseItemKind.Series && item.EndDate
|
||||
? `${item.ProductionYear ?? ""} - ${new Date(item.EndDate).getFullYear().toString()}`
|
||||
: (item.ProductionYear?.toString() ?? "")
|
||||
}
|
||||
onTickerClick={handleTickerClick}
|
||||
index={index}
|
||||
itemType={item.Type as BaseItemKind}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
<span className="material-symbols-rounded">chevron_left</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="cinema-arrow right"
|
||||
onClick={next}
|
||||
aria-label="Next"
|
||||
>
|
||||
<span className="material-symbols-rounded">chevron_right</span>
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
|
||||
<div className="cinema-trending">
|
||||
<div className="cinema-trending-head">
|
||||
<h3>Trending now</h3>
|
||||
{total > 1 && (
|
||||
<div className="cinema-dots">
|
||||
{content.map((item, index) => (
|
||||
<button
|
||||
key={item.Id}
|
||||
type="button"
|
||||
className={index === currentSlide ? "active" : ""}
|
||||
onClick={() => goTo(index)}
|
||||
aria-label={item.Name ?? `Slide ${index + 1}`}
|
||||
aria-current={index === currentSlide}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="cinema-trending-rail">
|
||||
{content.map((item, index) => {
|
||||
const imageUrl = trendingImageUrl(api, item);
|
||||
return (
|
||||
<button
|
||||
key={item.Id}
|
||||
type="button"
|
||||
className={`cinema-trending-card ${
|
||||
index === currentSlide ? "active" : ""
|
||||
}`}
|
||||
onClick={() => goTo(index)}
|
||||
aria-label={item.Name ?? "Featured item"}
|
||||
>
|
||||
{imageUrl ? (
|
||||
<img src={imageUrl} alt="" loading="lazy" />
|
||||
) : (
|
||||
<div className="cinema-trending-placeholder">
|
||||
<span className="material-symbols-rounded">
|
||||
{ item.Type === BaseItemKind.Series ? "tv" : "movie" }
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
<span className="cinema-trending-chip">
|
||||
{trendingLabel(item)}
|
||||
</span>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -137,6 +137,20 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
||||
},
|
||||
}}
|
||||
>
|
||||
<MotionStack
|
||||
custom={animationDirection}
|
||||
variants={textVariants}
|
||||
direction="row"
|
||||
sx={{ alignItems: "center", gap: 1 }}
|
||||
>
|
||||
<span className="hero-carousel-label">
|
||||
{item.UserData?.PlaybackPositionTicks
|
||||
? "Continue watching"
|
||||
: item.Type === BaseItemKind.Series
|
||||
? "New series"
|
||||
: "New movie"}
|
||||
</span>
|
||||
</MotionStack>
|
||||
<MotionTypography
|
||||
custom={animationDirection}
|
||||
variants={textVariants}
|
||||
@@ -146,26 +160,9 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
||||
sx={{
|
||||
fontWeight: 600,
|
||||
overflow: "visible",
|
||||
mb: "5px",
|
||||
}}
|
||||
>
|
||||
{!item.ImageTags?.Logo ? (
|
||||
item.Name
|
||||
) : (
|
||||
<img
|
||||
alt={item.Name ?? "Item"}
|
||||
className="hero-carousel-text-logo"
|
||||
src={`${api?.basePath}/Items/${item.Id}/Images/Logo?quality=90&tag=${item.ImageTags.Logo}`}
|
||||
style={{
|
||||
opacity: 0,
|
||||
transition: "opacity 0.2s",
|
||||
objectFit: "contain",
|
||||
}}
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{item.Name}
|
||||
</MotionTypography>
|
||||
<MotionStack
|
||||
custom={animationDirection}
|
||||
|
||||
@@ -52,6 +52,7 @@ const OverlayScrollbar = () => {
|
||||
document.body.classList.add("has-overlay-scrollbar");
|
||||
|
||||
let frame = 0;
|
||||
let measureTimer = 0;
|
||||
let lastShow = 0;
|
||||
|
||||
const setVisible = (visible: boolean) => {
|
||||
@@ -90,10 +91,12 @@ const OverlayScrollbar = () => {
|
||||
|
||||
// Expensive path: runs on mount and when page/window geometry changes.
|
||||
const measure = () => {
|
||||
// Use the header height rather than its viewport position: the
|
||||
// header scrolls with the page, but the track must stay put.
|
||||
const header = document.querySelector("header");
|
||||
const insetTop = Math.max(
|
||||
0,
|
||||
Math.round(header?.getBoundingClientRect().bottom ?? 0) + 4,
|
||||
Math.round(header?.getBoundingClientRect().height ?? 0) + 6,
|
||||
);
|
||||
const trackHeight = Math.max(0, window.innerHeight - insetTop - 6);
|
||||
const topStyle = `${insetTop}px`;
|
||||
@@ -139,8 +142,19 @@ const OverlayScrollbar = () => {
|
||||
if (frame) return;
|
||||
frame = window.requestAnimationFrame(() => {
|
||||
frame = 0;
|
||||
window.clearTimeout(measureTimer);
|
||||
measure();
|
||||
});
|
||||
// Animation frames stop in an occluded window, but the page can
|
||||
// still grow (route/data changes). Refresh geometry on a timer too.
|
||||
window.clearTimeout(measureTimer);
|
||||
measureTimer = window.setTimeout(() => {
|
||||
if (frame) {
|
||||
window.cancelAnimationFrame(frame);
|
||||
frame = 0;
|
||||
}
|
||||
measure();
|
||||
}, 250);
|
||||
};
|
||||
|
||||
const onScroll = () => {
|
||||
@@ -214,6 +228,7 @@ const OverlayScrollbar = () => {
|
||||
|
||||
return () => {
|
||||
window.clearTimeout(hideTimer.current);
|
||||
window.clearTimeout(measureTimer);
|
||||
if (frame) window.cancelAnimationFrame(frame);
|
||||
scroller.removeEventListener("scroll", onScroll);
|
||||
window.removeEventListener("resize", onResize);
|
||||
|
||||
Reference in new issue
Block a user