feat: add new last media layout
This commit is contained in:
8 files changed
+377
-340
No files matched your search
@@ -1,15 +1,42 @@
|
||||
.carousel {
|
||||
position: relative;
|
||||
height: 64vh;
|
||||
width: calc(100% + 2*$page-margin);
|
||||
left: -$page-margin;
|
||||
margin-bottom: 3.2em;
|
||||
.slider {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
max-width: 35%;
|
||||
right: $page-margin;
|
||||
overflow: hidden;
|
||||
height: 62vh;
|
||||
margin-bottom: 2em;
|
||||
display: grid;
|
||||
grid-template-areas: "main sidebar";
|
||||
grid-template-columns: 1fr 25vw;
|
||||
gap: 1em;
|
||||
|
||||
&-sidebar {
|
||||
overflow-y: auto;
|
||||
height: inherit;
|
||||
background: rgb(0 0 0 / 0.2);
|
||||
border-radius: 20px;
|
||||
border: 1.2px solid rgb(255 255 255 / 0.1);
|
||||
grid-area: sidebar;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
width: 14px;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
margin-block: 1em;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background-color: rgba(255, 255, 255, 0.2);
|
||||
border-radius: 10px;
|
||||
border: 4px solid transparent;
|
||||
background-clip: content-box;
|
||||
|
||||
&:hover {
|
||||
background-color: rgba(255, 255, 255, 0.4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&-button {
|
||||
position: absolute !important;
|
||||
top: 50%;
|
||||
@@ -25,14 +52,46 @@
|
||||
}
|
||||
}
|
||||
|
||||
&-ticker{
|
||||
overflow: hidden;
|
||||
height: 8em;
|
||||
display: flex;
|
||||
// margin-bottom: 1em;
|
||||
padding: 1em;
|
||||
align-items: center;
|
||||
gap: 1em;
|
||||
border-bottom: 1px solid rgb(255 255 255 / 0.1);
|
||||
transition: background $transition-time-fast;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
border: none;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: rgb(0 0 0 / .25);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: rgb(255 255 255 / 0.05);
|
||||
}
|
||||
|
||||
&-image {
|
||||
height: 100%;
|
||||
border-radius: 4px;
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
|
||||
&-indicator {
|
||||
aspect-ratio: 1.77777;
|
||||
overflow: hidden;
|
||||
border-radius: 2px;
|
||||
padding: 2px;
|
||||
transition: opacity $transition-time-fast;
|
||||
opacity: 0.5;
|
||||
width: auto;
|
||||
overflow: hidden;
|
||||
border-radius: 2px;
|
||||
padding: 2px;
|
||||
transition: opacity $transition-time-fast;
|
||||
opacity: 0.5;
|
||||
width: auto;
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
opacity: 0.8;
|
||||
@@ -44,29 +103,29 @@
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
&-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
&-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgb(155 155 155 / 0.4);
|
||||
border-radius: 4px;
|
||||
}
|
||||
&-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
&-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgb(155 155 155 / 0.4);
|
||||
border-radius: 4px;
|
||||
}
|
||||
&.active {
|
||||
opacity: 1;
|
||||
|
||||
.material-symbols-rounded {
|
||||
|
||||
--fill: 1;
|
||||
}
|
||||
}
|
||||
.material-symbols-rounded {
|
||||
|
||||
--fill: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,20 @@
|
||||
import { AnimatePresence, motion } from "motion/react";
|
||||
import type { PanInfo } from "motion/react";
|
||||
import React, { useEffect, useState, useMemo, useCallback } from "react";
|
||||
import type { MouseEvent, PointerEvent } from "react";
|
||||
import { AnimatePresence } from "motion/react";
|
||||
import React, { useCallback, useEffect, useState } from "react";
|
||||
|
||||
import { useCarouselStore } from "../../utils/store/carousel";
|
||||
import "./carousel.scss";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import CarouselSlide from "../carouselSlide";
|
||||
|
||||
import {
|
||||
type BaseItemDto,
|
||||
BaseItemKind,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import Slider from "../Slider";
|
||||
import { getTypeIcon } from "../utils/iconsCollection";
|
||||
|
||||
const swipeConfidenceThreshold = 8000;
|
||||
const swipePower = (offset: number, velocity: number) => {
|
||||
return Math.abs(offset) * velocity;
|
||||
};
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import CarouselSlide from "../carouselSlide";
|
||||
import CarouselTickers from "./tickers";
|
||||
|
||||
// Memoize CarouselSlide to prevent unnecessary re-renders
|
||||
const MemoizedCarouselSlide = React.memo(CarouselSlide);
|
||||
|
||||
// Memoize Slider to prevent unnecessary re-renders
|
||||
const MemoizedSlider = React.memo(Slider);
|
||||
|
||||
const Carousel = ({
|
||||
content,
|
||||
onChange,
|
||||
@@ -41,112 +32,50 @@ const Carousel = ({
|
||||
|
||||
const api = useApiInContext((s) => s.api);
|
||||
|
||||
// Memoize the content mapping
|
||||
const sliderContent = useMemo(() => {
|
||||
return content.map((item, index) => {
|
||||
return (
|
||||
<motion.div
|
||||
className={
|
||||
currentSlide === index
|
||||
? "carousel-indicator active"
|
||||
: "carousel-indicator"
|
||||
}
|
||||
layout
|
||||
initial={{
|
||||
height: "4.6em",
|
||||
}}
|
||||
whileHover={{
|
||||
height: "5.5em",
|
||||
}}
|
||||
transition={{
|
||||
duration: 0.05,
|
||||
}}
|
||||
key={item.Id}
|
||||
onClick={() => {
|
||||
if (currentSlide > index) {
|
||||
setDirection("left");
|
||||
} else if (currentSlide <= index) {
|
||||
setDirection("right");
|
||||
}
|
||||
setCurrentSlide(index);
|
||||
}}
|
||||
>
|
||||
{item.ImageTags?.Thumb ? (
|
||||
<img
|
||||
src={
|
||||
api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
item.Id ?? "",
|
||||
"Thumb",
|
||||
{
|
||||
tag: item.ImageTags.Primary,
|
||||
fillWidth: 300,
|
||||
},
|
||||
)
|
||||
}
|
||||
alt={item.Name ?? "item-image"}
|
||||
className="carousel-indicator-image"
|
||||
/>
|
||||
) : (
|
||||
<div className="carousel-indicator-icon">
|
||||
{getTypeIcon(item.Type ?? "Movie")}
|
||||
</div>
|
||||
)}
|
||||
</motion.div>
|
||||
);
|
||||
});
|
||||
}, [content, currentSlide, api, setDirection]);
|
||||
|
||||
const handleDragEnd = useCallback(
|
||||
(
|
||||
_: MouseEvent | TouchEvent | PointerEvent,
|
||||
{ offset, velocity }: PanInfo,
|
||||
) => {
|
||||
const swipe = swipePower(offset.x, velocity.x);
|
||||
if (
|
||||
currentSlide !== content.length - 1 &&
|
||||
swipe < -swipeConfidenceThreshold
|
||||
) {
|
||||
setDirection("right");
|
||||
setCurrentSlide((init) => init + 1);
|
||||
} else if (currentSlide !== 0 && swipe > swipeConfidenceThreshold) {
|
||||
setDirection("left");
|
||||
setCurrentSlide((init) => init - 1);
|
||||
}
|
||||
const handleTickerClick = useCallback(
|
||||
(index: number) => {
|
||||
if (index === currentSlide) return;
|
||||
setDirection(index > currentSlide ? "right" : "left");
|
||||
setCurrentSlide(index);
|
||||
},
|
||||
[currentSlide, content.length, setDirection],
|
||||
[currentSlide, setDirection],
|
||||
);
|
||||
|
||||
if (!api) return null;
|
||||
|
||||
return (
|
||||
<div className="carousel">
|
||||
<AnimatePresence mode="sync">
|
||||
<motion.div
|
||||
key={currentSlide}
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
exit={{ opacity: 0 }}
|
||||
transition={{
|
||||
duration: 0.25,
|
||||
ease: "linear",
|
||||
}}
|
||||
drag={"x"}
|
||||
dragConstraints={{ left: 0, right: 0 }}
|
||||
dragElastic={1}
|
||||
//@ts-ignore
|
||||
onDragEnd={handleDragEnd}
|
||||
style={{
|
||||
height: "100%",
|
||||
width: "100%",
|
||||
position: "absolute",
|
||||
}}
|
||||
>
|
||||
<MemoizedCarouselSlide
|
||||
item={content[currentSlide]}
|
||||
key={content[currentSlide].Id}
|
||||
/>
|
||||
</motion.div>
|
||||
<MemoizedCarouselSlide
|
||||
item={content[currentSlide]}
|
||||
key={content[currentSlide].Id}
|
||||
/>
|
||||
</AnimatePresence>
|
||||
<MemoizedSlider currentSlide={currentSlide} content={sliderContent} />
|
||||
<div className="carousel-sidebar">
|
||||
{content.map((item, index) => (
|
||||
<CarouselTickers
|
||||
key={item.Id}
|
||||
imageUrl={
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
item.Id ?? "",
|
||||
"Primary",
|
||||
{
|
||||
quality: 90,
|
||||
fillWidth: 360,
|
||||
},
|
||||
) ?? undefined
|
||||
}
|
||||
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() ?? "")
|
||||
}
|
||||
onClick={() => handleTickerClick(index)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import { Typography } from "@mui/material";
|
||||
import React from "react";
|
||||
|
||||
type CarouselTickersProps = {
|
||||
imageUrl?: string;
|
||||
itemName: string;
|
||||
itemYear: string;
|
||||
onClick: () => void;
|
||||
isActive: boolean;
|
||||
};
|
||||
|
||||
const CarouselTickers = ({
|
||||
imageUrl,
|
||||
itemName,
|
||||
itemYear,
|
||||
onClick,
|
||||
isActive,
|
||||
}: CarouselTickersProps) => {
|
||||
return (
|
||||
<div
|
||||
className={`carousel-ticker${isActive ? " active" : ""}`}
|
||||
onClick={onClick}
|
||||
>
|
||||
<img
|
||||
src={imageUrl}
|
||||
alt={itemName}
|
||||
className="carousel-ticker-image"
|
||||
// style={{ width: "5em", height: "100%", objectFit: "cover" }}
|
||||
/>
|
||||
<div>
|
||||
<Typography variant="subtitle1" className="carousel-ticker-title">
|
||||
{itemName}
|
||||
</Typography>
|
||||
<Typography variant="caption" className="carousel-ticker-year">
|
||||
{itemYear}
|
||||
</Typography>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
export default CarouselTickers;
|
||||
@@ -1,29 +1,47 @@
|
||||
import React from "react";
|
||||
|
||||
import { motion } from "motion/react";
|
||||
|
||||
import Button from "@mui/material/Button";
|
||||
import Chip from "@mui/material/Chip";
|
||||
import Stack from "@mui/material/Stack";
|
||||
import Typography from "@mui/material/Typography";
|
||||
|
||||
import { yellow } from "@mui/material/colors";
|
||||
|
||||
import { endsAt, getRuntime } from "@/utils/date/time";
|
||||
import { green, red } from "@mui/material/colors";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import { getTypeIcon } from "../utils/iconsCollection";
|
||||
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCarouselStore } from "@/utils/store/carousel";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import {
|
||||
type BaseItemDto,
|
||||
BaseItemKind,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import Button from "@mui/material/Button";
|
||||
import Chip from "@mui/material/Chip";
|
||||
import { green, red, yellow } from "@mui/material/colors";
|
||||
import Stack from "@mui/material/Stack";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import { motion } from "motion/react";
|
||||
import React from "react";
|
||||
import { endsAt, getRuntime } from "@/utils/date/time";
|
||||
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCarouselStore } from "@/utils/store/carousel";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import LikeButton from "../buttons/likeButton";
|
||||
import MarkPlayedButton from "../buttons/markPlayedButton";
|
||||
import PlayButton from "../buttons/playButton";
|
||||
import { getTypeIcon } from "../utils/iconsCollection";
|
||||
|
||||
const textVariants = {
|
||||
initial: (direction: string) => ({
|
||||
x: direction === "right" ? 40 : -40,
|
||||
opacity: 0,
|
||||
}),
|
||||
animate: {
|
||||
x: 0,
|
||||
opacity: 1,
|
||||
transition: {
|
||||
duration: 0.35,
|
||||
ease: [0.2, 0, 0, 1],
|
||||
},
|
||||
},
|
||||
exit: (direction: string) => ({
|
||||
x: direction === "right" ? -40 : 40,
|
||||
opacity: 0,
|
||||
transition: {
|
||||
duration: 0.2,
|
||||
ease: "easeInOut",
|
||||
},
|
||||
}),
|
||||
};
|
||||
|
||||
const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
@@ -66,7 +84,13 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
||||
|
||||
return (
|
||||
<div className="hero-carousel-slide">
|
||||
<div className="hero-carousel-background-container">
|
||||
<motion.div
|
||||
className="hero-carousel-background-container"
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
exit={{ opacity: 0 }}
|
||||
transition={{ duration: 0.4, ease: "easeInOut" }}
|
||||
>
|
||||
{item.BackdropImageTags?.length ? (
|
||||
<img
|
||||
alt={item.Name ?? "item"}
|
||||
@@ -89,39 +113,39 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
||||
{getTypeIcon(item.Type ?? "Movie")}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="hero-carousel-detail">
|
||||
</motion.div>
|
||||
<motion.div
|
||||
className="hero-carousel-detail"
|
||||
initial="initial"
|
||||
animate="animate"
|
||||
exit="exit"
|
||||
variants={{
|
||||
animate: {
|
||||
transition: {
|
||||
staggerChildren: 0.05,
|
||||
delayChildren: 0.05,
|
||||
},
|
||||
},
|
||||
exit: {
|
||||
transition: {
|
||||
staggerChildren: 0.02,
|
||||
staggerDirection: -1,
|
||||
},
|
||||
},
|
||||
}}
|
||||
>
|
||||
{/* @ts-ignore */}
|
||||
<Typography
|
||||
component={motion.div}
|
||||
initial={{
|
||||
transform:
|
||||
animationDirection === "right"
|
||||
? "translateX(60px)"
|
||||
: "translateX(-60px)",
|
||||
opacity: 0,
|
||||
}}
|
||||
animate={{
|
||||
transform: "translateX(0px)",
|
||||
opacity: 1,
|
||||
}}
|
||||
exit={{
|
||||
transform:
|
||||
animationDirection === "right"
|
||||
? "translateX(-60px)"
|
||||
: "translateX(60px)",
|
||||
opacity: 0,
|
||||
}}
|
||||
transition={{
|
||||
duration: 0.25,
|
||||
ease: "easeInOut",
|
||||
}}
|
||||
custom={animationDirection}
|
||||
variants={textVariants}
|
||||
key={item.Id}
|
||||
variant="h2"
|
||||
className="hero-carousel-text"
|
||||
sx={{
|
||||
mb: "5px",
|
||||
}}
|
||||
fontWeight={200}
|
||||
fontWeight={600}
|
||||
overflow="visible"
|
||||
>
|
||||
{!item.ImageTags?.Logo ? (
|
||||
@@ -142,31 +166,11 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
||||
/>
|
||||
)}
|
||||
</Typography>
|
||||
{/* @ts-ignore */}
|
||||
<Stack
|
||||
component={motion.div}
|
||||
initial={{
|
||||
transform:
|
||||
animationDirection === "right"
|
||||
? "translateX(20px)"
|
||||
: "translateX(-20px)",
|
||||
opacity: 0,
|
||||
}}
|
||||
animate={{
|
||||
transform: "translateX(0px)",
|
||||
opacity: 1,
|
||||
}}
|
||||
exit={{
|
||||
transform:
|
||||
animationDirection === "right"
|
||||
? "translateX(-20px)"
|
||||
: "translateX(20px)",
|
||||
|
||||
opacity: 0,
|
||||
}}
|
||||
transition={{
|
||||
duration: 0.25,
|
||||
ease: "easeInOut",
|
||||
}}
|
||||
custom={animationDirection}
|
||||
variants={textVariants}
|
||||
direction="row"
|
||||
gap={2}
|
||||
className="hero-carousel-info"
|
||||
@@ -176,7 +180,7 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
||||
>
|
||||
{item.PremiereDate && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{item.ProductionYear}
|
||||
{item.ProductionYear ?? ""}
|
||||
</Typography>
|
||||
)}
|
||||
{item.OfficialRating && (
|
||||
@@ -239,82 +243,49 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{item.RunTimeTicks ? (
|
||||
{item.RunTimeTicks && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{getRuntime(item.RunTimeTicks)}
|
||||
</Typography>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
{item.RunTimeTicks ? (
|
||||
{item.RunTimeTicks && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{endsAt(
|
||||
item.RunTimeTicks - (item.UserData?.PlaybackPositionTicks ?? 0),
|
||||
)}
|
||||
</Typography>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
<Typography variant="subtitle2" style={{ opacity: 0.8 }}>
|
||||
{item.Genres?.slice(0, 4).join(" / ")}
|
||||
</Typography>
|
||||
</Stack>
|
||||
{/* @ts-ignore */}
|
||||
<Typography
|
||||
component={motion.div}
|
||||
initial={{
|
||||
transform:
|
||||
animationDirection === "right"
|
||||
? "translateX(20px)"
|
||||
: "translateX(-20px)",
|
||||
opacity: 0,
|
||||
}}
|
||||
animate={{
|
||||
transform: "translateX(0px)",
|
||||
opacity: 1,
|
||||
}}
|
||||
exit={{
|
||||
transform:
|
||||
animationDirection === "right"
|
||||
? "translateX(-20px)"
|
||||
: "translateX(20px)",
|
||||
|
||||
opacity: 0,
|
||||
}}
|
||||
transition={{
|
||||
duration: 0.25,
|
||||
ease: "easeInOut",
|
||||
}}
|
||||
className="hero-carousel-text"
|
||||
sx={{
|
||||
display: "-webkit-box",
|
||||
maxWidth: "70%",
|
||||
maxHeight: "50%",
|
||||
textOverflow: "ellipsis",
|
||||
overflow: "hidden",
|
||||
WebkitLineClamp: "4",
|
||||
WebkitBoxOrient: "vertical",
|
||||
}}
|
||||
variant="subtitle2"
|
||||
fontWeight={300}
|
||||
custom={animationDirection}
|
||||
variants={textVariants}
|
||||
className="hero-carousel-overview"
|
||||
variant="body1"
|
||||
fontWeight={400}
|
||||
>
|
||||
{item.Overview}
|
||||
</Typography>
|
||||
|
||||
{/* @ts-ignore */}
|
||||
<Stack
|
||||
mt={3}
|
||||
direction="row"
|
||||
gap={3}
|
||||
gap={2}
|
||||
width="100%"
|
||||
className="hero-carousel-button-container"
|
||||
alignItems="center"
|
||||
component={motion.div}
|
||||
custom={animationDirection}
|
||||
variants={textVariants}
|
||||
>
|
||||
<PlayButton
|
||||
item={item}
|
||||
userId={user?.Id}
|
||||
itemType={item.Type ?? "Movie"}
|
||||
currentAudioTrack={0}
|
||||
currentSubTrack={0}
|
||||
currentVideoTrack={0}
|
||||
buttonProps={{
|
||||
size: "large",
|
||||
}}
|
||||
@@ -330,7 +301,7 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
||||
|
||||
<Button
|
||||
size="large"
|
||||
//@ts-ignore
|
||||
//@ts-expect-error
|
||||
color="white"
|
||||
variant="outlined"
|
||||
endIcon={
|
||||
@@ -364,7 +335,7 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
||||
/>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</div>
|
||||
</motion.div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -4,6 +4,7 @@ import Chip from "@mui/material/Chip";
|
||||
import { green, red, yellow } from "@mui/material/colors";
|
||||
import Stack from "@mui/material/Stack";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { Link } from "@tanstack/react-router";
|
||||
import React, { type ReactNode, type RefObject } from "react";
|
||||
import { Blurhash } from "react-blurhash";
|
||||
import heroBg from "@/assets/herobg.png";
|
||||
@@ -26,7 +27,6 @@ import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||
import { endsAt, getRuntime } from "@/utils/date/time";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import type MediaQualityInfo from "@/utils/types/mediaQualityInfo";
|
||||
import { Link } from "@tanstack/react-router";
|
||||
import "./itemHeader.scss";
|
||||
|
||||
interface ItemHeaderProps {
|
||||
@@ -54,8 +54,6 @@ const ItemHeader = ({
|
||||
? (item.ParentBackdropItemId ?? item.Id)
|
||||
: item.Id;
|
||||
|
||||
// @ts-expect-error - ParentLogoImageTag is not in the type definition
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const parentLogoImageTag =
|
||||
(item as any).ParentLogoImageTag || (item as any).ParentLogoImageTags?.[0];
|
||||
const logoTag =
|
||||
|
||||
@@ -6,7 +6,7 @@ import { getRuntimeMusic } from "@/utils/date/time";
|
||||
interface PlayerProgressProps {
|
||||
progress: number;
|
||||
duration: number;
|
||||
onSeek: (value: number) => void;
|
||||
onSeek?: (value: number) => void;
|
||||
onSeekCommit: (value: number) => void;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ const PlayerProgress = ({
|
||||
setIsScrubbing(true);
|
||||
const newValue = Array.isArray(value) ? value[0] : value;
|
||||
setSliderValue(newValue);
|
||||
onSeek(newValue);
|
||||
onSeek?.(newValue);
|
||||
};
|
||||
|
||||
const handleChangeCommitted = (_: unknown, value: number | number[]) => {
|
||||
|
||||
@@ -26,7 +26,7 @@ const AudioPlayer = () => {
|
||||
const user = useCentralStore((s) => s.currentUser);
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
|
||||
|
||||
const audioRef = useRef<HTMLAudioElement | null>(null);
|
||||
const [url, display, item, volume, isMuted] = useAudioPlayback((state) => [
|
||||
state.url,
|
||||
@@ -35,32 +35,33 @@ const AudioPlayer = () => {
|
||||
state.player.volume,
|
||||
state.player.isMuted,
|
||||
]);
|
||||
|
||||
|
||||
const [tracks, currentTrack] = useQueue((state) => [
|
||||
state.tracks,
|
||||
state.currentItemIndex,
|
||||
]);
|
||||
|
||||
|
||||
const [playing, setPlaying] = useState(false);
|
||||
const [progress, setProgress] = useState(0);
|
||||
|
||||
|
||||
// Sync volume and ref
|
||||
useEffect(() => {
|
||||
if (display) {
|
||||
setAudioRef(audioRef);
|
||||
|
||||
if (audioRef.current) {
|
||||
audioRef.current.volume = isMuted ? 0 : volume;
|
||||
}
|
||||
}
|
||||
}, [display, url, tracks?.[currentTrack]?.Id]);
|
||||
|
||||
|
||||
// Update volume when state changes
|
||||
useEffect(() => {
|
||||
if (audioRef.current) {
|
||||
audioRef.current.volume = isMuted ? 0 : volume;
|
||||
}
|
||||
}, [volume, isMuted]);
|
||||
|
||||
|
||||
// Media Session Metadata
|
||||
useEffect(() => {
|
||||
if ("mediaSession" in navigator && item) {
|
||||
@@ -87,7 +88,7 @@ const AudioPlayer = () => {
|
||||
});
|
||||
}
|
||||
}, [item, api]);
|
||||
|
||||
|
||||
// Media Session Action Handlers
|
||||
useEffect(() => {
|
||||
if ("mediaSession" in navigator) {
|
||||
@@ -114,7 +115,7 @@ const AudioPlayer = () => {
|
||||
});
|
||||
}
|
||||
}, [api, user?.Id]);
|
||||
|
||||
|
||||
const updatePositionState = () => {
|
||||
if (
|
||||
"mediaSession" in navigator &&
|
||||
@@ -132,7 +133,7 @@ const AudioPlayer = () => {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const handlePlayPause = () => {
|
||||
if (audioRef.current) {
|
||||
if (audioRef.current.paused) {
|
||||
@@ -144,41 +145,41 @@ const AudioPlayer = () => {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const handleTimeUpdate = (e: SyntheticEvent<HTMLAudioElement>) => {
|
||||
setProgress(secToTicks(e.currentTarget.currentTime));
|
||||
};
|
||||
|
||||
|
||||
const handleEnded = () => {
|
||||
setPlaying(false);
|
||||
if (tracks?.[currentTrack + 1]?.Id && api && user?.Id) {
|
||||
playItemFromQueue("next", user.Id, api);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const handleSeekCommit = (value: number) => {
|
||||
if (audioRef.current) {
|
||||
audioRef.current.currentTime = ticksToSec(value);
|
||||
setProgress(value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const handleVolumeChange = (newVolume: number) => {
|
||||
setVolume(newVolume);
|
||||
};
|
||||
|
||||
|
||||
const handleMuteToggle = () => {
|
||||
setIsMuted(!isMuted);
|
||||
};
|
||||
|
||||
|
||||
const handleClose = () => {
|
||||
useAudioPlayback.setState(useAudioPlayback.getInitialState());
|
||||
};
|
||||
|
||||
|
||||
const handleNavigate = () => {
|
||||
navigate({ to: "/player/audio" });
|
||||
};
|
||||
|
||||
|
||||
// Listen to play/pause events directly from audio element to keep state in sync
|
||||
// (e.g. if paused by media keys)
|
||||
const onPlay = () => {
|
||||
@@ -195,7 +196,7 @@ const AudioPlayer = () => {
|
||||
navigator.mediaSession.playbackState = "paused";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<AnimatePresence mode="sync">
|
||||
{display && (
|
||||
@@ -214,7 +215,7 @@ const AudioPlayer = () => {
|
||||
<PlayerInfo
|
||||
item={item}
|
||||
api={api}
|
||||
trackName={tracks?.[currentTrack]?.Name}
|
||||
trackName={tracks?.[currentTrack]?.Name ?? "Unknown Track"}
|
||||
/>
|
||||
|
||||
<audio
|
||||
|
||||
@@ -3,37 +3,47 @@
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
isolation: isolate;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
|
||||
&-slide {
|
||||
position: relative;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
overflow: visible;
|
||||
margin: 0 auto;
|
||||
overflow: hidden;
|
||||
margin: 0;
|
||||
border: none;
|
||||
// box-shadow: 0 0 30px black !important;
|
||||
border-radius: 20px;
|
||||
grid-area: main;
|
||||
border: 1.2px solid rgb(255 255 255 / 0.1);
|
||||
}
|
||||
|
||||
&-background {
|
||||
&-blurhash {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
filter: brightness(0.4);
|
||||
}
|
||||
&-container {
|
||||
position: absolute;
|
||||
z-index: 0;
|
||||
top: -4.4em;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 90vh;
|
||||
filter: brightness(0.8);
|
||||
mask-image: linear-gradient(to left, black 50%, transparent), linear-gradient(to bottom, black 60%, transparent);
|
||||
-webkit-mask-image: linear-gradient(to left,
|
||||
black 50%,
|
||||
transparent), linear-gradient(to bottom, black 40%, transparent);
|
||||
mask-composite: intersect;
|
||||
bottom: 0;
|
||||
height: 100%;
|
||||
|
||||
// Gradient overlay to make text readable
|
||||
&::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: linear-gradient(
|
||||
to top right,
|
||||
rgba(0, 0, 0, 0.9) 0%,
|
||||
rgba(0, 0, 0, 0.4) 50%,
|
||||
transparent 100%
|
||||
);
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
&-image {
|
||||
position: absolute;
|
||||
background-size: cover;
|
||||
@@ -41,16 +51,16 @@
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
background-position: center;
|
||||
object-fit: cover;
|
||||
width: 100%;
|
||||
height: 90vh;
|
||||
height: 100%;
|
||||
transition: opacity 0.5s;
|
||||
}
|
||||
|
||||
|
||||
&-icon-container {
|
||||
position: absolute;
|
||||
// background: $clr-gradient-dark;
|
||||
background: url("/src/assets/herobg.png"), rgb(0 0 0 /0.3);
|
||||
z-index: 0;
|
||||
top: 0;
|
||||
@@ -58,41 +68,67 @@
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-blend-mode: overlay;
|
||||
height: 90vh;
|
||||
height: 100%;
|
||||
|
||||
.material-symbols-rounded {
|
||||
position: absolute;
|
||||
font-size: 15em !important;
|
||||
left: 80%;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
font-variation-settings: "FILL" 0, "wght" 300, "GRAD" 50,
|
||||
"opsz" 60;
|
||||
font-variation-settings: "FILL" 0, "wght" 300, "GRAD" 50, "opsz" 60;
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&-text {
|
||||
display: -webkit-box;
|
||||
overflow: hidden;
|
||||
-webkit-line-clamp: 2;
|
||||
margin-bottom: 0.5em;
|
||||
text-shadow: 0 0 10px rgba(0,0,0,0.5), 0 0 20px rgba(0,0,0,0.3);
|
||||
|
||||
&-logo {
|
||||
max-width: 34vw;
|
||||
max-height: 2.4em;
|
||||
max-width: 25vw;
|
||||
max-height: 20vh;
|
||||
object-fit: contain;
|
||||
object-position: bottom;
|
||||
object-position: left bottom;
|
||||
filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
|
||||
}
|
||||
}
|
||||
|
||||
&-overview {
|
||||
overflow: hidden;
|
||||
margin-bottom: 0.5em;
|
||||
text-shadow: 0 1px 2px rgba(0,0,0,0.8);
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
display: block;
|
||||
font-size: 1.1rem;
|
||||
opacity: 0.9;
|
||||
max-width: 800px;
|
||||
}
|
||||
|
||||
&-detail {
|
||||
position: relative;
|
||||
z-index: 0;
|
||||
position: absolute;
|
||||
z-index: 3;
|
||||
display: flex;
|
||||
gap: 1.5em;
|
||||
height: 100%;
|
||||
width: 80%;
|
||||
padding: $page-margin;
|
||||
padding-bottom: 0;
|
||||
width: 100%;
|
||||
max-width: 1400px;
|
||||
padding: 4rem;
|
||||
padding-bottom: 5rem;
|
||||
padding-left: 5rem;
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
align-items: flex-start;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
&-info {
|
||||
text-shadow: 0 1px 2px rgba(0,0,0,0.8);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,22 +141,24 @@
|
||||
}
|
||||
|
||||
@media (max-width: 1140px) {
|
||||
.carousel{
|
||||
.carousel {
|
||||
height: 60vh !important;
|
||||
}
|
||||
.hero-carousel{
|
||||
&-background-image{
|
||||
.hero-carousel {
|
||||
&-detail {
|
||||
width: 100%;
|
||||
background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
|
||||
}
|
||||
|
||||
&-background-container::after {
|
||||
background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
|
||||
}
|
||||
|
||||
&-text {
|
||||
-webkit-line-clamp: 2 !important;
|
||||
|
||||
&-logo {
|
||||
max-width: 7em;
|
||||
max-height: 2em;
|
||||
object-fit: contain;
|
||||
object-position: bottom;
|
||||
}
|
||||
}
|
||||
&-logo {
|
||||
max-width: 60vw;
|
||||
max-height: 10vh;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user