fix(ui): match loading skeletons to real pages
Continuous Integration / build_web (push) Failing after 1s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped

Measure the library grid instead of guessing from the viewport, reuse the card scroller for search and latest rows, mirror item/music page structure, and add skeleton sections to the home placeholder.
This commit is contained in:
1xDed committed 2026-12-03 09:45:50 +03:00
1 parent 497b9a2fc5
commit 2a0478fc16
14 files changed
+348 -287

No files matched your search

@@ -26,7 +26,7 @@ export const LatestMediaSection = ({
getLibraryLatestQueryOptions(api, user?.Id, latestMediaLib.Id), getLibraryLatestQueryOptions(api, user?.Id, latestMediaLib.Id),
); );
if (data.isPending) { if (data.isPending) {
return <CardsSkeleton />; return <CardsSkeleton title={`Latest ${latestMediaLib.Name}`} />;
} }
if (data.isSuccess && (data.data?.length ?? 0) >= 1) { if (data.isSuccess && (data.data?.length ?? 0) >= 1) {
return ( return (
+34 -30
View File
@@ -1,34 +1,38 @@
import Skeleton from "@mui/material/Skeleton"; import Skeleton from "@mui/material/Skeleton";
import Typography from "@mui/material/Typography";
import React from "react"; import React from "react";
import CardScroller from "@/components/cardScroller/cardScroller";
export const CardsSkeleton = () => { export const CardsSkeleton = ({
return ( title = "Загрузка",
<div displayCards = 7,
style={{ }: {
display: "flex", title?: string;
flexFlow: "column", displayCards?: number;
marginBottom: "2em", }) => (
}} <CardScroller title={title} displayCards={displayCards} disableDecoration>
> {Array.from({ length: displayCards }, (_, index) => (
<Typography variant="h3" sx={{ mb: "0.15em" }}> <CardSkeleton
<Skeleton width="35%" /> // biome-ignore lint/suspicious/noArrayIndexKey: static skeleton slides
</Typography> key={`card-skeleton-${index}`}
<div className="flex flex-align-center" style={{ height: "17em" }}> />
{Array.from({ length: 12 }).map((_, index) => ( ))}
<Skeleton </CardScroller>
height="26em" );
sx={{
flex: "1 0 12.45%",
marginRight: "1.5em", export const CardSkeleton = ({
borderRadius: "10px", cardType = "portrait",
animationDelay: `${index * 0.25}s`, }: {
}} cardType?: "portrait" | "square" | "thumb";
// biome-ignore lint/suspicious/noArrayIndexKey: This is a skeleton component }) => (
key={index} <div className="card skeleton-card">
/> <div className={`card-image-container ${cardType}`}>
))} <Skeleton
</div> variant="rectangular"
sx={{ width: "100%", height: "100%", position: "absolute", inset: 0 }}
/>
</div> </div>
); <Skeleton variant="text" sx={{ width: "78%", height: 18, mt: "8px" }} />
}; <Skeleton variant="text" sx={{ width: "46%", height: 14 }} />
</div>
);
+38 -85
View File
@@ -1,123 +1,76 @@
import React from "react";
import { Skeleton } from "@mui/material"; import { Skeleton } from "@mui/material";
import { motion } from "motion/react"; import { motion } from "motion/react";
import React from "react";
import "@/components/itemDetail/itemDetail.scss";
import "@/components/itemHeader/itemHeader.scss";
const ItemSkeleton = () => { const ItemSkeleton = () => {
return ( return (
<motion.div <motion.div
className="item item-detail-page item-default scrollY padded-top flex flex-column" className="item item-detail-page item-default scrollY padded-top flex flex-column"
style={{ initial={{ opacity: 0 }}
width: "100vw", animate={{ opacity: 1 }}
}} exit={{ opacity: 0 }}
initial={{
opacity: 0,
}}
animate={{
opacity: 1,
}}
exit={{
opacity: 0,
}}
> >
<div className="item-hero"> <div className="item-hero">
<div <div className="item-hero-image-container">
className="item-hero-image-container"
style={{
aspectRatio: 0.6666,
boxShadow: "0 0 black",
}}
>
<Skeleton <Skeleton
variant="rounded" variant="rounded"
style={{ sx={{
height: "50vh", width: "100%",
height: "auto",
aspectRatio: "2 / 3",
borderRadius: "8px",
}} }}
/> />
</div> </div>
<div <div className="item-hero-detail flex flex-column">
className="item-hero-detail flex flex-column" <Skeleton
style={ variant="text"
{ sx={{
// width: "50vw", fontSize: "clamp(2rem, 4vw, 3.4rem)",
} width: "72%",
} maxWidth: "34rem",
> }}
<Skeleton variant="text" sx={{ fontSize: "4rem" }} width="50%" /> />
{/* </Typography> */}
<div <div
className="item-hero-buttons-container flex flex-row" className="item-hero-buttons-container flex flex-row"
style={{ style={{ width: "100%", gap: "0.8em", flexWrap: "wrap" }}
width: "70%",
gap: "1em",
justifyContent: "flex-start",
}}
> >
<Skeleton <Skeleton
width="10rem" variant="rounded"
width="12rem"
height="3rem" height="3rem"
sx={{ sx={{ borderRadius: "999px" }}
fontSize: "3rem",
borderRadius: "3em",
transform: "scale(1)",
}}
/> />
<div className="flex flex-row" style={{ gap: "1em" }}> <div className="flex flex-row" style={{ gap: "0.8em" }}>
<Skeleton <Skeleton variant="circular" width="3rem" height="3rem" />
width="3rem" <Skeleton variant="circular" width="3rem" height="3rem" />
height="3rem" <Skeleton variant="circular" width="3rem" height="3rem" />
sx={{
fontSize: "3rem",
borderRadius: "3em",
transform: "scale(1)",
aspectRatio: "1",
}}
/>
<Skeleton
width="3rem"
height="3rem"
sx={{
fontSize: "3rem",
borderRadius: "3em",
transform: "scale(1)",
aspectRatio: "1",
}}
/>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div className="item-detail"> <div className="item-detail">
<div style={{ width: "100%" }}> <div style={{ width: "100%" }}>
<Skeleton variant="text" /> <Skeleton variant="text" width="92%" />
<Skeleton variant="text" /> <Skeleton variant="text" width="100%" />
<Skeleton variant="text" /> <Skeleton variant="text" width="84%" />
<Skeleton variant="text" width="58%" />
</div> </div>
<div <div style={{ width: "100%" }}>
style={{
width: "100%",
}}
>
<Skeleton <Skeleton
variant="rounded" variant="rounded"
sx={{ sx={{ width: "100%", height: "2.8rem", mb: 1, borderRadius: "8px" }}
fontSize: "2.4rem",
mb: 1,
}}
/> />
<Skeleton <Skeleton
variant="rounded" variant="rounded"
sx={{ sx={{ width: "100%", height: "2.8rem", mb: 1, borderRadius: "8px" }}
fontSize: "2.4rem",
mb: 1,
}}
/> />
<Skeleton <Skeleton
variant="rounded" variant="rounded"
sx={{ sx={{ width: "100%", height: "2.8rem", borderRadius: "8px" }}
fontSize: "2.4rem",
}}
/> />
</div> </div>
</div> </div>
+59 -47
View File
@@ -1,5 +1,5 @@
import { Skeleton } from "@mui/material"; import { Skeleton } from "@mui/material";
import React from "react"; import React, { useLayoutEffect, useRef, useState } from "react";
type LibraryItemsSkeletonProps = { type LibraryItemsSkeletonProps = {
/** Square artwork (music, playlists, genres) instead of portrait posters. */ /** Square artwork (music, playlists, genres) instead of portrait posters. */
@@ -7,65 +7,77 @@ type LibraryItemsSkeletonProps = {
}; };
/** /**
* Placeholder that matches the virtualized library grid: same card width, * Placeholder that matches the virtualized library grid: measured against the
* gap and text block. A mismatched skeleton was making the real cards resize * real grid container, the same gap and the same three rows of cards. Keeping
* when the first page of items arrived. * the width measured instead of derived from the viewport means the mobile
* page margins cannot turn the two-column grid into one giant card.
*/ */
const LibraryItemsSkeleton = ({ const LibraryItemsSkeleton = ({
square = false, square = false,
}: LibraryItemsSkeletonProps) => { }: LibraryItemsSkeletonProps) => {
const viewportWidth = const ref = useRef<HTMLDivElement | null>(null);
typeof window === "undefined" const [width, setWidth] = useState(0);
? 1200
: document.documentElement.clientWidth || window.innerWidth; useLayoutEffect(() => {
// Same inset as `.library-items` (4em on each side) used by the real grid. const element = ref.current;
const width = Math.max(0, viewportWidth - 128); if (!element) return;
const update = () => setWidth(element.clientWidth);
update();
const observer = new ResizeObserver(update);
observer.observe(element);
return () => observer.disconnect();
}, []);
const minCardWidth = width < 700 ? 140 : 180; const minCardWidth = width < 700 ? 140 : 180;
const columns = Math.max(1, Math.floor(width / minCardWidth)); const columns = width > 0 ? Math.max(1, Math.floor(width / minCardWidth)) : 0;
const gap = 16; const gap = 16;
const cardWidth = Math.max( const cardWidth =
1, columns > 0
Math.floor((width - (columns - 1) * gap) / columns), ? Math.max(1, Math.floor((width - (columns - 1) * gap) / columns))
); : 0;
const count = columns * 3; const placeholders = Array.from({ length: columns * 3 }, (_, index) => ({
const placeholders = Array.from({ length: count }, (_, index) => ({
id: `library-skeleton-${index}`, id: `library-skeleton-${index}`,
})); }));
return ( return (
<div <div ref={ref} style={{ width: "100%" }}>
style={{ {columns > 0 && (
display: "flex",
flexWrap: "wrap",
gap,
width: "100%",
alignItems: "flex-start",
}}
>
{placeholders.map((placeholder) => (
<div <div
key={placeholder.id} style={{
style={{ width: cardWidth, flex: "0 0 auto", minWidth: 0 }} display: "flex",
flexWrap: "wrap",
gap,
width: "100%",
alignItems: "flex-start",
}}
> >
<Skeleton {placeholders.map((placeholder) => (
variant="rounded" <div
sx={{ key={placeholder.id}
width: "100%", style={{ width: cardWidth, flex: "0 0 auto", minWidth: 0 }}
height: "auto", >
aspectRatio: square ? 1 : 0.6666, <Skeleton
borderRadius: "10px", variant="rounded"
}} sx={{
/> width: "100%",
<Skeleton height: "auto",
variant="text" aspectRatio: square ? 1 : 0.6666,
sx={{ width: "82%", height: 18, mt: "8px", mb: 0 }} borderRadius: "10px",
/> }}
<Skeleton />
variant="text" <Skeleton
sx={{ width: "52%", height: 16, mt: 0, mb: 0 }} variant="text"
/> sx={{ width: "82%", height: 18, mt: "8px", mb: 0 }}
/>
<Skeleton
variant="text"
sx={{ width: "52%", height: 16, mt: 0, mb: 0 }}
/>
</div>
))}
</div> </div>
))} )}
</div> </div>
); );
}; };
+111
View File
@@ -0,0 +1,111 @@
import { Skeleton } from "@mui/material";
import React from "react";
import "@/components/albumMusicTrack/albumMusicTrack.scss";
type MusicPageSkeletonProps = {
/** Artist pages open on a round portrait and a discography grid. */
artist?: boolean;
};
const ALBUM_SKELETONS = ["one", "two", "three", "four", "five"];
const TRACK_SKELETONS = [
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
];
const AlbumCardSkeleton = () => (
<div>
<Skeleton
variant="rounded"
sx={{ width: "100%", aspectRatio: "1", borderRadius: "10px" }}
/>
<Skeleton variant="text" sx={{ width: "76%", height: 18, mt: "8px" }} />
<Skeleton variant="text" sx={{ width: "42%", height: 14 }} />
</div>
);
const MusicPageSkeleton = ({ artist = false }: MusicPageSkeletonProps) => (
<div className="scrollY padded-top music-page" aria-busy="true">
<header className={`music-hero${artist ? " music-hero-artist" : ""}`}>
<div className={artist ? "music-portrait" : "music-cover"}>
<Skeleton
variant={artist ? "circular" : "rounded"}
sx={{
width: "100%",
height: "100%",
aspectRatio: "1",
borderRadius: artist ? "50%" : "6px",
}}
/>
</div>
<div className="music-hero-info">
<Skeleton variant="text" sx={{ width: 110, height: 14 }} />
<Skeleton
variant="text"
sx={{
width: "68%",
maxWidth: 620,
height: "clamp(2.7rem, 5vw, 4.2rem)",
my: "0.35em",
}}
/>
<Skeleton variant="text" sx={{ width: 180 }} />
<Skeleton variant="text" sx={{ width: 230, mt: "0.4em" }} />
<div className="music-actions">
<Skeleton
variant="rounded"
width={172}
height={48}
sx={{ borderRadius: "999px" }}
/>
<Skeleton variant="circular" width={44} height={44} />
<Skeleton variant="circular" width={44} height={44} />
</div>
</div>
</header>
{artist ? (
<>
<div className="music-tabs">
<Skeleton variant="rounded" width={120} height={34} sx={{ borderRadius: 999 }} />
<Skeleton variant="rounded" width={96} height={34} sx={{ borderRadius: 999 }} />
<Skeleton variant="rounded" width={100} height={34} sx={{ borderRadius: 999 }} />
</div>
<div className="music-album-grid">
{ALBUM_SKELETONS.map((id) => (
<AlbumCardSkeleton key={`artist-album-${id}`} />
))}
</div>
</>
) : (
<section className="music-tracks" aria-label="Загрузка треков">
<div className="music-tracks-head">
<Skeleton variant="text" width={24} />
<Skeleton variant="text" width={120} />
<Skeleton variant="text" width={60} />
<Skeleton variant="text" width={32} />
</div>
{TRACK_SKELETONS.map((id) => (
<div className="album-track" key={`music-track-${id}`}>
<Skeleton variant="text" width={16} />
<div className="album-track-info">
<Skeleton variant="text" sx={{ width: "52%", height: 18 }} />
<Skeleton variant="text" sx={{ width: "34%", height: 14 }} />
</div>
<Skeleton variant="text" width={38} />
<Skeleton variant="circular" width={24} height={24} />
</div>
))}
</section>
)}
</div>
);
export default MusicPageSkeleton;
+35 -43
View File
@@ -1,52 +1,44 @@
import Divider from "@mui/material/Divider"; import Divider from "@mui/material/Divider";
import Grid2 from "@mui/material/Grid";
import Skeleton from "@mui/material/Skeleton"; import Skeleton from "@mui/material/Skeleton";
import Typography from "@mui/material/Typography";
import React from "react"; import React from "react";
import EpisodeSkeleton from "./episode"; import EpisodeSkeleton from "./episode";
export const SeasonSelectorSkeleton = () => { export const SeasonSelectorSkeleton = () => (
return ( <div className="item-series-seasons-container" aria-busy="true">
<Grid2 <div
container style={{
columns={{ display: "flex",
xs: 2, width: "100%",
sm: 3, alignItems: "center",
md: 4, justifyContent: "space-between",
paddingBottom: "0.5em",
}} }}
sx={{ width: "100%" }}
> >
<div <div style={{ display: "flex", gap: "1em", alignItems: "center" }}>
style={{ <Skeleton variant="text" width={220} sx={{ fontSize: "1.5rem" }} />
display: "flex", <Skeleton
gap: "1em", variant="rounded"
justifyContent: "space-between", width={36}
width: "100%", height={24}
}} sx={{ borderRadius: 999 }}
> />
<Typography variant="h3">
<Skeleton width={320} variant="text" animation="wave" />
</Typography>
<Skeleton animation="wave" height={64} width={128} />
</div> </div>
<Divider <div style={{ display: "flex", gap: "0.75em", alignItems: "center" }}>
style={{ <Skeleton variant="circular" width={32} height={32} />
display: "block", <Skeleton variant="circular" width={32} height={32} />
width: "100%", <Skeleton
}} variant="rounded"
/> width={110}
<div height={36}
style={{ sx={{ borderRadius: "8px" }}
display: "flex", />
width: "100%",
alignItems: "center",
justifyContent: "space-between",
paddingBottom: " 0.5em",
}}
/>
<div className="item-detail-episode-container">
<EpisodeSkeleton />
</div> </div>
</Grid2> </div>
); <Divider />
}; <div className="item-detail-episode-container">
<EpisodeSkeleton />
</div>
</div>
);
export default SeasonSelectorSkeleton;
+15
View File
@@ -124,6 +124,7 @@ body.has-player-bar .home-sections {
.home-skeleton-cards { .home-skeleton-cards {
display: flex; display: flex;
gap: 0.75rem; gap: 0.75rem;
overflow: hidden;
} }
.home-skeleton-cards span { .home-skeleton-cards span {
@@ -180,3 +181,17 @@ body.has-player-bar .home-sections {
padding: 2rem 1.1rem calc(8rem + var(--safe-bottom)); padding: 2rem 1.1rem calc(8rem + var(--safe-bottom));
} }
} }
.home-skeleton-sections {
gap: 1.8em;
}
.home-skeleton-row {
display: flex;
flex-direction: column;
}
.home-skeleton-row .home-skeleton-heading {
margin-bottom: 0.9em;
}
+12
View File
@@ -200,6 +200,18 @@ function HomeContent({ api, user }: { api: Api; user: UserDto }) {
</div> </div>
</section> </section>
</div> </div>
<div className="home-sections home-skeleton-sections">
{[0, 1, 2].map((row) => (
<div className="home-skeleton-row" key={`home-skeleton-row-${row}`}>
<span className="home-skeleton-heading" />
<div className="home-skeleton-cards">
{[0, 1, 2, 3].map((card) => (
<span key={`home-skeleton-card-${row}-${card}`} />
))}
</div>
</div>
))}
</div>
</main> </main>
); );
} }
+12 -10
View File
@@ -109,16 +109,18 @@ function Library() {
> >
<Suspense <Suspense
fallback={ fallback={
<LibraryItemsSkeleton <div className="library-items">
square={ <LibraryItemsSkeleton
currentViewType === BaseItemKind.MusicAlbum || square={
currentViewType === BaseItemKind.Audio || currentViewType === BaseItemKind.MusicAlbum ||
currentViewType === BaseItemKind.Genre || currentViewType === BaseItemKind.Audio ||
currentViewType === BaseItemKind.MusicGenre || currentViewType === BaseItemKind.Genre ||
currentViewType === BaseItemKind.Studio || currentViewType === BaseItemKind.MusicGenre ||
currentViewType === BaseItemKind.Playlist currentViewType === BaseItemKind.Studio ||
} currentViewType === BaseItemKind.Playlist
/> }
/>
</div>
} }
> >
<div className="library-items"> <div className="library-items">
+1 -2
View File
@@ -227,7 +227,6 @@
} }
.library-items { .library-items {
padding-top: 0.5rem !important; padding: 0.5rem 0.75rem calc(7.5em + var(--safe-bottom)) !important;
padding-bottom: calc(7.5em + var(--safe-bottom)) !important;
} }
} }
+2 -15
View File
@@ -1,7 +1,5 @@
import { BaseItemKind, SortOrder } from "@jellyfin/sdk/lib/generated-client"; import { BaseItemKind, SortOrder } from "@jellyfin/sdk/lib/generated-client";
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api"; import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
import Box from "@mui/material/Box";
import CircularProgress from "@mui/material/CircularProgress";
import { useQuery } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query";
import { createFileRoute, Link } from "@tanstack/react-router"; import { createFileRoute, Link } from "@tanstack/react-router";
import React, { useLayoutEffect, useMemo } from "react"; import React, { useLayoutEffect, useMemo } from "react";
@@ -13,6 +11,7 @@ import RatingControl from "@/components/buttons/ratingControl";
import { Card } from "@/components/card/card"; import { Card } from "@/components/card/card";
import CardScroller from "@/components/cardScroller/cardScroller"; import CardScroller from "@/components/cardScroller/cardScroller";
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice"; import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
import MusicPageSkeleton from "@/components/skeleton/musicPage";
import ShowMoreText from "@/components/showMoreText"; import ShowMoreText from "@/components/showMoreText";
import TagChip from "@/components/tagChip"; import TagChip from "@/components/tagChip";
import { getTypeIcon } from "@/components/utils/iconsCollection"; import { getTypeIcon } from "@/components/utils/iconsCollection";
@@ -130,19 +129,7 @@ function MusicAlbumTitlePage() {
}, [item.isSuccess, item.data, setBackdrop]); }, [item.isSuccess, item.data, setBackdrop]);
if (item.isPending) { if (item.isPending) {
return ( return <MusicPageSkeleton />;
<Box
sx={{
width: "100%",
height: "100vh",
display: "flex",
alignItems: "center",
justifyContent: "center",
}}
>
<CircularProgress />
</Box>
);
} }
if (item.isError) { if (item.isError) {
+2 -15
View File
@@ -6,8 +6,6 @@ import {
SortOrder, SortOrder,
} from "@jellyfin/sdk/lib/generated-client"; } from "@jellyfin/sdk/lib/generated-client";
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api"; import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
import Box from "@mui/material/Box";
import CircularProgress from "@mui/material/CircularProgress";
import IconButton from "@mui/material/IconButton"; import IconButton from "@mui/material/IconButton";
import Tooltip from "@mui/material/Tooltip"; import Tooltip from "@mui/material/Tooltip";
import { useQuery } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query";
@@ -21,6 +19,7 @@ import RatingControl from "@/components/buttons/ratingControl";
import { Card } from "@/components/card/card"; import { Card } from "@/components/card/card";
import IconLink from "@/components/iconLink"; import IconLink from "@/components/iconLink";
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice"; import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
import MusicPageSkeleton from "@/components/skeleton/musicPage";
import ShowMoreText from "@/components/showMoreText"; import ShowMoreText from "@/components/showMoreText";
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi"; import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
import { useBackdropStore } from "@/utils/store/backdrop"; import { useBackdropStore } from "@/utils/store/backdrop";
@@ -195,19 +194,7 @@ function ArtistTitlePage() {
].filter(Boolean); ].filter(Boolean);
if (item.isPending) { if (item.isPending) {
return ( return <MusicPageSkeleton artist />;
<Box
sx={{
width: "100%",
height: "100vh",
display: "flex",
alignItems: "center",
justifyContent: "center",
}}
>
<CircularProgress />
</Box>
);
} }
if (item.isError) { if (item.isError) {
+2 -15
View File
@@ -1,8 +1,6 @@
import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client"; import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api"; import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
import { getPlaylistApi } from "@jellyfin/sdk/lib/utils/api/playlist-api"; import { getPlaylistApi } from "@jellyfin/sdk/lib/utils/api/playlist-api";
import Box from "@mui/material/Box";
import CircularProgress from "@mui/material/CircularProgress";
import { useQuery } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query";
import { createFileRoute } from "@tanstack/react-router"; import { createFileRoute } from "@tanstack/react-router";
import React, { useEffect } from "react"; import React, { useEffect } from "react";
@@ -13,6 +11,7 @@ import RatingControl from "@/components/buttons/ratingControl";
import { Card } from "@/components/card/card"; import { Card } from "@/components/card/card";
import CardScroller from "@/components/cardScroller/cardScroller"; import CardScroller from "@/components/cardScroller/cardScroller";
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice"; import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
import MusicPageSkeleton from "@/components/skeleton/musicPage";
import ShowMoreText from "@/components/showMoreText"; import ShowMoreText from "@/components/showMoreText";
import TagChip from "@/components/tagChip"; import TagChip from "@/components/tagChip";
import { getTypeIcon } from "@/components/utils/iconsCollection"; import { getTypeIcon } from "@/components/utils/iconsCollection";
@@ -100,19 +99,7 @@ function PlaylistTitlePage() {
}, [item.isSuccess, setAppBackdrop]); }, [item.isSuccess, setAppBackdrop]);
if (item.isPending) { if (item.isPending) {
return ( return <MusicPageSkeleton />;
<Box
sx={{
width: "100%",
height: "100vh",
display: "flex",
alignItems: "center",
justifyContent: "center",
}}
>
<CircularProgress />
</Box>
);
} }
if (item.isError) { if (item.isError) {
+24 -24
View File
@@ -6,6 +6,7 @@ import { useQuery } from "@tanstack/react-query";
import React, { useEffect, useMemo, useState } from "react"; import React, { useEffect, useMemo, useState } from "react";
import { Card } from "@/components/card/card"; import { Card } from "@/components/card/card";
import CardScroller from "@/components/cardScroller/cardScroller"; import CardScroller from "@/components/cardScroller/cardScroller";
import { CardSkeleton } from "@/components/skeleton/cards";
import { useBackdropStore } from "@/utils/store/backdrop"; import { useBackdropStore } from "@/utils/store/backdrop";
import "./search.scss"; import "./search.scss";
import { import {
@@ -424,7 +425,7 @@ function CategorySection({ category, query, api, user, onResult }: any) {
} }
}, [data, isLoading, onResult]); }, [data, isLoading, onResult]);
if (isLoading) return <CategorySkeleton />; if (isLoading) return <CategorySkeleton category={category} />;
if (!data?.items || data.items.length === 0) return null; if (!data?.items || data.items.length === 0) return null;
// ... (Card mapping logic same as before) ... // ... (Card mapping logic same as before) ...
@@ -477,31 +478,30 @@ function CategorySection({ category, query, api, user, onResult }: any) {
); );
} }
function CategorySkeleton() { function CategorySkeleton({ category }: { category: any }) {
const displayCards = category.value === "Episode" ? 4 : 7;
const cardType =
category.value === "Episode"
? "thumb"
: ["MusicAlbum", "MusicArtist", "Person"].includes(category.value)
? "square"
: "portrait";
return ( return (
<Box sx={{ mb: 4, ml: 2, mr: 2 }}> <div aria-busy="true">
<Box <CardScroller
sx={{ title={category.label}
height: 32, displayCards={displayCards}
width: 200, disableDecoration
bgcolor: "rgba(255,255,255,0.05)", >
borderRadius: 2, {Array.from({ length: displayCards }, (_, index) => (
mb: 2, <CardSkeleton
}} // biome-ignore lint/suspicious/noArrayIndexKey: static skeleton slides
/> key={`${category.value}-skeleton-${index}`}
<Box sx={{ display: "flex", gap: 2, overflow: "hidden" }}> cardType={cardType}
{[1, 2, 3, 4, 5, 6].map((i) => (
<Box
key={i}
sx={{
height: 260,
minWidth: 170,
bgcolor: "rgba(255,255,255,0.03)",
borderRadius: 3,
}}
/> />
))} ))}
</Box> </CardScroller>
</Box> </div>
); );
} }