refactore: move more components to typescript
This commit is contained in:
14 files changed
+437
-575
No files matched your search
@@ -0,0 +1,60 @@
|
|||||||
|
.item-info-track{
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 3em 60% 6em 1fr;
|
||||||
|
gap: 1em;
|
||||||
|
padding: 1em;
|
||||||
|
align-items: center;
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: $border-radius-default;
|
||||||
|
transition: background $transition-time-fast;
|
||||||
|
&.header {
|
||||||
|
border-bottom: 1px solid rgb(255 255 255 / 0.2);
|
||||||
|
color: rgb(255 255 255 / 0.7);
|
||||||
|
border-radius: 0 !important;
|
||||||
|
}
|
||||||
|
.index-container {
|
||||||
|
justify-self: center;
|
||||||
|
position: relative;
|
||||||
|
.material-symbols-rounded {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
font-size: 2em !important;
|
||||||
|
opacity: 0;
|
||||||
|
transition: none !important;
|
||||||
|
color: $clr-accent-default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-info {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.1em
|
||||||
|
}
|
||||||
|
&:hover {
|
||||||
|
background: rgb(255 255 255 / 0.1) !important;
|
||||||
|
.index-container {
|
||||||
|
// font-size: 0em;
|
||||||
|
.index {
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0;
|
||||||
|
}
|
||||||
|
.material-symbols-rounded {
|
||||||
|
opacity: 1;
|
||||||
|
font-size: 2.2em !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&.playing {
|
||||||
|
background: rgb(0 0 0 / 0.4) !important;
|
||||||
|
.item-info-track-info-name, .index {
|
||||||
|
color: $clr-accent-default;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.4em
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
import {
|
||||||
|
generateAudioStreamUrl,
|
||||||
|
playAudio,
|
||||||
|
useAudioPlayback,
|
||||||
|
} from "@/utils/store/audioPlayback";
|
||||||
|
import type {
|
||||||
|
BaseItemDto,
|
||||||
|
BaseItemDtoQueryResult,
|
||||||
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { Typography } from "@mui/material";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
import { getRuntimeMusic } from "@/utils/date/time";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
import { setQueue } from "@/utils/store/queue";
|
||||||
|
import { useSnackbar } from "notistack";
|
||||||
|
import lyricsIcon from "../../assets/icons/lyrics.svg";
|
||||||
|
import LikeButton from "../buttons/likeButton";
|
||||||
|
|
||||||
|
import "./albumMusicTrack.scss";
|
||||||
|
|
||||||
|
type AlbumMusicTrackProps = {
|
||||||
|
track: BaseItemDto;
|
||||||
|
/**
|
||||||
|
* This is the index of the track in the musicTracks array (not to be confused with IndexNumber property of the track)
|
||||||
|
*/
|
||||||
|
trackIndex: number;
|
||||||
|
musicTracks: BaseItemDtoQueryResult | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function AlbumMusicTrack(props: AlbumMusicTrackProps) {
|
||||||
|
const { track, musicTracks, trackIndex } = props;
|
||||||
|
const [currentPlayingItem] = useAudioPlayback((state) => [state.item]);
|
||||||
|
|
||||||
|
const user = useCentralStore((state) => state.currentUser);
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
|
|
||||||
|
const handlePlayback = (
|
||||||
|
index: number,
|
||||||
|
item: BaseItemDto,
|
||||||
|
queue: BaseItemDto[],
|
||||||
|
) => {
|
||||||
|
if (!user?.Id || !api) {
|
||||||
|
console.error("User not logged in");
|
||||||
|
enqueueSnackbar("You need to be logged in to play music", {
|
||||||
|
variant: "error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (item.Id) {
|
||||||
|
const url = generateAudioStreamUrl(
|
||||||
|
item.Id,
|
||||||
|
user.Id,
|
||||||
|
api.deviceInfo.id,
|
||||||
|
api.basePath,
|
||||||
|
api.accessToken,
|
||||||
|
);
|
||||||
|
playAudio(url, item);
|
||||||
|
setQueue(queue, index);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={
|
||||||
|
currentPlayingItem?.Id === track.Id
|
||||||
|
? "item-info-track playing"
|
||||||
|
: "item-info-track"
|
||||||
|
}
|
||||||
|
key={track.Id}
|
||||||
|
onClick={() => {
|
||||||
|
if (musicTracks?.Items) {
|
||||||
|
handlePlayback(trackIndex, track, musicTracks.Items);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className="index-container">
|
||||||
|
<span className="material-symbols-rounded fill ">play_arrow</span>
|
||||||
|
<Typography className="index">{track.IndexNumber ?? "-"}</Typography>
|
||||||
|
</div>
|
||||||
|
<div className="item-info-track-info">
|
||||||
|
<Typography className="item-info-track-info-name">
|
||||||
|
{track.Name}
|
||||||
|
</Typography>
|
||||||
|
<Typography
|
||||||
|
variant="subtitle2"
|
||||||
|
style={{
|
||||||
|
opacity: 0.6,
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: "0.6em",
|
||||||
|
}}
|
||||||
|
fontWeight={300}
|
||||||
|
>
|
||||||
|
{track.HasLyrics && <img src={lyricsIcon} alt="lyrics" />}
|
||||||
|
{track.Artists?.join(", ")}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
<Typography>{getRuntimeMusic(track.RunTimeTicks ?? 0)}</Typography>
|
||||||
|
<div className="flex flex-align-center">
|
||||||
|
<LikeButton
|
||||||
|
itemId={track.Id}
|
||||||
|
isFavorite={track.UserData?.IsFavorite}
|
||||||
|
queryKey={["item", "musicTracks"]}
|
||||||
|
userId={user?.Id}
|
||||||
|
itemName={track.Name}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -336,11 +336,6 @@ const PlayButton = ({
|
|||||||
enqueueSnackbar("No item ID found", { variant: "error" });
|
enqueueSnackbar("No item ID found", { variant: "error" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!result?.mediaSource?.MediaSources?.[0]?.Id) {
|
|
||||||
console.error("No media source ID found");
|
|
||||||
enqueueSnackbar("No media source ID found", { variant: "error" });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (trackIndex) {
|
if (trackIndex) {
|
||||||
// Playlist Playback
|
// Playlist Playback
|
||||||
@@ -363,9 +358,9 @@ const PlayButton = ({
|
|||||||
navigate({ to: "/player/photos" });
|
navigate({ to: "/player/photos" });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!result?.mediaSource) {
|
if (!result?.mediaSource?.MediaSources?.[0]?.Id) {
|
||||||
enqueueSnackbar("No media source found", { variant: "error" });
|
console.error("No media source ID found");
|
||||||
console.error("No media source found");
|
enqueueSnackbar("No media source ID found", { variant: "error" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const episodeIndex = result.episodeIndex;
|
const episodeIndex = result.episodeIndex;
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ import {
|
|||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
type ImageType,
|
type ImageType,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { ErrorBoundary } from "react-error-boundary";
|
||||||
import LikeButton from "../buttons/likeButton";
|
import LikeButton from "../buttons/likeButton";
|
||||||
import MarkPlayedButton from "../buttons/markPlayedButton";
|
import MarkPlayedButton from "../buttons/markPlayedButton";
|
||||||
import PlayButton from "../buttons/playButton";
|
import PlayButton from "../buttons/playButton";
|
||||||
import ErrorBoundary from "../errorBoundary";
|
|
||||||
import { getTypeIcon } from "../utils/iconsCollection";
|
import { getTypeIcon } from "../utils/iconsCollection";
|
||||||
import "./card.scss";
|
import "./card.scss";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
>
|
>
|
||||||
{item.PremiereDate && (
|
{item.PremiereDate && (
|
||||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||||
{item.ProductionYear ?? ""}
|
{item.ProductionYear}
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
{item.OfficialRating && (
|
{item.OfficialRating && (
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
class ErrorBoundary extends React.Component {
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = { hasError: false };
|
|
||||||
}
|
|
||||||
|
|
||||||
static getDerivedStateFromError(error) {
|
|
||||||
// Update state so the next render will show the fallback UI.
|
|
||||||
return { hasError: true };
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidCatch(error, info) {
|
|
||||||
// Example "componentStack":
|
|
||||||
// in ComponentThatThrows (created by App)
|
|
||||||
// in ErrorBoundary (created by App)
|
|
||||||
// in div (created by App)
|
|
||||||
// in App
|
|
||||||
this.setState;
|
|
||||||
console.error(`Err in ${info} - ${error}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
if (this.state.hasError) {
|
|
||||||
// You can render any custom fallback UI
|
|
||||||
return this.props.fallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.props.children;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export default ErrorBoundary;
|
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
height: 16em;
|
height: 16em;
|
||||||
box-shadow: $shadow-card-image;
|
box-shadow: $shadow-card-image;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
flex-shrink: 0;
|
||||||
&-icon {
|
&-icon {
|
||||||
color: rgb(255 255 255 / 0.5);
|
color: rgb(255 255 255 / 0.5);
|
||||||
font-variation-settings: "FILL" 1, "wght" 300, "GRAD" 25, "opsz" 40;
|
font-variation-settings: "FILL" 1, "wght" 300, "GRAD" 25, "opsz" 40;
|
||||||
|
|||||||
@@ -1,274 +0,0 @@
|
|||||||
import React, { useState } from "react";
|
|
||||||
|
|
||||||
import MuiLink from "@mui/material/Link";
|
|
||||||
import Paper from "@mui/material/Paper";
|
|
||||||
import Stack from "@mui/material/Stack";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
|
|
||||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
|
|
||||||
import { getRuntimeMusic } from "../../../utils/date/time";
|
|
||||||
|
|
||||||
import { SortOrder } from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import { useAudioPlayback } from "../../../utils/store/audioPlayback";
|
|
||||||
import LikeButton from "../../buttons/likeButton";
|
|
||||||
import PlayButton from "../../buttons/playButton";
|
|
||||||
|
|
||||||
import TrackList from "../tracksList/index";
|
|
||||||
import "./albumArtist.scss";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { Link, useRouteContext } from "@tanstack/react-router";
|
|
||||||
|
|
||||||
export const ArtistAlbum = ({ user, album, boxProps }) => {
|
|
||||||
const api = useApiInContext((s) => s.api);
|
|
||||||
const albumTracks = useQuery({
|
|
||||||
queryKey: ["artist", "album", album.Id],
|
|
||||||
queryFn: async () => {
|
|
||||||
const result = await getItemsApi(api).getItems({
|
|
||||||
userId: user.Id,
|
|
||||||
parentId: album.Id,
|
|
||||||
sortOrder: SortOrder.Ascending,
|
|
||||||
sortBy: "IndexNumber",
|
|
||||||
});
|
|
||||||
return result.data;
|
|
||||||
},
|
|
||||||
|
|
||||||
networkMode: "always",
|
|
||||||
});
|
|
||||||
|
|
||||||
const [
|
|
||||||
currentTrackItem,
|
|
||||||
setCurrentAudioTrack,
|
|
||||||
setAudioUrl,
|
|
||||||
setAudioDisplay,
|
|
||||||
setAudioItem,
|
|
||||||
setAudioTracks,
|
|
||||||
] = useAudioPlayback((state) => [
|
|
||||||
state.item,
|
|
||||||
state.setCurrentTrack,
|
|
||||||
state.setUrl,
|
|
||||||
state.setDisplay,
|
|
||||||
state.setItem,
|
|
||||||
state.setTracks,
|
|
||||||
]);
|
|
||||||
const playTrack = (index) => {
|
|
||||||
setAudioTracks(albumTracks.data.Items);
|
|
||||||
setCurrentAudioTrack(index);
|
|
||||||
setAudioUrl(
|
|
||||||
`${api.basePath}/Audio/${albumTracks.data.Items[index].Id}/universal?deviceId=${api.deviceInfo.id}&userId=${user.Id}&api_key=${api.accessToken}`,
|
|
||||||
);
|
|
||||||
setAudioItem(albumTracks.data.Items[index]);
|
|
||||||
setAudioDisplay(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div style={{ marginBottom: "3em" }} {...boxProps}>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "row",
|
|
||||||
gap: "1em",
|
|
||||||
marginBottom: "1em",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{!!album.ImageTags?.Primary && (
|
|
||||||
<div className="album-image">
|
|
||||||
<img
|
|
||||||
alt={album.Name}
|
|
||||||
src={`${api.basePath}/Items/${album.Id}/Images/Primary?fillHeight=532&fillWidth=532&quality=96`}
|
|
||||||
style={{
|
|
||||||
width: "100%",
|
|
||||||
height: "100%",
|
|
||||||
objectFit: "cover",
|
|
||||||
opacity: 0,
|
|
||||||
transition: "opacity 250ms",
|
|
||||||
position: "relative",
|
|
||||||
zIndex: 2,
|
|
||||||
}}
|
|
||||||
onLoad={(e) => (e.currentTarget.style.opacity = 1)}
|
|
||||||
/>
|
|
||||||
<div className="album-image-icon-container">
|
|
||||||
<span
|
|
||||||
className="material-symbols-rounded album-image-icon"
|
|
||||||
style={{ fontSize: "8em" }}
|
|
||||||
>
|
|
||||||
album
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<div
|
|
||||||
className="flex flex-column"
|
|
||||||
style={{
|
|
||||||
alignItems: "flex-start",
|
|
||||||
justifyContent: "space-between",
|
|
||||||
padding: "1em 0",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div className="flex flex-column">
|
|
||||||
<Typography
|
|
||||||
variant="h4"
|
|
||||||
fontWeight={300}
|
|
||||||
style={{ opacity: "0.6", mb: 1 }}
|
|
||||||
>
|
|
||||||
{album.ProductionYear}
|
|
||||||
</Typography>
|
|
||||||
<MuiLink
|
|
||||||
component={Link}
|
|
||||||
to="/album/$Id"
|
|
||||||
variant="h2"
|
|
||||||
color="inherit"
|
|
||||||
underline="hover"
|
|
||||||
>
|
|
||||||
{album.Name}
|
|
||||||
</MuiLink>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
className=" flex flex-row"
|
|
||||||
style={{
|
|
||||||
gap: "1em",
|
|
||||||
alignItems: "center",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<PlayButton
|
|
||||||
audio
|
|
||||||
itemId={album.Id}
|
|
||||||
itemType={album.Type}
|
|
||||||
itemUserData={album.UserData}
|
|
||||||
userId={user.Id}
|
|
||||||
buttonProps={{
|
|
||||||
color: "white",
|
|
||||||
style: {
|
|
||||||
color: "black ",
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<LikeButton
|
|
||||||
itemName={album.Name}
|
|
||||||
key={album.Id}
|
|
||||||
queryKey={[
|
|
||||||
"item",
|
|
||||||
album.ParentBackdropItemId,
|
|
||||||
"artist",
|
|
||||||
"discography",
|
|
||||||
]}
|
|
||||||
isFavorite={album.UserData.IsFavorite}
|
|
||||||
itemId={album.Id}
|
|
||||||
itemType={album.Type}
|
|
||||||
itemUserData={album.UserData}
|
|
||||||
userId={user.Id}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{albumTracks.isSuccess && (
|
|
||||||
<TrackList user={user} tracks={albumTracks.data.Items} />
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
{
|
|
||||||
/* <div
|
|
||||||
key={0}
|
|
||||||
className="item-detail-album-track"
|
|
||||||
style={{
|
|
||||||
padding: "0.75em 0 ",
|
|
||||||
background: "rgb(0 0 0 / 0.6)",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
variant="h6"
|
|
||||||
fontWeight={400}
|
|
||||||
style={{
|
|
||||||
justifySelf: "end",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
#
|
|
||||||
</Typography>
|
|
||||||
<div />
|
|
||||||
<Typography
|
|
||||||
variant="h6"
|
|
||||||
style={{
|
|
||||||
justifySelf: "start",
|
|
||||||
}}
|
|
||||||
fontWeight={400}
|
|
||||||
>
|
|
||||||
Name
|
|
||||||
</Typography>
|
|
||||||
<span className="material-symbols-rounded">schedule</span>
|
|
||||||
</div>
|
|
||||||
{/*albumTracks.data.Items.map((track, index) => {
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={track.Id}
|
|
||||||
className={
|
|
||||||
currentTrackItem.Id === track.Id &&
|
|
||||||
currentTrackItem.ParentId === track.ParentId
|
|
||||||
? "item-detail-album-track playing"
|
|
||||||
: "item-detail-album-track"
|
|
||||||
}
|
|
||||||
onClick={() => playTrack(index)}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
variant="subtitle1"
|
|
||||||
style={{
|
|
||||||
justifySelf: "end",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{track.IndexNumber ? track.IndexNumber : "-"}
|
|
||||||
</Typography>
|
|
||||||
|
|
||||||
<LikeButton
|
|
||||||
itemId={track.Id}
|
|
||||||
isFavorite={track.UserData?.IsFavorite}
|
|
||||||
queryKey={["artist", "album", album.Id]}
|
|
||||||
userId={user.Id}
|
|
||||||
itemName={track.Name}
|
|
||||||
color={
|
|
||||||
currentTrackItem.Id === track.Id &&
|
|
||||||
currentTrackItem.ParentId === track.ParentId
|
|
||||||
? "hsl(337, 96%, 56%)"
|
|
||||||
: "white"
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
|
||||||
width: "100%",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
variant="subtitle1"
|
|
||||||
style={{
|
|
||||||
justifySelf: "start",
|
|
||||||
}}
|
|
||||||
fontWeight={500}
|
|
||||||
>
|
|
||||||
{track.Name}
|
|
||||||
</Typography>
|
|
||||||
{track.AlbumArtist === "Various Artists" && (
|
|
||||||
<Typography
|
|
||||||
variant="subtitle2"
|
|
||||||
style={{
|
|
||||||
opacity: 0.5,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{track.ArtistItems.map((artist) => artist.Name).join(
|
|
||||||
", ",
|
|
||||||
)}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<Typography variant="subtitle1">
|
|
||||||
{getRuntimeMusic(track.RunTimeTicks)}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})*/
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,166 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
import Typography from "@mui/material/Typography";
|
||||||
|
|
||||||
|
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
|
||||||
|
import {
|
||||||
|
type BaseItemDto,
|
||||||
|
SortOrder,
|
||||||
|
type UserDto,
|
||||||
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import LikeButton from "../../buttons/likeButton";
|
||||||
|
import PlayButton from "../../buttons/playButton";
|
||||||
|
|
||||||
|
import "./albumArtist.scss";
|
||||||
|
import AlbumMusicTrack from "@/components/albumMusicTrack";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { Link } from "@tanstack/react-router";
|
||||||
|
|
||||||
|
type ArtistAlbumProps = {
|
||||||
|
user: UserDto;
|
||||||
|
album: BaseItemDto;
|
||||||
|
boxProps?: object;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ArtistAlbum = ({ user, album, boxProps }: ArtistAlbumProps) => {
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
const albumTracks = useQuery({
|
||||||
|
queryKey: ["artist", "album", album.Id],
|
||||||
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
|
const result = await getItemsApi(api).getItems({
|
||||||
|
userId: user.Id,
|
||||||
|
parentId: album.Id,
|
||||||
|
sortOrder: [SortOrder.Ascending],
|
||||||
|
sortBy: ["IndexNumber"],
|
||||||
|
});
|
||||||
|
return result.data;
|
||||||
|
},
|
||||||
|
|
||||||
|
networkMode: "always",
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div style={{ marginBottom: "3em" }} {...boxProps}>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "row",
|
||||||
|
gap: "1em",
|
||||||
|
marginBottom: "1em",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{!!album.ImageTags?.Primary && (
|
||||||
|
<div className="album-image">
|
||||||
|
<img
|
||||||
|
alt={album.Name ?? "Album Image"}
|
||||||
|
src={`${api?.basePath}/Items/${album.Id}/Images/Primary?fillHeight=532&fillWidth=532&quality=96`}
|
||||||
|
style={{
|
||||||
|
width: "100%",
|
||||||
|
height: "100%",
|
||||||
|
objectFit: "cover",
|
||||||
|
opacity: 0,
|
||||||
|
transition: "opacity 250ms",
|
||||||
|
position: "relative",
|
||||||
|
zIndex: 2,
|
||||||
|
}}
|
||||||
|
onLoad={(e) => {
|
||||||
|
e.currentTarget.style.opacity = "1";
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<div className="album-image-icon-container">
|
||||||
|
<span
|
||||||
|
className="material-symbols-rounded album-image-icon"
|
||||||
|
style={{ fontSize: "8em" }}
|
||||||
|
>
|
||||||
|
album
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div
|
||||||
|
className="flex flex-column"
|
||||||
|
style={{
|
||||||
|
alignItems: "flex-start",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
padding: "1em 0",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className="flex flex-column">
|
||||||
|
<Typography
|
||||||
|
variant="h5"
|
||||||
|
fontWeight={300}
|
||||||
|
style={{ opacity: "0.6" }}
|
||||||
|
>
|
||||||
|
{album.ProductionYear}
|
||||||
|
</Typography>
|
||||||
|
<Link
|
||||||
|
to="/album/$id"
|
||||||
|
params={{ id: album.Id ?? "" }}
|
||||||
|
style={{ color: "white", textDecoration: "none" }}
|
||||||
|
>
|
||||||
|
<Typography variant="h4" color="white">
|
||||||
|
{album.Name}
|
||||||
|
</Typography>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className=" flex flex-row"
|
||||||
|
style={{
|
||||||
|
gap: "1em",
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<PlayButton
|
||||||
|
audio
|
||||||
|
item={album}
|
||||||
|
itemType={album.Type ?? "MusicAlbum"}
|
||||||
|
userId={user.Id}
|
||||||
|
buttonProps={{
|
||||||
|
//@ts-ignore
|
||||||
|
color: "white",
|
||||||
|
style: {
|
||||||
|
color: "black ",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<LikeButton
|
||||||
|
itemName={album.Name}
|
||||||
|
key={album.Id}
|
||||||
|
queryKey={[
|
||||||
|
"item",
|
||||||
|
album.ParentBackdropItemId ?? "",
|
||||||
|
"artist",
|
||||||
|
"discography",
|
||||||
|
]}
|
||||||
|
isFavorite={album.UserData?.IsFavorite}
|
||||||
|
itemId={album.Id}
|
||||||
|
userId={user.Id}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{albumTracks.isSuccess && (albumTracks.data?.Items?.length ?? 0) > 0 && (
|
||||||
|
<div>
|
||||||
|
<div className="item-info-track header">
|
||||||
|
<span className="material-symbols-rounded index">tag</span>
|
||||||
|
<Typography variant="subtitle1">Title</Typography>
|
||||||
|
<Typography variant="subtitle1">Duration</Typography>
|
||||||
|
</div>
|
||||||
|
{albumTracks.data?.Items?.map((track, index) => (
|
||||||
|
<AlbumMusicTrack
|
||||||
|
track={track}
|
||||||
|
trackIndex={index}
|
||||||
|
musicTracks={albumTracks.data}
|
||||||
|
key={track.Id}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -9,7 +9,6 @@ import "./musicTrack.scss";
|
|||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
import type { QueryKey } from "@tanstack/react-query";
|
|
||||||
import lyrics_icon from "../../assets/icons/lyrics.svg";
|
import lyrics_icon from "../../assets/icons/lyrics.svg";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,8 +36,8 @@ const MusicTrack = ({
|
|||||||
trackIndex,
|
trackIndex,
|
||||||
className = "",
|
className = "",
|
||||||
}: {
|
}: {
|
||||||
item?: BaseItemDto | null;
|
item: BaseItemDto;
|
||||||
queryKey?: QueryKey;
|
queryKey: string[];
|
||||||
userId?: string | undefined;
|
userId?: string | undefined;
|
||||||
playlistItem?: boolean;
|
playlistItem?: boolean;
|
||||||
playlistItemId?: string;
|
playlistItemId?: string;
|
||||||
@@ -60,16 +59,21 @@ const MusicTrack = ({
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<img
|
<img
|
||||||
alt={item.Name}
|
alt={item.Name ?? "Music Track"}
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
Object.keys(item.ImageTags).length === 0 ? item.AlbumId : item.Id,
|
api &&
|
||||||
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
|
(Object.keys(item.ImageTags ?? {}).length === 0
|
||||||
|
? item.AlbumId
|
||||||
|
: item.Id) ?? "",
|
||||||
"Primary",
|
"Primary",
|
||||||
{
|
{
|
||||||
quality: 70,
|
quality: 70,
|
||||||
fillHeight: 128,
|
fillHeight: 128,
|
||||||
fillWidth: 128,
|
fillWidth: 128,
|
||||||
},
|
},
|
||||||
)}
|
)
|
||||||
|
}
|
||||||
style={{
|
style={{
|
||||||
width: "100%",
|
width: "100%",
|
||||||
height: "100%",
|
height: "100%",
|
||||||
@@ -77,14 +81,14 @@ const MusicTrack = ({
|
|||||||
opacity: 0,
|
opacity: 0,
|
||||||
}}
|
}}
|
||||||
onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
e.target.style.opacity = 1;
|
e.currentTarget.style.opacity = "1";
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<div className="music-track-image-overlay">
|
<div className="music-track-image-overlay">
|
||||||
<PlayButton
|
<PlayButton
|
||||||
itemId={item.Id}
|
item={item}
|
||||||
|
itemType="Audio"
|
||||||
userId={userId}
|
userId={userId}
|
||||||
itemType={item.Type}
|
|
||||||
size="small"
|
size="small"
|
||||||
iconOnly
|
iconOnly
|
||||||
audio
|
audio
|
||||||
@@ -119,9 +123,11 @@ const MusicTrack = ({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{item.ArtistItems?.map((artist, index) => (
|
{item.ArtistItems?.map((artist, index) => (
|
||||||
<>
|
<span
|
||||||
|
style={{ display: "inline-flex", alignItems: "center" }}
|
||||||
|
key={artist.Id}
|
||||||
|
>
|
||||||
<TextLink
|
<TextLink
|
||||||
key={index}
|
|
||||||
variant={"subtitle2"}
|
variant={"subtitle2"}
|
||||||
location={`/artist/${artist.Id}`}
|
location={`/artist/${artist.Id}`}
|
||||||
otherProps={{
|
otherProps={{
|
||||||
@@ -133,7 +139,7 @@ const MusicTrack = ({
|
|||||||
>
|
>
|
||||||
{artist.Name}
|
{artist.Name}
|
||||||
</TextLink>
|
</TextLink>
|
||||||
{index !== item.ArtistItems.length - 1 && (
|
{index !== (item.ArtistItems?.length ?? 0) - 1 && (
|
||||||
<span
|
<span
|
||||||
style={{
|
style={{
|
||||||
whiteSpace: "pre",
|
whiteSpace: "pre",
|
||||||
@@ -142,12 +148,12 @@ const MusicTrack = ({
|
|||||||
,{" "}
|
,{" "}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</>
|
</span>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Typography variant="subtitl1">
|
<Typography variant="subtitle1">
|
||||||
{getRuntimeMusic(item.RunTimeTicks)}
|
{getRuntimeMusic(item.RunTimeTicks ?? 0)}
|
||||||
</Typography>
|
</Typography>
|
||||||
<LikeButton
|
<LikeButton
|
||||||
itemId={item.Id}
|
itemId={item.Id}
|
||||||
|
|||||||
+40
-163
@@ -4,11 +4,7 @@ import Box from "@mui/material/Box";
|
|||||||
import CircularProgress from "@mui/material/CircularProgress";
|
import CircularProgress from "@mui/material/CircularProgress";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
|
|
||||||
import {
|
import { BaseItemKind, SortOrder } from "@jellyfin/sdk/lib/generated-client";
|
||||||
type BaseItemDto,
|
|
||||||
BaseItemKind,
|
|
||||||
SortOrder,
|
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||||
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||||
@@ -16,7 +12,7 @@ import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api"
|
|||||||
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
|
||||||
import { getRuntimeCompact, getRuntimeMusic } from "@/utils/date/time";
|
import { getRuntimeCompact } from "@/utils/date/time";
|
||||||
|
|
||||||
import { Card } from "@/components/card/card";
|
import { Card } from "@/components/card/card";
|
||||||
import CardScroller from "@/components/cardScroller/cardScroller";
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||||
@@ -26,21 +22,16 @@ import PlayButton from "@/components/buttons/playButton";
|
|||||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||||
|
|
||||||
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||||
import {
|
|
||||||
generateAudioStreamUrl,
|
|
||||||
playAudio,
|
|
||||||
useAudioPlayback,
|
|
||||||
} from "@/utils/store/audioPlayback";
|
|
||||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
import "./album.scss";
|
import "./album.scss";
|
||||||
|
|
||||||
|
import AlbumMusicTrack from "@/components/albumMusicTrack";
|
||||||
import TagChip from "@/components/tagChip";
|
import TagChip from "@/components/tagChip";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import { setQueue } from "@/utils/store/queue";
|
import { Chip } from "@mui/material";
|
||||||
import { Link, createFileRoute } from "@tanstack/react-router";
|
import { Link, createFileRoute } from "@tanstack/react-router";
|
||||||
import { useSnackbar } from "notistack";
|
import { createPortal } from "react-dom";
|
||||||
import lyricsIcon from "../../../assets/icons/lyrics.svg";
|
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/album/$id")({
|
export const Route = createFileRoute("/_api/album/$id")({
|
||||||
component: MusicAlbumTitlePage,
|
component: MusicAlbumTitlePage,
|
||||||
@@ -58,7 +49,6 @@ function MusicAlbumTitlePage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const user = useCentralStore((s) => s.currentUser);
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
|
||||||
|
|
||||||
const item = useQuery({
|
const item = useQuery({
|
||||||
queryKey: ["item", id],
|
queryKey: ["item", id],
|
||||||
@@ -135,33 +125,6 @@ function MusicAlbumTitlePage() {
|
|||||||
|
|
||||||
const pageRef = useRef(null);
|
const pageRef = useRef(null);
|
||||||
|
|
||||||
const handlePlayback = (
|
|
||||||
index: number,
|
|
||||||
item: BaseItemDto,
|
|
||||||
queue: BaseItemDto[],
|
|
||||||
) => {
|
|
||||||
if (!user?.Id || !api) {
|
|
||||||
console.error("User not logged in");
|
|
||||||
enqueueSnackbar("You need to be logged in to play music", {
|
|
||||||
variant: "error",
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (item.Id) {
|
|
||||||
const url = generateAudioStreamUrl(
|
|
||||||
item.Id,
|
|
||||||
user.Id,
|
|
||||||
api.deviceInfo.id,
|
|
||||||
api.basePath,
|
|
||||||
api.accessToken,
|
|
||||||
);
|
|
||||||
playAudio(url, item, undefined);
|
|
||||||
setQueue(queue, index);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const currentPlayingItem = useAudioPlayback((s) => s.item);
|
|
||||||
|
|
||||||
if (item.isPending || similarItems.isPending) {
|
if (item.isPending || similarItems.isPending) {
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
@@ -184,13 +147,22 @@ function MusicAlbumTitlePage() {
|
|||||||
className="scrollY padded-top item item-album"
|
className="scrollY padded-top item item-album"
|
||||||
ref={pageRef}
|
ref={pageRef}
|
||||||
>
|
>
|
||||||
<div className="item-info-container">
|
|
||||||
<div className="item-info">
|
<div className="item-info">
|
||||||
<Typography className="item-info-name" variant="h3">
|
<Typography className="item-info-name" variant="h3">
|
||||||
{item.data.Name}
|
{item.data.Name}
|
||||||
</Typography>
|
</Typography>
|
||||||
<div className="flex flex-align-center item-info-album-info">
|
<div className="flex flex-align-center item-info-album-info">
|
||||||
<div className="flex flex-align-center">
|
{/* @ts-ignore - Using Link as component */}
|
||||||
|
<Chip
|
||||||
|
component={Link}
|
||||||
|
to="/artist/$id"
|
||||||
|
params={{ id: item.data.AlbumArtists?.[0].Id ?? "" }}
|
||||||
|
className="flex flex-align-center"
|
||||||
|
style={{
|
||||||
|
color: "white",
|
||||||
|
textDecoration: "none",
|
||||||
|
}}
|
||||||
|
icon={
|
||||||
<span
|
<span
|
||||||
className="material-symbols-rounded"
|
className="material-symbols-rounded"
|
||||||
style={{
|
style={{
|
||||||
@@ -199,8 +171,9 @@ function MusicAlbumTitlePage() {
|
|||||||
>
|
>
|
||||||
artist
|
artist
|
||||||
</span>
|
</span>
|
||||||
<Typography ml={1}>{item.data.AlbumArtist}</Typography>
|
}
|
||||||
</div>
|
label={item.data.AlbumArtist}
|
||||||
|
/>
|
||||||
<Typography className="opacity-07">
|
<Typography className="opacity-07">
|
||||||
{item.data.ProductionYear}
|
{item.data.ProductionYear}
|
||||||
</Typography>
|
</Typography>
|
||||||
@@ -232,7 +205,10 @@ function MusicAlbumTitlePage() {
|
|||||||
{allDiscs.length > 1 ? (
|
{allDiscs.length > 1 ? (
|
||||||
allDiscs.map((disc) => (
|
allDiscs.map((disc) => (
|
||||||
<div className="item-info-disc-container" key={disc}>
|
<div className="item-info-disc-container" key={disc}>
|
||||||
<div className="item-info-disc-header flex flex-row flex-align-center">
|
<div
|
||||||
|
className="item-info-disc-header flex flex-row flex-align-center"
|
||||||
|
style={{ marginBottom: "1em" }}
|
||||||
|
>
|
||||||
<span
|
<span
|
||||||
className="material-symbols-rounded"
|
className="material-symbols-rounded"
|
||||||
style={{ fontSize: "2em" }}
|
style={{ fontSize: "2em" }}
|
||||||
@@ -242,143 +218,43 @@ function MusicAlbumTitlePage() {
|
|||||||
<Typography variant="h5">Disc {disc}</Typography>
|
<Typography variant="h5">Disc {disc}</Typography>
|
||||||
</div>
|
</div>
|
||||||
<div className="item-info-track header">
|
<div className="item-info-track header">
|
||||||
<span className="material-symbols-rounded index">
|
<span className="material-symbols-rounded index">tag</span>
|
||||||
tag
|
|
||||||
</span>
|
|
||||||
<Typography variant="subtitle1">Title</Typography>
|
<Typography variant="subtitle1">Title</Typography>
|
||||||
<Typography variant="subtitle1">Duration</Typography>
|
<Typography variant="subtitle1">Duration</Typography>
|
||||||
</div>
|
</div>
|
||||||
{musicTracks.data?.Items?.map(
|
{musicTracks.data?.Items?.map(
|
||||||
(track, index) =>
|
(track, index) =>
|
||||||
track.ParentIndexNumber === disc && (
|
track.ParentIndexNumber === disc && (
|
||||||
<div
|
<AlbumMusicTrack
|
||||||
className={
|
|
||||||
currentPlayingItem?.Id === track.Id
|
|
||||||
? "item-info-track playing"
|
|
||||||
: "item-info-track"
|
|
||||||
}
|
|
||||||
key={track.Id}
|
key={track.Id}
|
||||||
onClick={() => {
|
track={track}
|
||||||
if (musicTracks.data.Items) {
|
trackIndex={index}
|
||||||
handlePlayback(
|
musicTracks={musicTracks.data}
|
||||||
index,
|
|
||||||
track,
|
|
||||||
musicTracks.data.Items,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div className="index-container">
|
|
||||||
<span className="material-symbols-rounded fill ">
|
|
||||||
play_arrow
|
|
||||||
</span>
|
|
||||||
<Typography className="index">
|
|
||||||
{track.IndexNumber ?? "-"}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
<div className="item-info-track-info">
|
|
||||||
<Typography className="item-info-track-info-name">
|
|
||||||
{track.Name}
|
|
||||||
</Typography>
|
|
||||||
<Typography
|
|
||||||
variant="subtitle2"
|
|
||||||
style={{
|
|
||||||
opacity: 0.6,
|
|
||||||
display: "flex",
|
|
||||||
alignItems: "center",
|
|
||||||
gap: "0.6em",
|
|
||||||
}}
|
|
||||||
fontWeight={300}
|
|
||||||
>
|
|
||||||
{track.HasLyrics && (
|
|
||||||
<img src={lyricsIcon} alt="lyrics" />
|
|
||||||
)}
|
|
||||||
{track.Artists?.join(", ")}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
<Typography>
|
|
||||||
{getRuntimeMusic(track.RunTimeTicks ?? 0)}
|
|
||||||
</Typography>
|
|
||||||
<div className="flex flex-align-center">
|
|
||||||
<LikeButton
|
|
||||||
itemId={track.Id}
|
|
||||||
isFavorite={track.UserData?.IsFavorite}
|
|
||||||
queryKey={["item", "musicTracks"]}
|
|
||||||
userId={user?.Id}
|
|
||||||
itemName={track.Name}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
<>
|
<div>
|
||||||
<div className="item-info-track header">
|
<div className="item-info-track header">
|
||||||
<span className="material-symbols-rounded index">tag</span>
|
<span className="material-symbols-rounded index">tag</span>
|
||||||
<Typography variant="subtitle1">Title</Typography>
|
<Typography variant="subtitle1">Title</Typography>
|
||||||
<Typography variant="subtitle1">Duration</Typography>
|
<Typography variant="subtitle1">Duration</Typography>
|
||||||
</div>
|
</div>
|
||||||
{musicTracks.data?.Items?.map((track, index) => (
|
{musicTracks.data?.Items?.map((track, index) => (
|
||||||
<div
|
<AlbumMusicTrack
|
||||||
className={
|
|
||||||
currentPlayingItem?.Id === track.Id
|
|
||||||
? "item-info-track playing"
|
|
||||||
: "item-info-track"
|
|
||||||
}
|
|
||||||
key={track.Id}
|
key={track.Id}
|
||||||
onClick={() =>
|
track={track}
|
||||||
musicTracks.data.Items &&
|
trackIndex={index}
|
||||||
handlePlayback(index, track, musicTracks.data.Items)
|
musicTracks={musicTracks.data}
|
||||||
}
|
|
||||||
>
|
|
||||||
<div className="index-container">
|
|
||||||
<span className="material-symbols-rounded fill ">
|
|
||||||
play_arrow
|
|
||||||
</span>
|
|
||||||
<Typography className="index">
|
|
||||||
{track.IndexNumber ?? "-"}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
<div className="item-info-track-info">
|
|
||||||
<Typography className="item-info-track-info-name">
|
|
||||||
{track.Name}
|
|
||||||
</Typography>
|
|
||||||
<Typography
|
|
||||||
variant="subtitle2"
|
|
||||||
style={{
|
|
||||||
opacity: 0.6,
|
|
||||||
display: "flex",
|
|
||||||
alignItems: "center",
|
|
||||||
gap: "0.6em",
|
|
||||||
}}
|
|
||||||
fontWeight={300}
|
|
||||||
>
|
|
||||||
{track.HasLyrics && (
|
|
||||||
<img src={lyricsIcon} alt="lyrics" />
|
|
||||||
)}
|
|
||||||
{track.Artists?.join(", ")}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
<Typography>
|
|
||||||
{getRuntimeMusic(track.RunTimeTicks ?? 0)}
|
|
||||||
</Typography>
|
|
||||||
<div className="flex flex-align-center">
|
|
||||||
<LikeButton
|
|
||||||
itemId={track.Id}
|
|
||||||
isFavorite={track.UserData?.IsFavorite}
|
|
||||||
queryKey={["item", "musicTracks"]}
|
|
||||||
userId={user?.Id}
|
|
||||||
itemName={track.Name}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
))}
|
))}
|
||||||
</>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{createPortal(
|
||||||
<div className="item-info-sidebar">
|
<div className="item-info-sidebar">
|
||||||
<div className="item-info-sidebar-image-container">
|
<div className="item-info-sidebar-image-container">
|
||||||
{item.data.ImageTags?.Primary ? (
|
{item.data.ImageTags?.Primary ? (
|
||||||
@@ -440,12 +316,13 @@ function MusicAlbumTitlePage() {
|
|||||||
</Link>
|
</Link>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>,
|
||||||
</div>
|
document.body,
|
||||||
{(similarItems.data?.TotalRecordCount ?? -1) > 0 && (
|
)}
|
||||||
|
{(similarItems.data?.TotalRecordCount ?? 0) > 0 && (
|
||||||
<CardScroller
|
<CardScroller
|
||||||
title="You might also like"
|
title="You might also like"
|
||||||
displayCards={7}
|
displayCards={5}
|
||||||
disableDecoration
|
disableDecoration
|
||||||
>
|
>
|
||||||
{similarItems.data?.Items?.map((similar) => {
|
{similarItems.data?.Items?.map((similar) => {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
$border-radius: 20px;
|
$border-radius: 20px;
|
||||||
.item-album {
|
.item-album {
|
||||||
|
width: 70vw;
|
||||||
|
padding-right: 2.2em;
|
||||||
.item-info {
|
.item-info {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -9,13 +11,35 @@ $border-radius: 20px;
|
|||||||
display: grid;
|
display: grid;
|
||||||
gap: 3em;
|
gap: 3em;
|
||||||
}
|
}
|
||||||
&-sidebar {
|
|
||||||
|
&-album-info {
|
||||||
|
gap: 1.2em;
|
||||||
|
}
|
||||||
|
&-buttons {
|
||||||
|
display: flex;
|
||||||
|
gap: 1em;
|
||||||
|
}
|
||||||
|
&-disc-header{
|
||||||
|
padding: 1em 2em;
|
||||||
|
background: hsla(0, 0, 100%, 10%);
|
||||||
|
border-radius: 100px;
|
||||||
|
gap: 1em;
|
||||||
|
margin-top: 1em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-info-sidebar {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 1em;
|
gap: 1em;
|
||||||
position: sticky;
|
position: fixed;
|
||||||
max-height: 100vh;
|
max-height: 100vh;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
width: 30vw;
|
||||||
|
padding: 4.4em;
|
||||||
|
padding-left: 2.2em;
|
||||||
&-image {
|
&-image {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
@@ -66,82 +90,7 @@ $border-radius: 20px;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&-track {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 3em 60% 6em 1fr;
|
|
||||||
gap: 1em;
|
|
||||||
padding: 1em;
|
|
||||||
align-items: center;
|
|
||||||
cursor: pointer;
|
|
||||||
border-radius: $border-radius-default;
|
|
||||||
transition: background $transition-time-fast;
|
|
||||||
&.header {
|
|
||||||
border-bottom: 1px solid rgb(255 255 255 / 0.2);
|
|
||||||
color: rgb(255 255 255 / 0.7);
|
|
||||||
border-radius: 0 !important;
|
|
||||||
}
|
|
||||||
.index-container {
|
|
||||||
justify-self: center;
|
|
||||||
position: relative;
|
|
||||||
.material-symbols-rounded {
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
left: 50%;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
font-size: 2em !important;
|
|
||||||
opacity: 0;
|
|
||||||
transition: none !important;
|
|
||||||
color: $clr-accent-default;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
&-info {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 0.1em
|
|
||||||
}
|
|
||||||
&:hover {
|
|
||||||
background: rgb(255 255 255 / 0.1) !important;
|
|
||||||
.index-container {
|
|
||||||
// font-size: 0em;
|
|
||||||
.index {
|
|
||||||
opacity: 0;
|
|
||||||
transition: opacity 0;
|
|
||||||
}
|
|
||||||
.material-symbols-rounded {
|
|
||||||
opacity: 1;
|
|
||||||
font-size: 2.2em !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
&.playing {
|
|
||||||
background: rgb(0 0 0 / 0.4) !important;
|
|
||||||
.item-info-track-info-name, .index {
|
|
||||||
color: $clr-accent-default;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
&-container {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 0.4em
|
|
||||||
}
|
|
||||||
}
|
|
||||||
&-album-info {
|
|
||||||
gap: 1.2em;
|
|
||||||
}
|
|
||||||
&-buttons {
|
|
||||||
display: flex;
|
|
||||||
gap: 1em;
|
|
||||||
}
|
|
||||||
&-disc-header{
|
|
||||||
padding: 1em 2em;
|
|
||||||
background: hsla(0, 0, 100%, 10%);
|
|
||||||
border-radius: 100px;
|
|
||||||
gap: 1em;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.item-detail-album {
|
.item-detail-album {
|
||||||
&-track {
|
&-track {
|
||||||
display: grid;
|
display: grid;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import { ArtistAlbum } from "@/components/layouts/artist/artistAlbum";
|
|||||||
import MusicTrack from "@/components/musicTrack";
|
import MusicTrack from "@/components/musicTrack";
|
||||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||||
import ShowMoreText from "@/components/showMoreText";
|
import ShowMoreText from "@/components/showMoreText";
|
||||||
import { setBackdrop, useBackdropStore } from "@/utils/store/backdrop";
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
import "./artist.scss";
|
import "./artist.scss";
|
||||||
|
|
||||||
import IconLink from "@/components/iconLink";
|
import IconLink from "@/components/iconLink";
|
||||||
@@ -168,6 +168,7 @@ function ArtistTitlePage() {
|
|||||||
|
|
||||||
const [animationDirection, setAnimationDirection] = useState("forward");
|
const [animationDirection, setAnimationDirection] = useState("forward");
|
||||||
|
|
||||||
|
const { setBackdrop } = useBackdropStore();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (item.isSuccess) {
|
if (item.isSuccess) {
|
||||||
setBackdrop(
|
setBackdrop(
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export const useAudioPlayback = createWithEqualityFn<AudioPlaybackStore>(
|
|||||||
export const playAudio = (
|
export const playAudio = (
|
||||||
url: string,
|
url: string,
|
||||||
item: BaseItemDto | undefined | null,
|
item: BaseItemDto | undefined | null,
|
||||||
playlistItemId: string | undefined,
|
playlistItemId?: string | undefined,
|
||||||
): void => {
|
): void => {
|
||||||
useAudioPlayback.setState({
|
useAudioPlayback.setState({
|
||||||
display: true,
|
display: true,
|
||||||
|
|||||||
Reference in new issue
Block a user