style: update hero-carousel styling
This commit is contained in:
27 files changed
+750
-382
No files matched your search
@@ -0,0 +1,11 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_1029_262)">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M23.5024 12.9928C23.271 9.28227 21.3839 6.50613 18.5446 4.9541C18.5607 5.04452 18.4802 5.15755 18.3886 5.11752C16.5315 4.30511 13.3809 6.93435 11.1793 5.55749C11.1958 6.05163 11.0993 8.46208 7.70374 8.6019C7.62358 8.60519 7.57946 8.52333 7.63015 8.46537C8.08426 7.94743 8.54275 6.63609 7.88349 5.93701C6.47168 7.20213 5.65179 7.67825 2.94477 7.04997C1.21159 8.86222 0.229486 11.3426 0.422283 14.4324C0.815644 20.7399 6.72373 24.3454 12.6732 23.9741C18.6223 23.6032 23.8959 19.3003 23.5024 12.9928Z" fill="#FA320A"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.6598 3.43995C13.8824 3.14856 17.3987 3.41156 18.5253 4.90604C18.5929 4.99566 18.4977 5.16526 18.3887 5.11766C16.5315 4.30524 13.3809 6.93449 11.1793 5.55762C11.1958 6.05176 11.0993 8.46222 7.7038 8.60204C7.62363 8.60532 7.57952 8.52347 7.6302 8.46551C8.08431 7.94756 8.5427 6.63623 7.88355 5.93714C6.34566 7.3153 5.51193 7.75815 2.17404 6.85591C2.06479 6.82644 2.10204 6.65087 2.21825 6.60655C2.84913 6.36546 4.27837 5.30946 5.63054 4.844C5.88796 4.75547 6.14459 4.68675 6.39505 4.64682C4.90625 4.51377 4.23515 4.30674 3.2882 4.44954C3.18443 4.46517 3.11392 4.34438 3.17825 4.26152C4.45414 2.61807 6.80454 2.12174 8.2547 2.9948C7.36083 1.88722 6.66064 1.0039 6.66064 1.0039L8.31973 0.0615234C8.31973 0.0615234 9.00518 1.59294 9.5039 2.7075C10.7381 0.883996 13.0343 0.715698 14.0044 2.00951C14.062 2.08639 14.0019 2.19573 13.9058 2.19344C13.1161 2.17422 12.6814 2.89243 12.6484 3.43865L12.6598 3.43995Z" fill="#00912D"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_1029_262">
|
||||
<rect width="24" height="24" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.7 KiB |
@@ -0,0 +1,10 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_1029_259)">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M21.4392 21.4361C16.9038 21.6742 15.9771 16.4845 14.1977 16.5215C13.4395 16.5374 12.8419 17.3301 13.1043 18.254C13.2487 18.7619 13.649 19.5067 13.9012 19.9689C14.7909 21.6 13.4756 23.4458 11.9364 23.6019C9.37865 23.8614 8.31171 22.3776 8.37771 20.8586C8.45192 19.1535 9.89771 17.4111 8.41486 16.6698C6.86086 15.8928 5.5976 18.931 4.11055 19.6091C2.76465 20.2229 0.896337 19.747 0.232126 18.2525C-0.2344 17.2023 -0.149558 15.1801 1.9276 14.4085C3.22507 13.9266 6.11644 15.0387 6.26476 13.6301C6.43571 12.0063 3.22728 11.8694 2.26128 11.48C0.552021 10.7911 -0.456821 9.31714 0.3336 7.73588C0.926653 6.54978 2.6716 6.06714 4.00349 6.58672C5.59907 7.20914 5.85518 8.86409 6.67265 9.5523C7.37686 10.1455 8.34065 10.2197 8.97097 9.81188C9.43581 9.51104 9.59055 8.8503 9.41518 8.24672C9.18255 7.44546 8.56518 6.94546 7.96286 6.45556C6.89097 5.5842 5.37771 4.83493 6.29307 2.45651C7.04339 0.507354 9.24402 0.437144 9.24402 0.437144C10.1183 0.338828 10.9013 0.602828 11.5393 1.17283C12.3922 1.93483 12.5583 2.95335 12.4156 4.03999C12.2852 5.03188 11.9341 5.90062 11.7511 6.88335C11.5387 8.0243 12.1484 9.17399 13.3081 9.21872C14.8335 9.27767 15.2909 8.10525 15.4775 7.36209C15.7508 6.27472 16.1094 5.26525 17.1185 4.62946C18.5669 3.71693 20.5787 3.91693 21.512 5.67072C22.2503 7.05841 22.0133 8.96872 20.8808 10.0119C20.3727 10.4798 19.7617 10.6447 19.1009 10.6494C18.1532 10.6561 17.2059 10.6328 16.3262 11.0763C15.7274 11.3781 15.4664 11.8699 15.4665 12.529C15.4665 13.1715 15.801 13.591 16.3429 13.8641C17.3635 14.3785 18.4901 14.4837 19.5927 14.6767C21.1915 14.9567 22.5973 15.5199 23.4998 17.0036C23.5079 17.0166 23.5158 17.0298 23.5235 17.043C24.56 18.7997 23.476 21.329 21.4392 21.4361Z" fill="#0AC855"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_1029_259">
|
||||
<rect width="24" height="24" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.0 KiB |
@@ -0,0 +1,171 @@
|
||||
import useDebounce from "@/utils/hooks/useDebounce";
|
||||
import React, {
|
||||
type ReactNode,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
|
||||
import { useSpring } from "@react-spring/web";
|
||||
import { debounce } from "lodash";
|
||||
|
||||
import "./style.scss";
|
||||
import { Button, IconButton } from "@mui/material";
|
||||
|
||||
enum Direction {
|
||||
RIGHT = 0,
|
||||
LEFT = 1,
|
||||
}
|
||||
|
||||
const Slider = ({
|
||||
content,
|
||||
currentSlide,
|
||||
}: { content: ReactNode[]; currentSlide: number }) => {
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const [scrollPos, setScrollPos] = useState({ isStart: true, isEnd: false });
|
||||
|
||||
const handleScroll = useCallback(() => {
|
||||
const scrollWidth = containerRef.current?.scrollWidth ?? 0;
|
||||
const clientWidth =
|
||||
containerRef.current?.getBoundingClientRect().width ?? 0;
|
||||
const scrolledPostion = containerRef.current?.scrollLeft ?? 0;
|
||||
if (content.length === 0) {
|
||||
setScrollPos({ isStart: true, isEnd: true });
|
||||
} else if (clientWidth >= scrollWidth) {
|
||||
setScrollPos({ isStart: true, isEnd: true });
|
||||
} else if (
|
||||
scrolledPostion >=
|
||||
(containerRef.current?.scrollWidth ?? 0) - clientWidth
|
||||
) {
|
||||
setScrollPos({ isStart: false, isEnd: true });
|
||||
} else if (scrolledPostion > 0) {
|
||||
setScrollPos({ isStart: false, isEnd: false });
|
||||
} else {
|
||||
setScrollPos({ isStart: true, isEnd: false });
|
||||
}
|
||||
}, [content]);
|
||||
|
||||
const debouncedScroll = useCallback(
|
||||
() => debounce(handleScroll, 50),
|
||||
[handleScroll],
|
||||
);
|
||||
useEffect(() => {
|
||||
const handleResize = () => {
|
||||
debouncedScroll();
|
||||
};
|
||||
window.addEventListener("resize", handleResize, { passive: true });
|
||||
return () => window.removeEventListener("resize", handleResize);
|
||||
}, [debouncedScroll]);
|
||||
|
||||
useEffect(() => {
|
||||
handleScroll();
|
||||
}, [handleScroll, content]);
|
||||
|
||||
const onScroll = () => {
|
||||
debouncedScroll();
|
||||
};
|
||||
|
||||
const [, setX] = useSpring(() => ({
|
||||
from: { x: 0 },
|
||||
to: { x: 0 },
|
||||
onChange: (results) => {
|
||||
if (containerRef.current) {
|
||||
containerRef.current.scrollLeft = results.value.x;
|
||||
}
|
||||
},
|
||||
}));
|
||||
|
||||
const slide = (direction: Direction) => {
|
||||
const clientWidth =
|
||||
containerRef.current?.getBoundingClientRect().width ?? 0;
|
||||
const cardWidth =
|
||||
containerRef.current?.firstElementChild?.getBoundingClientRect().width ??
|
||||
0;
|
||||
const scrollPosition = containerRef.current?.scrollLeft ?? 0;
|
||||
const visibleItems = Math.floor(clientWidth / cardWidth);
|
||||
const scrollOffset = scrollPosition % cardWidth;
|
||||
|
||||
if (direction === Direction.LEFT) {
|
||||
const newX = Math.max(
|
||||
scrollPosition - scrollOffset - visibleItems * cardWidth,
|
||||
0,
|
||||
);
|
||||
setX.start({
|
||||
from: { x: scrollPosition },
|
||||
to: { x: newX },
|
||||
onChange: (results) => {
|
||||
if (containerRef.current) {
|
||||
containerRef.current.scrollLeft = results.value.x;
|
||||
}
|
||||
},
|
||||
reset: true,
|
||||
config: { friction: 60, tension: 1000, velocity: 2 },
|
||||
});
|
||||
|
||||
if (newX === 0) {
|
||||
setScrollPos({ isStart: true, isEnd: false });
|
||||
} else {
|
||||
setScrollPos({ isStart: false, isEnd: false });
|
||||
}
|
||||
} else if (direction === Direction.RIGHT) {
|
||||
const newX = Math.min(
|
||||
scrollPosition - scrollOffset + visibleItems * cardWidth,
|
||||
containerRef.current?.scrollWidth ?? 0 - clientWidth,
|
||||
);
|
||||
setX.start({
|
||||
from: { x: scrollPosition },
|
||||
to: { x: newX },
|
||||
onChange: (results) => {
|
||||
if (containerRef.current) {
|
||||
containerRef.current.scrollLeft = results.value.x;
|
||||
}
|
||||
},
|
||||
reset: true,
|
||||
config: { friction: 60, tension: 500, velocity: 2 },
|
||||
});
|
||||
|
||||
if (newX >= (containerRef.current?.scrollWidth ?? 0) - clientWidth) {
|
||||
setScrollPos({ isStart: false, isEnd: true });
|
||||
} else {
|
||||
setScrollPos({ isStart: false, isEnd: false });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="slider">
|
||||
<IconButton
|
||||
className="slider-button left"
|
||||
onClick={() => slide(Direction.LEFT)}
|
||||
disabled={scrollPos.isStart}
|
||||
variant="contained"
|
||||
>
|
||||
<span className="material-symbols-rounded">chevron_left</span>
|
||||
</IconButton>
|
||||
<div className="slider-track" ref={containerRef} onScroll={onScroll}>
|
||||
{content?.map((item, index) => (
|
||||
<div
|
||||
key={index}
|
||||
className={
|
||||
currentSlide === index
|
||||
? "slider-track-item active"
|
||||
: "slider-track-item"
|
||||
}
|
||||
>
|
||||
{item}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<IconButton
|
||||
className="slider-button right"
|
||||
onClick={() => slide(Direction.RIGHT)}
|
||||
disabled={scrollPos.isEnd}
|
||||
variant="contained"
|
||||
>
|
||||
<span className="material-symbols-rounded">chevron_right</span>
|
||||
</IconButton>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
export default Slider;
|
||||
@@ -0,0 +1,31 @@
|
||||
.slider {
|
||||
position: relative;
|
||||
|
||||
&-track {
|
||||
overflow-y: hidden;
|
||||
overflow-x: auto;
|
||||
white-space: nowrap;
|
||||
position: relative;
|
||||
overscroll-behavior-x: contain;
|
||||
margin: 0.5em 1em;
|
||||
|
||||
&-item {
|
||||
display: inline-block;
|
||||
// align-self: top;
|
||||
padding: 0.5em 0;
|
||||
}
|
||||
}
|
||||
|
||||
&-button {
|
||||
position: absolute !important;
|
||||
bottom: 1.3em;
|
||||
|
||||
&.left {
|
||||
left: -1.2em;
|
||||
}
|
||||
|
||||
&.right {
|
||||
right: -1.2em;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,6 +103,7 @@ export const AppBar = () => {
|
||||
return usr.data;
|
||||
},
|
||||
enabled: display,
|
||||
throwOnError: true,
|
||||
});
|
||||
const libraries = useQuery({
|
||||
queryKey: ["libraries"],
|
||||
|
||||
@@ -11,6 +11,7 @@ import Typography from "@mui/material/Typography";
|
||||
import {
|
||||
type BaseItemDto,
|
||||
BaseItemKind,
|
||||
type ImageType,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import LikeButton from "../buttons/likeButton";
|
||||
import MarkPlayedButton from "../buttons/markPlayedButton";
|
||||
@@ -49,22 +50,21 @@ export const Card = ({
|
||||
overrideIcon,
|
||||
}: {
|
||||
item: BaseItemDto;
|
||||
cardTitle: string | null;
|
||||
cardCaption: string | null;
|
||||
imageType: string;
|
||||
cardTitle: string | undefined | null;
|
||||
cardCaption?: string | null | number;
|
||||
imageType: ImageType;
|
||||
cardType: string;
|
||||
queryKey: [];
|
||||
userId: string;
|
||||
seriesId: string | null;
|
||||
hideText: boolean;
|
||||
onClick: () => null | null;
|
||||
disableOverlay: boolean;
|
||||
overrideIcon: any;
|
||||
queryKey?: string[];
|
||||
userId?: string;
|
||||
seriesId?: string | null;
|
||||
hideText?: boolean;
|
||||
onClick?: () => void;
|
||||
disableOverlay?: boolean;
|
||||
overrideIcon?: any;
|
||||
}) => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const navigate = useNavigate();
|
||||
const defaultOnClick = () => {
|
||||
|
||||
switch (item.Type) {
|
||||
case BaseItemKind.BoxSet:
|
||||
navigate({ to: "/boxset/$id", params: { id: item.Id } });
|
||||
|
||||
@@ -10,6 +10,7 @@ import { Blurhash } from "react-blurhash";
|
||||
import "./card.scss";
|
||||
|
||||
import { getRuntimeCompact } from "@/utils/date/time";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useNavigate, useRouteContext } from "@tanstack/react-router";
|
||||
import LikeButton from "../buttons/likeButton";
|
||||
import MarkPlayedButton from "../buttons/markPlayedButton";
|
||||
@@ -43,7 +44,7 @@ export const EpisodeCard = ({
|
||||
disableRunTime = false,
|
||||
onClick,
|
||||
}) => {
|
||||
const api = useRouteContext({ from: "/" }).api;
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const navigate = useNavigate();
|
||||
const defaultOnClick = () => {
|
||||
navigate({ to: `/episode/${item.Id}` });
|
||||
|
||||
@@ -1,45 +1,72 @@
|
||||
|
||||
.carousel {
|
||||
position: relative;
|
||||
height: 70vh;
|
||||
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;
|
||||
}
|
||||
&-button {
|
||||
position: absolute !important;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
z-index: 100;
|
||||
|
||||
&.right {
|
||||
left: calc(100% + 0.5em);
|
||||
right: 0.5em;
|
||||
}
|
||||
|
||||
&.left {
|
||||
right: calc(100% + 0.5em);
|
||||
left: 0.5em;
|
||||
}
|
||||
}
|
||||
|
||||
&-indicator {
|
||||
height: 3px;
|
||||
width: 100%;
|
||||
border-radius: 10px;
|
||||
transition: background $transition-time-fast,
|
||||
height $transition-time-fast;
|
||||
background: rgb(255 255 255 / 0.5);
|
||||
aspect-ratio: 1.77777;
|
||||
overflow: hidden;
|
||||
border-radius: 2px;
|
||||
padding: 2px;
|
||||
transition: opacity $transition-time-fast;
|
||||
opacity: 0.5;
|
||||
width: auto;
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
height: 6px;
|
||||
background: rgb(255 255 255 / 0.8) !important;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
&-container {
|
||||
display: flex;
|
||||
position: absolute;
|
||||
bottom: -1.5em;
|
||||
left: 10px;
|
||||
right: 10px;
|
||||
gap: 1em;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
&.active {
|
||||
height: 6px;
|
||||
background: white !important;
|
||||
}
|
||||
}
|
||||
&-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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,46 +5,60 @@ import IconButton from "@mui/material/IconButton";
|
||||
|
||||
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 ReactMultiCarousel from "react-multi-carousel";
|
||||
import Slider from "../Slider";
|
||||
import { getTypeIcon } from "../utils/iconsCollection";
|
||||
|
||||
const swipeConfidenceThreshold = 8000;
|
||||
const swipePower = (offset, velocity) => {
|
||||
return Math.abs(offset) * velocity;
|
||||
};
|
||||
|
||||
const Carousel = ({ content, onChange }) => {
|
||||
const Carousel = ({
|
||||
content,
|
||||
onChange,
|
||||
}: {
|
||||
content: BaseItemDto[];
|
||||
onChange: () => void;
|
||||
}) => {
|
||||
const [currentSlide, setCurrentSlide] = useState(0);
|
||||
|
||||
const [setDirection, dir] = useCarouselStore((state) => [
|
||||
state.setDirection,
|
||||
state.direction,
|
||||
]);
|
||||
|
||||
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
|
||||
useEffect(() => {
|
||||
onChange(currentSlide);
|
||||
}, [content[currentSlide]?.key]);
|
||||
}, [content[currentSlide]?.Id]);
|
||||
|
||||
const api = useApiInContext((s) => s.api);
|
||||
|
||||
const responsive = {
|
||||
superLargeDesktop: {
|
||||
// the naming can be any, depends on you.
|
||||
breakpoint: { max: 4000, min: 3000 },
|
||||
items: 6,
|
||||
},
|
||||
desktop: {
|
||||
breakpoint: { max: 3000, min: 1024 },
|
||||
items: 6,
|
||||
},
|
||||
tablet: {
|
||||
breakpoint: { max: 1024, min: 464 },
|
||||
items: 4,
|
||||
},
|
||||
mobile: {
|
||||
breakpoint: { max: 464, min: 0 },
|
||||
items: 1,
|
||||
},
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="carousel">
|
||||
<IconButton
|
||||
className="carousel-button left"
|
||||
onClick={() => {
|
||||
if (currentSlide === 0) {
|
||||
setDirection("left");
|
||||
setCurrentSlide(content.length - 1);
|
||||
}
|
||||
if (currentSlide > 0) {
|
||||
setDirection("left");
|
||||
setCurrentSlide((init) => init - 1);
|
||||
}
|
||||
}}
|
||||
sx={{
|
||||
background: " rgb(200 200 200 / 0.05)",
|
||||
}}
|
||||
// disabled={currentSlide == 0}
|
||||
>
|
||||
<div className="material-symbols-rounded">arrow_left</div>
|
||||
</IconButton>
|
||||
<AnimatePresence mode="sync">
|
||||
<motion.div
|
||||
key={currentSlide}
|
||||
@@ -77,35 +91,31 @@ const Carousel = ({ content, onChange }) => {
|
||||
position: "absolute",
|
||||
}}
|
||||
>
|
||||
{content[currentSlide]}
|
||||
<CarouselSlide
|
||||
item={content[currentSlide]}
|
||||
key={content[currentSlide].Id}
|
||||
/>
|
||||
</motion.div>
|
||||
</AnimatePresence>
|
||||
<IconButton
|
||||
className="carousel-button right"
|
||||
onClick={() => {
|
||||
if (currentSlide === content.length - 1) {
|
||||
setDirection("right");
|
||||
setCurrentSlide(0);
|
||||
} else if (currentSlide < content.length - 1) {
|
||||
setDirection("right");
|
||||
setCurrentSlide((init) => init + 1);
|
||||
}
|
||||
}}
|
||||
// disabled={currentSlide == content.length - 1}
|
||||
sx={{
|
||||
background: " rgb(200 200 200 / 0.05)",
|
||||
}}
|
||||
>
|
||||
<div className="material-symbols-rounded">arrow_right</div>
|
||||
</IconButton>
|
||||
<div className="carousel-indicator-container">
|
||||
{content.map((item, index) => (
|
||||
<div
|
||||
<Slider
|
||||
currentSlide={currentSlide}
|
||||
content={content.map((item, index) => (
|
||||
<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) {
|
||||
@@ -115,9 +125,24 @@ const Carousel = ({ content, onChange }) => {
|
||||
}
|
||||
setCurrentSlide(index);
|
||||
}}
|
||||
/>
|
||||
>
|
||||
{item.ImageTags?.Primary ? (
|
||||
<img
|
||||
src={api.getItemImageUrl(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)}
|
||||
</div>
|
||||
)}
|
||||
</motion.div>
|
||||
))}
|
||||
</div>
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -14,12 +14,15 @@ import { yellow } from "@mui/material/colors";
|
||||
import { endsAt, getRuntime } from "@/utils/date/time";
|
||||
import { green, red } from "@mui/material/colors";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useNavigate, useRouteContext } from "@tanstack/react-router";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import { getTypeIcon } from "../utils/iconsCollection";
|
||||
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCarouselStore } from "@/utils/store/carousel";
|
||||
import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
||||
import {
|
||||
type BaseItemDto,
|
||||
BaseItemKind,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import LikeButton from "../buttons/likeButton";
|
||||
import MarkPlayedButton from "../buttons/markPlayedButton";
|
||||
@@ -41,7 +44,7 @@ const availableSpecialRoutes = [
|
||||
* @param {Props}
|
||||
* @returns {React.Component}
|
||||
*/
|
||||
const CarouselSlide = ({ item }) => {
|
||||
const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const navigate = useNavigate();
|
||||
|
||||
@@ -55,19 +58,31 @@ const CarouselSlide = ({ item }) => {
|
||||
});
|
||||
|
||||
const handleMoreInfo = () => {
|
||||
if (availableSpecialRoutes.includes(item.Type)) {
|
||||
navigate({
|
||||
to: `/${item.Type.toLocaleLowerCase()}/$id`,
|
||||
params: { id: item.Id },
|
||||
});
|
||||
} else if (!!item.Role || item.Type === BaseItemKind.Person) {
|
||||
navigate({ to: "/person/$id", params: { id: item.Id } });
|
||||
} else if (item.Type === BaseItemKind.MusicArtist) {
|
||||
navigate({ to: "/artist/$id", params: { id: item.Id } });
|
||||
} else if (item.Type === BaseItemKind.Episode) {
|
||||
navigate({ to: "/episode/$id", params: { id: item.Id } });
|
||||
} else {
|
||||
navigate({ to: "/item/$id", params: { id: item.Id } });
|
||||
switch (item.Type) {
|
||||
case BaseItemKind.BoxSet:
|
||||
navigate({ to: "/boxset/$id", params: { id: item.Id } });
|
||||
break;
|
||||
case BaseItemKind.Episode:
|
||||
navigate({ to: "/episode/$id", params: { id: item.Id } });
|
||||
break;
|
||||
case BaseItemKind.MusicAlbum:
|
||||
navigate({ to: "/album/$id", params: { id: item.Id } });
|
||||
break;
|
||||
case BaseItemKind.MusicArtist:
|
||||
navigate({ to: "/artist/$id", params: { id: item.Id } });
|
||||
break;
|
||||
case BaseItemKind.Person:
|
||||
navigate({ to: "/person/$id", params: { id: item.Id } });
|
||||
break;
|
||||
case BaseItemKind.Series:
|
||||
navigate({ to: "/series/$id", params: { id: item.Id } });
|
||||
break;
|
||||
case BaseItemKind.Playlist:
|
||||
navigate({ to: "/playlist/$id", params: { id: item.Id } });
|
||||
break;
|
||||
default:
|
||||
navigate({ to: "/item/$id", params: { id: item.Id } });
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -78,50 +93,33 @@ const CarouselSlide = ({ item }) => {
|
||||
className="hero-carousel-slide"
|
||||
sx={{
|
||||
background: "transparent",
|
||||
px: 3,
|
||||
// px: 3,
|
||||
}}
|
||||
elevation={10}
|
||||
elevation={0}
|
||||
>
|
||||
<div className="hero-carousel-background-container">
|
||||
{!!item.ImageBlurHashes.Backdrop && (
|
||||
<>
|
||||
{Object.keys(item.ImageBlurHashes.Backdrop).length !== 0 && (
|
||||
<Blurhash
|
||||
hash={
|
||||
item.ImageBlurHashes.Backdrop[
|
||||
Object.keys(item.ImageBlurHashes.Backdrop)[0]
|
||||
]
|
||||
}
|
||||
// hash="LEHV6nWB2yk8pyo0adR*.7kCMdnj"
|
||||
width="256"
|
||||
height="179.2"
|
||||
resolutionX={64}
|
||||
resolutionY={45}
|
||||
className="hero-carousel-background-blurhash"
|
||||
punch={1.4}
|
||||
/>
|
||||
)}
|
||||
<img
|
||||
alt={item.Name}
|
||||
className="hero-carousel-background-image"
|
||||
src={
|
||||
item.ParentBackdropItemId
|
||||
? `${api.basePath}/Items/${item.ParentBackdropItemId}/Images/Backdrop?quality=80`
|
||||
: `${api.basePath}/Items/${item.Id}/Images/Backdrop?quality=80&fillHeight=1400`
|
||||
}
|
||||
style={{
|
||||
opacity: 0,
|
||||
}}
|
||||
onLoad={(e) => {
|
||||
e.target.style.opacity = 1;
|
||||
}}
|
||||
loading="eager"
|
||||
/>
|
||||
</>
|
||||
{item.BackdropImageTags?.length ? (
|
||||
<img
|
||||
alt={item.Name}
|
||||
className="hero-carousel-background-image"
|
||||
src={
|
||||
item.ParentBackdropItemId
|
||||
? `${api.basePath}/Items/${item.ParentBackdropItemId}/Images/Backdrop?quality=80`
|
||||
: `${api.basePath}/Items/${item.Id}/Images/Backdrop?quality=80&fillHeight=1400`
|
||||
}
|
||||
style={{
|
||||
opacity: 0,
|
||||
}}
|
||||
onLoad={(e) => {
|
||||
e.target.style.opacity = 1;
|
||||
}}
|
||||
loading="eager"
|
||||
/>
|
||||
) : (
|
||||
<div className="hero-carousel-background-icon-container">
|
||||
{getTypeIcon(item.Type)}
|
||||
</div>
|
||||
)}
|
||||
<div className="hero-carousel-background-icon-container">
|
||||
{getTypeIcon(item.Type)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="hero-carousel-detail">
|
||||
<Typography
|
||||
@@ -207,10 +205,14 @@ const CarouselSlide = ({ item }) => {
|
||||
justifyItems="flex-start"
|
||||
alignItems="center"
|
||||
>
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle1">
|
||||
{item.ProductionYear ? item.ProductionYear : "Unknown"}
|
||||
</Typography>
|
||||
<Chip variant="filled" label={item.OfficialRating ?? "Not Rated"} />
|
||||
{item.PremiereDate && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{item.ProductionYear ?? ""}
|
||||
</Typography>
|
||||
)}
|
||||
{item.OfficialRating && (
|
||||
<Chip variant="filled" size="small" label={item.OfficialRating} />
|
||||
)}
|
||||
|
||||
{item.CommunityRating && (
|
||||
<div
|
||||
@@ -222,12 +224,10 @@ const CarouselSlide = ({ item }) => {
|
||||
className="hero-carousel-info-rating"
|
||||
>
|
||||
<div
|
||||
className="material-symbols-rounded "
|
||||
className="material-symbols-rounded fill"
|
||||
style={{
|
||||
// fontSize: "2.2em",
|
||||
color: yellow[400],
|
||||
fontVariationSettings:
|
||||
'"FILL" 1, "wght" 300, "GRAD" 25, "opsz" 40',
|
||||
}}
|
||||
>
|
||||
star
|
||||
@@ -236,13 +236,13 @@ const CarouselSlide = ({ item }) => {
|
||||
style={{
|
||||
opacity: "0.8",
|
||||
}}
|
||||
variant="subtitle1"
|
||||
variant="subtitle2"
|
||||
>
|
||||
{Math.round(item.CommunityRating * 10) / 10}
|
||||
</Typography>
|
||||
</div>
|
||||
)}
|
||||
{Boolean(item.CriticRating) && (
|
||||
{item.CriticRating && (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
@@ -252,11 +252,9 @@ const CarouselSlide = ({ item }) => {
|
||||
className="hero-carousel-info-rating"
|
||||
>
|
||||
<div
|
||||
className="material-symbols-rounded "
|
||||
className="material-symbols-rounded fill"
|
||||
style={{
|
||||
color: item.CriticRating > 50 ? green[400] : red[400],
|
||||
fontVariationSettings:
|
||||
'"FILL" 1, "wght" 300, "GRAD" 25, "opsz" 40',
|
||||
}}
|
||||
>
|
||||
{item.CriticRating > 50 ? "thumb_up" : "thumb_down"}
|
||||
@@ -265,23 +263,26 @@ const CarouselSlide = ({ item }) => {
|
||||
style={{
|
||||
opacity: "0.8",
|
||||
}}
|
||||
variant="subtitle1"
|
||||
variant="subtitle2"
|
||||
>
|
||||
{item.CriticRating}
|
||||
</Typography>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!!item.RunTimeTicks && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle1">
|
||||
{item.RunTimeTicks && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{getRuntime(item.RunTimeTicks)}
|
||||
</Typography>
|
||||
)}
|
||||
{!!item.RunTimeTicks && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle1">
|
||||
{endsAt(item.RunTimeTicks)}
|
||||
{item.RunTimeTicks && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{endsAt(item.RunTimeTicks - item.UserData.PlaybackPositionTicks)}
|
||||
</Typography>
|
||||
)}
|
||||
<Typography variant="subtitle2" style={{ opacity: 0.8 }}>
|
||||
{item.Genres?.slice(0, 4).join(" / ")}
|
||||
</Typography>
|
||||
</Stack>
|
||||
<Typography
|
||||
component={motion.div}
|
||||
@@ -308,7 +309,6 @@ const CarouselSlide = ({ item }) => {
|
||||
duration: 0.25,
|
||||
ease: "easeInOut",
|
||||
}}
|
||||
variant="subtitle1"
|
||||
className="hero-carousel-text"
|
||||
sx={{
|
||||
display: "-webkit-box",
|
||||
@@ -319,6 +319,8 @@ const CarouselSlide = ({ item }) => {
|
||||
WebkitLineClamp: "4",
|
||||
WebkitBoxOrient: "vertical",
|
||||
}}
|
||||
variant="subtitle2"
|
||||
fontWeight={300}
|
||||
>
|
||||
{item.Overview}
|
||||
</Typography>
|
||||
|
||||
+16
-12
@@ -5,15 +5,19 @@ import { CardScroller } from "../../cardScroller/cardScroller";
|
||||
import { CardsSkeleton } from "../../skeleton/cards";
|
||||
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
||||
import {
|
||||
type BaseItemDto,
|
||||
BaseItemKind,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||
import { useRouteContext } from "@tanstack/react-router";
|
||||
|
||||
/**
|
||||
* @description Latest Media Section
|
||||
*/
|
||||
export const LatestMediaSection = ({ latestMediaLib }) => {
|
||||
export const LatestMediaSection = ({
|
||||
latestMediaLib,
|
||||
}: { latestMediaLib: BaseItemDto }) => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const user = useQuery({
|
||||
queryKey: ["user"],
|
||||
@@ -23,27 +27,27 @@ export const LatestMediaSection = ({ latestMediaLib }) => {
|
||||
},
|
||||
networkMode: "always",
|
||||
});
|
||||
const fetchLatestMedia = async (library) => {
|
||||
const fetchLatestMedia = async (library: BaseItemDto) => {
|
||||
const media = await getUserLibraryApi(api).getLatestMedia({
|
||||
userId: user.data.Id,
|
||||
parentId: library,
|
||||
userId: user.data?.Id,
|
||||
parentId: library.Id,
|
||||
limit: 16,
|
||||
fields: ["PrimaryImageAspectRatio"],
|
||||
});
|
||||
return media.data;
|
||||
};
|
||||
const data = useQuery({
|
||||
queryKey: ["homeSection, latestMedia", latestMediaLib],
|
||||
queryFn: () => fetchLatestMedia(latestMediaLib[0]),
|
||||
queryKey: ["home", "latestMedia", latestMediaLib.Id],
|
||||
queryFn: () => fetchLatestMedia(latestMediaLib),
|
||||
enabled: !!user.data,
|
||||
refetchOnMount: true
|
||||
refetchOnMount: true,
|
||||
});
|
||||
if (data.isPending) {
|
||||
return <CardsSkeleton />;
|
||||
}
|
||||
if (data.isSuccess && data.data.length >= 1) {
|
||||
return (
|
||||
<CardScroller displayCards={7} title={`Latest ${latestMediaLib[1]}`}>
|
||||
<CardScroller displayCards={7} title={`Latest ${latestMediaLib.Name}`}>
|
||||
{data.data.map((item) => {
|
||||
return (
|
||||
<Card
|
||||
@@ -75,8 +79,8 @@ export const LatestMediaSection = ({ latestMediaLib }) => {
|
||||
? "square"
|
||||
: "portrait"
|
||||
}
|
||||
queryKey={["homeSection, latestMedia", latestMediaLib]}
|
||||
userId={user.data.Id}
|
||||
queryKey={["home", "latestMedia", latestMediaLib.Id]}
|
||||
userId={user.data?.Id}
|
||||
imageBlurhash={
|
||||
!!item.ImageBlurHashes?.Primary &&
|
||||
item.ImageBlurHashes?.Primary[
|
||||
@@ -28,7 +28,7 @@ import React, { useEffect, useState } from "react";
|
||||
|
||||
import logo from "@/assets/logo.png";
|
||||
|
||||
import { createApi, jellyfin, useApiInContext } from "@/utils/store/api";
|
||||
import { jellyfin, useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import { getSystemApi } from "@jellyfin/sdk/lib/utils/api/system-api";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
@@ -64,7 +64,9 @@ const Settings = () => {
|
||||
state.dialogOpen,
|
||||
state.tabValue,
|
||||
]);
|
||||
const api = useApiInContext((s) => s.api);
|
||||
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const createApi = useApiInContext((s) => s.createApi);
|
||||
|
||||
const systemInfo = useQuery({
|
||||
queryKey: ["about", "systemInfo"],
|
||||
|
||||
+1
-3
@@ -12,6 +12,7 @@ const router = createRouter({
|
||||
api: undefined!,
|
||||
createApi: undefined!,
|
||||
},
|
||||
defaultPreload: "intent",
|
||||
});
|
||||
|
||||
// Register the router instance for type safety
|
||||
@@ -21,9 +22,6 @@ declare module "@tanstack/react-router" {
|
||||
}
|
||||
}
|
||||
|
||||
import { ThemeProvider } from "@mui/material";
|
||||
import { SnackbarProvider } from "notistack";
|
||||
import { theme } from "./theme";
|
||||
import { ApiProvider, useApiInContext } from "./utils/store/api";
|
||||
|
||||
export const queryClient = new QueryClient({
|
||||
|
||||
@@ -23,9 +23,7 @@ import { useIsFetching, useIsMutating } from "@tanstack/react-query";
|
||||
import {
|
||||
Outlet,
|
||||
ScrollRestoration,
|
||||
createRootRoute,
|
||||
createRootRouteWithContext,
|
||||
useNavigate,
|
||||
useRouterState,
|
||||
} from "@tanstack/react-router";
|
||||
import { TanStackRouterDevtools } from "@tanstack/router-devtools";
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { getDefaultServer, getServer } from "@/utils/storage/servers";
|
||||
import { getUser } from "@/utils/storage/user";
|
||||
import { getSystemApi } from "@jellyfin/sdk/lib/utils/api/system-api";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { createFileRoute, redirect } from "@tanstack/react-router";
|
||||
|
||||
|
||||
@@ -7,10 +7,9 @@
|
||||
position: relative;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
border-radius: 10px !important;
|
||||
overflow: hidden;
|
||||
overflow: visible;
|
||||
margin: 0 auto;
|
||||
border: 1.2px solid rgb(255 255 255 / 0.15);
|
||||
border: none;
|
||||
// box-shadow: 0 0 30px black !important;
|
||||
}
|
||||
&-background {
|
||||
@@ -24,32 +23,31 @@
|
||||
&-container {
|
||||
position: absolute;
|
||||
z-index: 0;
|
||||
top: 0;
|
||||
top: -4.4em;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 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;
|
||||
}
|
||||
&-image {
|
||||
position: absolute;
|
||||
background-size: cover;
|
||||
z-index: 1;
|
||||
top: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
background-position: center;
|
||||
object-fit: cover;
|
||||
width: 80%;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
height: 90vh;
|
||||
transition: opacity 0.5s;
|
||||
mask-image: linear-gradient(to left, black 50%, transparent);
|
||||
-webkit-mask-image: linear-gradient(
|
||||
to left,
|
||||
black 50%,
|
||||
transparent
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
&-icon-container {
|
||||
position: absolute;
|
||||
// background: $clr-gradient-dark;
|
||||
@@ -60,6 +58,7 @@
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-blend-mode: overlay;
|
||||
height: 9%;
|
||||
.material-symbols-rounded {
|
||||
position: absolute;
|
||||
font-size: 15em !important;
|
||||
@@ -67,7 +66,7 @@
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
font-variation-settings: "FILL" 0, "wght" 300, "GRAD" 50,
|
||||
"opsz" 60;
|
||||
"opsz" 60;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,16 +88,17 @@
|
||||
display: flex;
|
||||
height: 100%;
|
||||
width: 80%;
|
||||
padding: 2.5em;
|
||||
padding: $page-margin;
|
||||
padding-bottom: 0;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
justify-content: flex-end;
|
||||
align-items: flex-start;
|
||||
}
|
||||
}
|
||||
|
||||
.backdropContainer {
|
||||
background: linear-gradient(
|
||||
45deg,
|
||||
45deg,
|
||||
$clr-background-default,
|
||||
$clr-background-light
|
||||
);
|
||||
@@ -113,13 +113,14 @@
|
||||
width: 100%;
|
||||
}
|
||||
&-text {
|
||||
-webkit-line-clamp: 2 !important;
|
||||
&-logo {
|
||||
max-width: 7em;
|
||||
max-height: 2em;
|
||||
object-fit: contain;
|
||||
object-position: bottom;
|
||||
}
|
||||
}
|
||||
-webkit-line-clamp: 2 !important;
|
||||
|
||||
&-logo {
|
||||
max-width: 7em;
|
||||
max-height: 2em;
|
||||
object-fit: contain;
|
||||
object-position: bottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,16 +21,18 @@ import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
||||
|
||||
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||
|
||||
import { setBackdrop, useBackdropStore } from "@/utils/store/backdrop";
|
||||
import { setBackdrop } from "@/utils/store/backdrop";
|
||||
|
||||
import CarouselSlide from "@/components/carouselSlide";
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||
import { ApiContext, useApiInContext } from "@/utils/store/api";
|
||||
import { BaseItemKind, ItemFields } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import {
|
||||
type BaseItemDto,
|
||||
BaseItemKind,
|
||||
ItemFields,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { useSnackbar } from "notistack";
|
||||
import { ErrorBoundary } from "react-error-boundary";
|
||||
import { useStore } from "zustand";
|
||||
|
||||
export const Route = createFileRoute("/_api/home/")({
|
||||
component: Home,
|
||||
@@ -45,6 +47,7 @@ function Home() {
|
||||
queryKey: ["user"],
|
||||
queryFn: async () => {
|
||||
const usr = await getUserApi(api).getCurrentUser();
|
||||
console.log(usr.data);
|
||||
return usr.data;
|
||||
},
|
||||
networkMode: "always",
|
||||
@@ -55,7 +58,7 @@ function Home() {
|
||||
queryKey: ["libraries"],
|
||||
queryFn: async () => {
|
||||
const libs = await getUserViewsApi(api).getUserViews({
|
||||
userId: user.data.Id,
|
||||
userId: user.data?.Id,
|
||||
});
|
||||
return libs.data;
|
||||
},
|
||||
@@ -67,11 +70,10 @@ function Home() {
|
||||
queryKey: ["home", "latestMedia"],
|
||||
queryFn: async () => {
|
||||
const media = await getUserLibraryApi(api).getLatestMedia({
|
||||
userId: user.data.Id,
|
||||
userId: user.data?.Id,
|
||||
fields: [
|
||||
ItemFields.Overview,
|
||||
ItemFields.ParentId,
|
||||
"ParentIndexNumber",
|
||||
ItemFields.SeasonUserData,
|
||||
ItemFields.IsHd,
|
||||
ItemFields.MediaStreams,
|
||||
@@ -89,7 +91,7 @@ function Home() {
|
||||
queryKey: ["home", "resume", "video"],
|
||||
queryFn: async () => {
|
||||
const resumeItems = await getItemsApi(api).getResumeItems({
|
||||
userId: user.data.Id,
|
||||
userId: user.data?.Id,
|
||||
limit: 10,
|
||||
mediaTypes: ["Video"],
|
||||
enableUserData: true,
|
||||
@@ -105,7 +107,7 @@ function Home() {
|
||||
queryKey: ["home", "resume", "audio"],
|
||||
queryFn: async () => {
|
||||
const resumeItems = await getItemsApi(api).getResumeItems({
|
||||
userId: user.data.Id,
|
||||
userId: user.data?.Id,
|
||||
limit: 10,
|
||||
mediaTypes: ["Audio"],
|
||||
enableUserData: true,
|
||||
@@ -120,14 +122,12 @@ function Home() {
|
||||
queryKey: ["home", "upNext"],
|
||||
queryFn: async () => {
|
||||
const upNext = await getTvShowsApi(api).getNextUp({
|
||||
userId: user.data.Id,
|
||||
userId: user.data?.Id,
|
||||
fields: [
|
||||
ItemFields.PrimaryImageAspectRatio,
|
||||
ItemFields.MediaStreams,
|
||||
ItemFields.MediaSources,
|
||||
ItemFields.ParentId,
|
||||
"IndexNumber",
|
||||
"ParentIndexNumber",
|
||||
],
|
||||
limit: 10,
|
||||
});
|
||||
@@ -137,38 +137,31 @@ function Home() {
|
||||
refetchOnMount: true,
|
||||
});
|
||||
|
||||
const [latestMediaLibs, setLatestMediaLibs] = useState([]);
|
||||
const [latestMediaLibs, setLatestMediaLibs] = useState<
|
||||
BaseItemDto[] | undefined
|
||||
>([]);
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
||||
const excludeTypes = ["boxsets", "playlists", "livetv", "channels"];
|
||||
|
||||
let tempData = [];
|
||||
const [excludeTypes] = useState(
|
||||
() => new Set(["boxsets", "playlists", "livetv", "channels"]),
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (libraries.isSuccess) {
|
||||
libraries.data.Items.map((lib) => {
|
||||
if (excludeTypes.includes(lib.CollectionType)) {
|
||||
return;
|
||||
}
|
||||
tempData = latestMediaLibs;
|
||||
if (
|
||||
!tempData.some(
|
||||
(el) => JSON.stringify(el) === JSON.stringify([lib.Id, lib.Name]),
|
||||
)
|
||||
) {
|
||||
tempData.push([lib.Id, lib.Name]);
|
||||
setLatestMediaLibs(tempData);
|
||||
}
|
||||
});
|
||||
const latestMediaLibsTemp = libraries.data.Items?.reduce(
|
||||
(filteredItems: BaseItemDto[], currentItem) => {
|
||||
if (!excludeTypes.has(currentItem.Type)) {
|
||||
filteredItems.push(currentItem);
|
||||
}
|
||||
return filteredItems;
|
||||
},
|
||||
[],
|
||||
);
|
||||
setLatestMediaLibs(latestMediaLibsTemp);
|
||||
}
|
||||
}, [libraries.isSuccess]);
|
||||
|
||||
if (user.isPaused) {
|
||||
user.refetch();
|
||||
console.log(user.isError);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<main
|
||||
@@ -182,12 +175,10 @@ function Home() {
|
||||
{latestMedia.isPending ? (
|
||||
<CarouselSkeleton />
|
||||
) : (
|
||||
latestMedia.data.length > 0 && (
|
||||
latestMedia.data?.length && (
|
||||
<Carousel
|
||||
content={latestMedia.data?.map((item) => (
|
||||
<CarouselSlide item={item} key={item.Id} />
|
||||
))}
|
||||
onChange={(now) => {
|
||||
content={latestMedia.data}
|
||||
onChange={(now: number) => {
|
||||
if (latestMedia.isSuccess && latestMedia.data.length > 0) {
|
||||
if (latestMedia.data[now]?.ParentBackdropImageTags) {
|
||||
setBackdrop(
|
||||
@@ -219,7 +210,7 @@ function Home() {
|
||||
) : (
|
||||
<CardScroller displayCards={4} title="Libraries">
|
||||
{libraries.status === "success" &&
|
||||
libraries.data.Items.map((item) => {
|
||||
libraries.data.Items?.map((item) => {
|
||||
return (
|
||||
<Card
|
||||
key={item.Id}
|
||||
@@ -228,12 +219,11 @@ function Home() {
|
||||
imageType="Primary"
|
||||
cardType="thumb"
|
||||
disableOverlay
|
||||
onClick={() => navigate({ to: `/library/${item.Id}` })}
|
||||
imageBlurhash={
|
||||
!!item.ImageBlurHashes?.Primary &&
|
||||
item.ImageBlurHashes?.Primary[
|
||||
Object.keys(item.ImageBlurHashes.Primary)[0]
|
||||
]
|
||||
onClick={() =>
|
||||
navigate({
|
||||
to: "/library/$id",
|
||||
params: { id: item.Id ?? "" },
|
||||
})
|
||||
}
|
||||
overrideIcon={item.CollectionType}
|
||||
/>
|
||||
@@ -251,11 +241,11 @@ function Home() {
|
||||
>
|
||||
{upNextItems.isPending ? (
|
||||
<CardsSkeleton />
|
||||
) : upNextItems.isSuccess && upNextItems.data.Items.length === 0 ? (
|
||||
) : upNextItems.isSuccess && !upNextItems.data.TotalRecordCount ? (
|
||||
<></>
|
||||
) : (
|
||||
<CardScroller displayCards={4} title="Up Next">
|
||||
{upNextItems.data.Items.map((item) => {
|
||||
{upNextItems.data?.Items?.map((item) => {
|
||||
return (
|
||||
<Card
|
||||
key={item.Id}
|
||||
@@ -268,7 +258,7 @@ function Home() {
|
||||
imageType={
|
||||
item.Type === BaseItemKind.Episode
|
||||
? "Primary"
|
||||
: Object.keys(item.ImageTags).includes("Thumb")
|
||||
: item.ImageTags?.Thumb
|
||||
? "Thumb"
|
||||
: "Backdrop"
|
||||
}
|
||||
@@ -291,13 +281,7 @@ function Home() {
|
||||
}
|
||||
cardType="thumb"
|
||||
queryKey={["home", "upNext"]}
|
||||
userId={user.data.Id}
|
||||
imageBlurhash={
|
||||
!!item.ImageBlurHashes?.Primary &&
|
||||
item.ImageBlurHashes?.Primary[
|
||||
Object.keys(item.ImageBlurHashes.Primary)[0]
|
||||
]
|
||||
}
|
||||
userId={user.data?.Id}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
@@ -314,11 +298,11 @@ function Home() {
|
||||
{resumeItemsVideo.isPending ? (
|
||||
<CardsSkeleton />
|
||||
) : resumeItemsVideo.isSuccess &&
|
||||
resumeItemsVideo.data.Items.length === 0 ? (
|
||||
!resumeItemsVideo.data.TotalRecordCount ? (
|
||||
<></>
|
||||
) : (
|
||||
<CardScroller displayCards={4} title="Continue Watching">
|
||||
{resumeItemsVideo.data.Items.map((item) => {
|
||||
{resumeItemsVideo.data?.Items?.map((item) => {
|
||||
return (
|
||||
<Card
|
||||
key={item.Id}
|
||||
@@ -331,7 +315,7 @@ function Home() {
|
||||
imageType={
|
||||
item.Type === BaseItemKind.Episode
|
||||
? "Primary"
|
||||
: Object.keys(item.ImageTags).includes("Thumb")
|
||||
: item.ImageTags?.Thumb
|
||||
? "Thumb"
|
||||
: "Backdrop"
|
||||
}
|
||||
@@ -350,13 +334,7 @@ function Home() {
|
||||
}
|
||||
cardType="thumb"
|
||||
queryKey={["home", "resume", "video"]}
|
||||
userId={user.data.Id}
|
||||
imageBlurhash={
|
||||
!!item.ImageBlurHashes?.Primary &&
|
||||
item.ImageBlurHashes?.Primary[
|
||||
Object.keys(item.ImageBlurHashes.Primary)[0]
|
||||
]
|
||||
}
|
||||
userId={user.data?.Id}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
@@ -373,32 +351,21 @@ function Home() {
|
||||
{resumeItemsAudio.isPending ? (
|
||||
<CardsSkeleton />
|
||||
) : resumeItemsAudio.isSuccess &&
|
||||
resumeItemsAudio.data.Items.length === 0 ? (
|
||||
!resumeItemsAudio.data.TotalRecordCount ? (
|
||||
<></>
|
||||
) : (
|
||||
<CardScroller displayCards={4} title="Continue Listening">
|
||||
{resumeItemsAudio.data.Items.map((item) => {
|
||||
{resumeItemsAudio.data?.Items?.map((item) => {
|
||||
return (
|
||||
<Card
|
||||
key={item.Id}
|
||||
item={item}
|
||||
cardTitle={item.Name}
|
||||
imageType={
|
||||
item.Type === BaseItemKind.Episode
|
||||
? "Primary"
|
||||
: Object.keys(item.ImageTags).includes("Thumb")
|
||||
? "Thumb"
|
||||
: "Backdrop"
|
||||
}
|
||||
imageType="Primary"
|
||||
cardCaption={item.ProductionYear}
|
||||
cardType="thumb"
|
||||
queryKey={["home", "resume", "audio"]}
|
||||
userId={user.data.Id}
|
||||
imageBlurhash={
|
||||
item.ImageBlurHashes?.Primary?.[
|
||||
Object.keys(item.ImageBlurHashes.Primary)[0]
|
||||
]
|
||||
}
|
||||
userId={user.data?.Id}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
@@ -412,8 +379,8 @@ function Home() {
|
||||
</div>
|
||||
}
|
||||
>
|
||||
{latestMediaLibs.map((lib) => {
|
||||
return <LatestMediaSection key={lib[0]} latestMediaLib={lib} />;
|
||||
{latestMediaLibs?.map((lib) => {
|
||||
return <LatestMediaSection key={lib.Id} latestMediaLib={lib} />;
|
||||
})}
|
||||
</ErrorBoundary>
|
||||
</main>
|
||||
|
||||
@@ -26,7 +26,7 @@ import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useQuery, useSuspenseQuery } from "@tanstack/react-query";
|
||||
|
||||
import heroBg from "@/assets/herobg.png";
|
||||
import { Card } from "@/components/card/card";
|
||||
@@ -67,6 +67,7 @@ import sdrIcon from "@/assets/icons/sdr.svg";
|
||||
import type MediaQualityInfo from "@/utils/types/mediaQualityInfo";
|
||||
|
||||
import IconLink from "@/components/iconLink";
|
||||
import { queryClient } from "@/main";
|
||||
import { Link, createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
function TabPanel(props) {
|
||||
@@ -97,7 +98,6 @@ export const Route = createFileRoute("/_api/item/$id")({
|
||||
});
|
||||
|
||||
function ItemDetail() {
|
||||
"use memo";
|
||||
const { id } = Route.useParams();
|
||||
|
||||
const api = Route.useRouteContext().api;
|
||||
@@ -126,6 +126,8 @@ function ItemDetail() {
|
||||
refetchOnWindowFocus: true,
|
||||
});
|
||||
|
||||
// const item = useSuspenseQuery({ queryKey: ["item", id] });
|
||||
|
||||
const similarItems = useQuery({
|
||||
queryKey: ["item", id, "similarItem"],
|
||||
queryFn: async () => {
|
||||
|
||||
@@ -12,10 +12,10 @@ import { useSnackbar } from "notistack";
|
||||
|
||||
import { AppBarBackOnly } from "@/components/appBar/backOnly.jsx";
|
||||
import { AvatarImage } from "@/components/avatar/avatar.jsx";
|
||||
import { createApi } from "@/utils/store/api.js";
|
||||
import "./login.scss";
|
||||
|
||||
import { saveUser } from "@/utils/storage/user";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { setBackdrop } from "@/utils/store/backdrop.js";
|
||||
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||
import React, { useLayoutEffect, useState } from "react";
|
||||
@@ -27,7 +27,8 @@ export const Route = createFileRoute("/_api/login/$userId/$userName")({
|
||||
function LoginUser() {
|
||||
const { userName, userId } = Route.useParams();
|
||||
|
||||
const api = Route.useRouteContext().api;
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const createApi = useApiInContext((s) => s.createApi);
|
||||
|
||||
const [password, setPassword] = useState({
|
||||
showpass: false,
|
||||
|
||||
@@ -31,9 +31,9 @@ import { getQuickConnectApi } from "@jellyfin/sdk/lib/utils/api/quick-connect-ap
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice.jsx";
|
||||
import { createApi } from "@/utils/store/api.js";
|
||||
import "./login.scss";
|
||||
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { setBackdrop } from "@/utils/store/backdrop.js";
|
||||
import { blue } from "@mui/material/colors";
|
||||
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||
@@ -52,7 +52,8 @@ function LoginPublicUsersList() {
|
||||
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
|
||||
const api = Route.useRouteContext().api;
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const createApi = useApiInContext((s) => s.createApi);
|
||||
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [rememberMe, setRememberMe] = useState(true);
|
||||
|
||||
@@ -55,7 +55,7 @@ import TrailerButton from "@/components/buttons/trailerButton";
|
||||
import ShowMoreText from "@/components/showMoreText";
|
||||
import { SeasonSelectorSkeleton } from "@/components/skeleton/seasonSelector";
|
||||
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
import { setBackdrop, useBackdropStore } from "@/utils/store/backdrop";
|
||||
|
||||
import IconLink from "@/components/iconLink";
|
||||
import EpisodeSkeleton from "@/components/skeleton/episode";
|
||||
@@ -173,9 +173,10 @@ function SeriesTitlePage() {
|
||||
refetchOnWindowFocus: true,
|
||||
});
|
||||
|
||||
const [backdropImage, setBackdropImage] = useState(() => {
|
||||
const result = sessionStorage.getItem(`backdrop-${item.data?.Id}`);
|
||||
return result ?? "0";
|
||||
const [backdropImage, setBackdropImage] = useState<SeriesBackdropImage>(() => {
|
||||
const url = sessionStorage.getItem(`backdrop-${item.data?.Id}`);
|
||||
const key = sessionStorage.getItem(`backdrop-${item.data?.Id}-key`);
|
||||
return { url, key };
|
||||
});
|
||||
const [backdropImageLoaded, setBackdropImageLoaded] = useState(false);
|
||||
|
||||
@@ -226,7 +227,6 @@ function SeriesTitlePage() {
|
||||
},
|
||||
enabled: item.isSuccess,
|
||||
});
|
||||
const [setAppBackdrop] = useBackdropStore((state) => [state.setBackdrop]);
|
||||
|
||||
const [directors, setDirectors] = useState([]);
|
||||
const [writers, setWriters] = useState([]);
|
||||
@@ -235,17 +235,18 @@ function SeriesTitlePage() {
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (item.isSuccess) {
|
||||
setBackdropImage(
|
||||
api.getItemImageUrl(item.data?.Id, "Backdrop", {
|
||||
tag: item.data?.BackdropImageTags[0],
|
||||
}),
|
||||
);
|
||||
setAppBackdrop(
|
||||
api.getItemImageUrl(item.data?.Id, "Backdrop", {
|
||||
tag: item.data?.BackdropImageTags[0],
|
||||
}),
|
||||
item.data.Id,
|
||||
);
|
||||
// setBackdropImage({
|
||||
// url: api.getItemImageUrl(item.data?.Id, "Backdrop", {
|
||||
// tag: item.data?.BackdropImageTags[0],
|
||||
// }),
|
||||
// key: item.data?.BackdropImageTags[0],
|
||||
// });
|
||||
// setBackdrop(
|
||||
// api.getItemImageUrl(item.data?.Id, "Backdrop", {
|
||||
// tag: item.data?.BackdropImageTags[0],
|
||||
// }),
|
||||
// item.data.Id,
|
||||
// );
|
||||
const direTp = item.data.People.filter((itm) => itm.Type === "Director");
|
||||
setDirectors(direTp);
|
||||
const writeTp = item.data.People.filter((itm) => itm.Type === "Writer");
|
||||
@@ -286,13 +287,17 @@ function SeriesTitlePage() {
|
||||
tag: currentSeasonItem.data.BackdropImageTags[0],
|
||||
}),
|
||||
);
|
||||
setBackdropImage(
|
||||
api.getItemImageUrl(currentSeasonItem.data.Id, "Backdrop", {
|
||||
tag: currentSeasonItem.data.BackdropImageTags[0],
|
||||
}),
|
||||
currentSeasonItem.data.Id,
|
||||
sessionStorage.setItem(
|
||||
`backdrop-${item.data?.Id}-key`,
|
||||
currentSeasonItem.data.BackdropImageTags[0],
|
||||
);
|
||||
setAppBackdrop(
|
||||
setBackdropImage({
|
||||
url: api.getItemImageUrl(item.data?.Id, "Backdrop", {
|
||||
tag: item.data?.BackdropImageTags[0],
|
||||
}),
|
||||
key: item.data?.BackdropImageTags[0],
|
||||
});
|
||||
setBackdrop(
|
||||
api.getItemImageUrl(currentSeasonItem.data.Id, "Backdrop", {
|
||||
tag: currentSeasonItem.data.BackdropImageTags[0],
|
||||
}),
|
||||
@@ -306,13 +311,17 @@ function SeriesTitlePage() {
|
||||
tag: item.data.BackdropImageTags[0],
|
||||
}),
|
||||
);
|
||||
setBackdropImage(
|
||||
api.getItemImageUrl(item.data.Id, "Backdrop", {
|
||||
tag: item.data.BackdropImageTags[0],
|
||||
}),
|
||||
item.data.Id,
|
||||
sessionStorage.setItem(
|
||||
`backdrop-${item.data?.Id}-key`,
|
||||
currentSeasonItem.data.BackdropImageTags[0],
|
||||
);
|
||||
setAppBackdrop(
|
||||
setBackdropImage({
|
||||
url: api.getItemImageUrl(item.data?.Id, "Backdrop", {
|
||||
tag: item.data?.BackdropImageTags[0],
|
||||
}),
|
||||
key: item.data?.BackdropImageTags[0],
|
||||
});
|
||||
setBackdrop(
|
||||
api.getItemImageUrl(item.data.Id, "Backdrop", {
|
||||
tag: item.data.BackdropImageTags[0],
|
||||
}),
|
||||
@@ -369,9 +378,9 @@ function SeriesTitlePage() {
|
||||
<AnimatePresence mode="wait">
|
||||
{item.data.BackdropImageTags ? (
|
||||
<motion.img
|
||||
key={currentSeasonItem.dataUpdatedAt}
|
||||
key={backdropImage.key}
|
||||
alt={item.data.Name}
|
||||
src={backdropImage}
|
||||
src={backdropImage.url}
|
||||
className="item-hero-backdrop"
|
||||
initial={{
|
||||
opacity: 0,
|
||||
|
||||
@@ -14,12 +14,12 @@ import {
|
||||
setDefaultServer,
|
||||
} from "@/utils/storage/servers";
|
||||
import { delUser } from "@/utils/storage/user";
|
||||
import { createApi } from "@/utils/store/api";
|
||||
import { setBackdrop } from "@/utils/store/backdrop";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||
import { useSnackbar } from "notistack";
|
||||
import "./serverList.scss";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
|
||||
export const Route = createFileRoute("/setup/server/list")({
|
||||
component: ServerList,
|
||||
@@ -30,6 +30,8 @@ function ServerList() {
|
||||
const [serverState, setServerState] = useState(null);
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
|
||||
const createApi = useApiInContext((s) => s.createApi);
|
||||
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const servers = useQuery({
|
||||
|
||||
+8
-28
@@ -1,5 +1,6 @@
|
||||
import { type Api, Jellyfin } from "@jellyfin/sdk";
|
||||
import React, { createContext, useContext, useRef, useState } from "react";
|
||||
import React, { type ReactNode } from "react";
|
||||
import { createContext, useContext, useState } from "react";
|
||||
import { type StoreApi, createStore, useStore } from "zustand";
|
||||
import { version as appVer } from "../../../package.json";
|
||||
|
||||
@@ -11,10 +12,7 @@ type ApiStore = {
|
||||
api: Api;
|
||||
deviceId: string | null;
|
||||
jellyfin: Jellyfin;
|
||||
createApi: (
|
||||
serverAddress: string | undefined,
|
||||
accessToken?: string | undefined,
|
||||
) => void;
|
||||
createApi: (serverAddress: string, accessToken?: string | undefined) => void;
|
||||
};
|
||||
|
||||
export const axiosClient = axios.create({
|
||||
@@ -42,22 +40,12 @@ export const jellyfin = new Jellyfin({
|
||||
},
|
||||
});
|
||||
|
||||
// export const useApi = create<{
|
||||
// api: Api;
|
||||
// deviceId: string | null;
|
||||
// jellyfin: Jellyfin;
|
||||
// }>(() => ({
|
||||
// api: undefined,
|
||||
// deviceId: deviceId,
|
||||
// jellyfin: jellyfin,
|
||||
// }));
|
||||
export const ApiContext = createContext<StoreApi<ApiStore>>(undefined!);
|
||||
|
||||
export const ApiContext = createContext(null);
|
||||
|
||||
export const ApiProvider = ({ children }) => {
|
||||
export const ApiProvider = ({ children }: { children: ReactNode }) => {
|
||||
const [store] = useState(() =>
|
||||
createStore<ApiStore>()((set) => ({
|
||||
api: undefined,
|
||||
api: undefined!,
|
||||
deviceId: deviceId,
|
||||
jellyfin: jellyfin,
|
||||
createApi: (serverAddress, accessToken?) =>
|
||||
@@ -74,7 +62,7 @@ export const ApiProvider = ({ children }) => {
|
||||
};
|
||||
}),
|
||||
})),
|
||||
)
|
||||
);
|
||||
return <ApiContext.Provider value={store}>{children}</ApiContext.Provider>;
|
||||
};
|
||||
|
||||
@@ -84,12 +72,4 @@ export function useApiInContext<T>(selector?: (state: ApiStore) => T) {
|
||||
throw new Error("Missing StoreProvider");
|
||||
}
|
||||
return useStore(store, selector!);
|
||||
}
|
||||
|
||||
export const createApi = (
|
||||
serverAddress: string | undefined,
|
||||
accessToken: string | undefined,
|
||||
) => {
|
||||
const createApiFn = useApiInContext((s) => s.createApi);
|
||||
createApiFn(serverAddress, accessToken);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
type SeriesBackdropImage = {
|
||||
url?: string | null;
|
||||
key?: string | null;
|
||||
};
|
||||
Reference in new issue
Block a user