Files
Blink/src/components/skeleton/musicPage.tsx
T
1xDed 2a0478fc16
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
fix(ui): match loading skeletons to real pages
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.
2026-12-03 09:45:50 +03:00

112 lines
3.1 KiB
TypeScript

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;