chore(web): Add new album page #243

This commit is contained in:
Prayag Prajapati committed 2024-01-16 21:47:55 +05:30
1 parent 3987ffd4da
commit 63b717adfb
8 files changed
+408 -49

No files matched your search

+2 -3
View File
@@ -135,12 +135,11 @@ const CarouselSlide = ({ item }) => {
animationDirection === "right"
? "translateX(-60px)"
: "translateX(60px)",
opacity: 0,
}}
transition={{
duration: 0.25,
ease: "easeInOut",
duration: 0.35,
ease: "anticipate",
}}
key={item.Id}
variant="h2"
+167 -2
View File
@@ -1,6 +1,11 @@
$border-radius: 20px;
.item-album{
.item-hero-image-container{
width: 22% !important;
}
}
.item-detail-album {
&-track {
display: grid;
@@ -10,13 +15,14 @@ $border-radius: 20px;
gap: 0.5em;
width: 100%;
padding: 0.25em 0;
background: hsl(256, 100%, 4%, 40%);
background: rgb(0 0 0 / 0.4);
transition: background $transition-time-default;
backdrop-filter: blur(5px);
&:first-child {
border-radius: $border-radius $border-radius 8px 8px;
cursor: default !important;
}
&:last-child {
@@ -33,7 +39,7 @@ $border-radius: 20px;
}
&:hover {
background: hsl(256, 100%, 4%, 50%);
background: rgb(0 0 0 / 0.5);
cursor: pointer;
}
@@ -42,3 +48,162 @@ $border-radius: 20px;
}
}
}
.item {
gap: 1em;
&-hero {
height: 50vh;
gap: 2em;
position: relative;
align-items: center;
&-image {
opacity: 0;
width: 100%;
object-fit: contain;
transition: opacity $transition-time-default;
&-container {
height: fit-content;
max-height: 100%;
overflow: hidden;
border-radius: $border-radius-default;
box-shadow: $shadow-card;
flex-grow: 1;
flex-shrink: 0;
position: relative;
}
&-blurhash {
position: absolute !important;
width: 100% !important;
height: 100% !important;
z-index: -1;
}
}
&-logo {
max-width: 42rem;
max-height: 10rem;
opacity: 0;
transition: opacity $transition-time-default;
object-position: bottom;
}
&-detail {
width: 100%;
align-items: flex-start;
gap: 1em;
justify-content: end;
}
&-buttons {
&-container {
align-items: center;
justify-content: space-between;
width: 100%;
}
}
&-backdrop {
width: 100%;
height: 100%;
object-fit: cover;
object-position: top;
opacity: 0;
transition: opacity $transition-time-default;
&-container {
filter: brightness(0.8);
position: absolute;
top: -4.4em;
left: -1.6em;
width: 100vw;
height: calc(50vh + 4.4em);
z-index: -1;
mask-image: linear-gradient(to top, transparent, black);
-webkit-mask-image: linear-gradient(
to top,
transparent,
black
);
}
}
}
&-detail {
display: grid;
grid-template-columns: 1fr 5px 35%;
justify-items: center;
align-items: start;
gap: 1em;
&-cast {
max-height: 50vh;
overflow-y: auto;
mask-image: linear-gradient(to top, transparent, black 1.2em);
-webkit-mask-image: linear-gradient(to top, transparent, black 1.2em);
&-title {
position: sticky;
top: 0;
background: $clr-background-dark;
padding: 0.35em;
border-radius: 10px;
z-index: 1;
}
&-container {
display: flex;
flex-direction: column;
gap: 1em;
}
&-grid {
display: grid;
gap: 1em;
margin-bottom: 1em;
grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}
&-card {
display: grid;
grid-template-columns: 6em 1fr;
gap: 0.5em;
align-items: center;
color: white !important;
text-decoration: none;
padding: 0.5em;
background: rgb(255 255 255 / 0);
transition: background $transition-time-default;
border-radius: $border-radius-default;
&:hover {
background: rgb(255 255 255 / 0.1);
}
&-image,
&-icon {
width: 6em;
height: 6em;
object-fit: cover;
border-radius: 100%;
box-shadow: $shadow-card-image;
}
&-icon {
display: flex;
align-items: center;
justify-content: center;
font-size: 1em;
background: rgb(255 255 255 / 0.1);
.material-symbols-rounded {
font-size: 3em;
}
}
}
}
&-link {
color: white;
text-decoration-color: rgb(255 255 255 / 0.5);
&:hover {
text-decoration-color: white;
}
}
}
}
@media (max-width: 1320px) {
.item-album .item-detail {
&-cast {
&-grid {
grid-template-columns: 1fr;
}
}
}
}
+228 -29
View File
@@ -1,12 +1,15 @@
import PropTypes from "prop-types";
import React, { useEffect } from "react";
import React, { useEffect, useLayoutEffect } from "react";
import Box from "@mui/material/Box";
import Chip from "@mui/material/Chip";
import CircularProgress from "@mui/material/CircularProgress";
import Divider from "@mui/material/Divider";
import Paper from "@mui/material/Paper";
import Stack from "@mui/material/Stack";
import Typography from "@mui/material/Typography";
import { useParams } from "react-router-dom";
import { Link, NavLink, useParams } from "react-router-dom";
import { motion } from "framer-motion";
@@ -20,16 +23,20 @@ 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 { Blurhash } from "react-blurhash";
import { useQuery } from "@tanstack/react-query";
import { getRuntimeMusic } from "../../utils/date/time";
import { endsAt, getRuntime, getRuntimeMusic } from "../../utils/date/time";
import { Card } from "../../components/card/card";
import { CardScroller } from "../../components/cardScroller/cardScroller";
import Hero from "../../components/layouts/item/hero";
import LikeButton from "../../components/buttons/likeButton";
import MarkPlayedButton from "../../components/buttons/markPlayedButton";
import PlayButton from "../../components/buttons/playButton";
import { ErrorNotice } from "../../components/notices/errorNotice/errorNotice";
import { getTypeIcon } from "../../components/utils/iconsCollection";
import { useApi } from "../../utils/store/api";
import { useAudioPlayback } from "../../utils/store/audioPlayback";
import { useBackdropStore } from "../../utils/store/backdrop";
@@ -151,17 +158,14 @@ const MusicAlbumTitlePage = () => {
const [setAppBackdrop] = useBackdropStore((state) => [state.setBackdrop]);
useEffect(() => {
useLayoutEffect(() => {
if (item.isSuccess) {
setAppBackdrop(
item.data.Type === BaseItemKind.MusicAlbum ||
item.data.Type === BaseItemKind.Episode
? `${api.basePath}/Items/${item.data.ParentBackdropItemId}/Images/Backdrop`
: `${api.basePath}/Items/${item.data.Id}/Images/Backdrop`,
`${api.basePath}/Items/${item.data.ParentBackdropItemId}/Images/Backdrop`,
item.data.Id,
);
}
});
}, [item.isSuccess]);
if (item.isPending || similarItems.isPending) {
return (
@@ -192,24 +196,203 @@ const MusicAlbumTitlePage = () => {
duration: 0.25,
ease: "easeInOut",
}}
className="scrollY"
style={{
padding: "5em 2em 2em 1em",
display: "flex",
flexDirection: "column",
gap: "0.5em",
}}
className="scrollY padded-top item-album"
>
<Hero
item={item.data}
userId={user.data.Id}
queryKey={["item", id]}
artists={item.data.ArtistItems}
albumBy={item.data.AlbumArtists[0]}
disableMarkAsPlayedButton
audioPlayButton
cardType="square"
/>
<div className="item-hero flex flex-row">
<div className="item-hero-backdrop-container">
{item.data.BackdropImageTags ? (
<img
alt={item.data.Name}
src={api.getItemImageUrl(
item.data.ParentBackdropItemId,
"Backdrop",
{
tag: item.data.ParentBackdropImageTags[0],
},
)}
className="item-hero-backdrop"
onLoad={(e) => {
e.currentTarget.style.opacity = 1;
}}
/>
) : (
<></>
)}
</div>
<div
className="item-hero-image-container"
style={{
aspectRatio: item.data.PrimaryImageAspectRatio ?? 1,
}}
>
{Object.keys(item.data.ImageTags).includes("Primary") ? (
<>
<Blurhash
hash={
item.data.ImageBlurHashes.Primary[
item.data.ImageTags.Primary
]
}
className="item-hero-image-blurhash"
/>
<img
alt={item.data.Name}
src={api.getItemImageUrl(item.data.Id, "Primary", {
quality: 90,
tag: item.data.ImageTags.Primary,
})}
onLoad={(e) => {
e.currentTarget.style.opacity = 1;
}}
className="item-hero-image"
/>
</>
) : (
<></>
)}
</div>
<div className="item-hero-detail flex flex-column">
<Typography variant="h3">{item.data.Name}</Typography>
<Chip label={`By ${item.data.AlbumArtist}`} />
<Stack
direction="row"
gap={2}
justifyItems="flex-start"
alignItems="center"
>
<Typography style={{ opacity: "0.8" }} variant="subtitle1">
{item.data.ProductionYear ?? ""}
</Typography>
<Typography style={{ opacity: "0.8" }} variant="subtitle1">
{item.data.ChildCount > 1
? `${item.data.ChildCount} Tracks`
: `${item.data.ChildCount}`}
</Typography>
{item.data.RunTimeTicks && (
<Typography style={{ opacity: "0.8" }} variant="subtitle1">
{getRuntime(item.data.RunTimeTicks)}
</Typography>
)}
</Stack>
<Typography variant="subtitle1" style={{ opacity: 0.8 }}>
{item.data.Genres.join(", ")}
</Typography>
<div className="item-hero-buttons-container flex flex-row">
<div className="flex flex-row">
<PlayButton
audio
itemId={item.data.Id}
itemType={item.data.Type}
itemUserData={item.data.UserData}
userId={user.data.Id}
/>
</div>
<div className="flex flex-row" style={{ gap: "1em" }}>
<LikeButton
itemName={item.data.Name}
itemId={item.data.Id}
queryKey={["item", id]}
isFavorite={item.data.UserData.IsFavorite}
userId={user.data.Id}
/>
</div>
</div>
</div>
</div>
<div className="item-detail">
<div style={{ width: "100%" }}>
<Typography variant="subtitle1" style={{ display: "block" }}>
{item.data.Overview ?? ""}
</Typography>
<Divider flexItem orientation="vertical" />
<div
style={{
display: "flex",
gap: "0.6em",
alignSelf: "start",
marginTop: "0.2em",
}}
>
{item.data.ExternalUrls.map((url) => (
<Link
key={url.Url}
target="_blank"
to={url.Url}
className="item-detail-link"
>
<Typography>{url.Name}</Typography>
</Link>
))}
</div>
</div>
<Divider />
<div
style={{
width: "100%",
}}
>
<div className="item-detail-cast">
{item.data.ArtistItems.length > 0 && (
<div className="item-detail-cast-container">
<Typography variant="h6" className="item-detail-cast-title">
Artists
</Typography>
<div className="item-detail-cast-grid">
{item.data.ArtistItems.map((artist) => (
<NavLink
className="item-detail-cast-card"
key={artist.Id}
to={`/person/${artist.Id}`}
>
<div
style={{
width: "5em",
position: "relative",
}}
>
<img
alt={artist.Name}
src={api.getItemImageUrl(artist.Id, "Primary", {
quality: 80,
fillWidth: 200,
fillHeight: 200,
})}
style={{
position: "absolute",
top: 0,
left: 0,
}}
className="item-detail-cast-card-image"
/>
<div className="item-detail-cast-card-icon">
{getTypeIcon("Person")}
</div>
</div>
<div className="item-detail-cast-card-text">
<Typography variant="subtitle1">
{artist.Name}
</Typography>
<Typography
variant="subtitle2"
style={{
opacity: 0.5,
}}
>
{artist.Role}
</Typography>
</div>
</NavLink>
))}
</div>
</div>
)}
</div>
</div>
</div>
{musicTracks.isPending ? (
<></>
) : (
@@ -217,6 +400,7 @@ const MusicAlbumTitlePage = () => {
<Paper
className="item-detail-album-tracks"
style={{
marginTop: "1.2em",
marginBottom: "1.2em",
}}
>
@@ -225,7 +409,7 @@ const MusicAlbumTitlePage = () => {
className="item-detail-album-track"
style={{
padding: "0.75em 0 ",
background: "hsl(256, 100%, 4%, 60%)",
background: "rgb(0 0 0 / 0.6)",
}}
>
<Typography
@@ -265,9 +449,24 @@ const MusicAlbumTitlePage = () => {
variant="subtitle1"
style={{
justifySelf: "end",
display: "flex",
alignItems: "center",
justifyContent: "center",
}}
>
{track.IndexNumber ? track.IndexNumber : "-"}
{(currentTrackItem.Id === track.Id &&
currentTrackItem.ParentId === track.ParentId ? (
<div
className="material-symbols-rounded"
style={{
height: "100%",
}}
>
equalizer
</div>
) : (
track.IndexNumber
)) ?? "-"}
</Typography>
<LikeButton
+2 -2
View File
@@ -158,7 +158,7 @@ const ArtistTitlePage = () => {
setActiveArtistTab(2);
}
}
});
}, []);
const [animationDirection, setAnimationDirection] = useState("forward");
@@ -174,7 +174,7 @@ const ArtistTitlePage = () => {
item.data.Id,
);
}
});
}, []);
if (item.isPending) {
return (
+3 -5
View File
@@ -21,7 +21,7 @@ import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
import { useNavigate } from "react-router-dom";
import { useBackdropStore } from "../../utils/store/backdrop";
import { setBackdrop, useBackdropStore } from "../../utils/store/backdrop";
import { BaseItemKind, ItemFields } from "@jellyfin/sdk/lib/generated-client";
import Typography from "@mui/material/Typography";
@@ -153,8 +153,6 @@ const Home = () => {
});
}
const [setAppBackdrop] = useBackdropStore((state) => [state.setBackdrop]);
if (user.isPaused) {
user.refetch();
console.log(user.isError);
@@ -181,12 +179,12 @@ const Home = () => {
onChange={(now) => {
if (latestMedia.isSuccess && latestMedia.data.length > 0) {
if (latestMedia.data[now]?.ParentBackdropImageTags) {
setAppBackdrop(
setBackdrop(
`${api.basePath}/Items/${latestMedia.data[now].ParentBackdropItemId}/Images/Backdrop`,
latestMedia.data[now].Id,
);
} else {
setAppBackdrop(
setBackdrop(
`${api.basePath}/Items/${latestMedia.data[now].Id}/Images/Backdrop`,
latestMedia.data[now].Id,
);
+5 -6
View File
@@ -1,5 +1,5 @@
import { motion } from "framer-motion";
import React, { useState, useEffect } from "react";
import React, { useState, useEffect, useLayoutEffect } from "react";
import { useParams } from "react-router-dom";
import { useQuery } from "@tanstack/react-query";
@@ -120,7 +120,7 @@ const LibraryView = () => {
*/
const [viewType, setViewType] = useState([]);
useEffect(() => {
useLayoutEffect(() => {
if (currentLib.isError) {
console.error(currentLib.error);
}
@@ -211,8 +211,7 @@ const LibraryView = () => {
]);
}
}
});
}, [currentLib.isSuccess]);
const [filterArray, setFilterArray] = useState([]);
const [videoTypes, setVideoTypes] = useState([]);
@@ -330,10 +329,10 @@ const LibraryView = () => {
const [setAppBackdrop] = useBackdropStore((state) => [state.setBackdrop]);
useState(() => {
useEffect(() => {
// Remove App backdrop in library page
setAppBackdrop("", "");
console.log(items.isSuccess);
// console.log(items.isSuccess);
}, []);
if (items.isError) {
+1 -1
View File
@@ -148,7 +148,7 @@ const SearchPage = () => {
useEffect(() => {
// Removing app's backdrop
setBackdrop("", "");
});
}, []);
return (
<div
className="scrollY"
-1
View File
@@ -100,7 +100,6 @@
}
&-grid {
display: grid;
grid-template-columns: repeat(5, minmax(0, 1fr));
gap: 1em;
margin-bottom: 1em;
}