Implement Episode Page #58

This commit is contained in:
prayag17 committed 2023-05-04 18:40:31 +05:30
1 parent e47b7afd15
commit dd4f5bab30
5 files changed
+138 -40

No files matched your search

+2
View File
@@ -372,10 +372,12 @@ function App() {
element={<UserLoginManual />}
/>
<Route
exact
path="/library/:id"
element={<LibraryView />}
/>
<Route
exact
path="/item/:id"
element={<ItemDetail />}
/>
+1 -1
View File
@@ -50,7 +50,7 @@ export const CardScroller = ({
const [carouselRef, setCarouselRef] = useState();
return (
<Box {...boxProps} className="card-scroller-container" sx={{ mb: 4 }}>
<Box {...boxProps} className="card-scroller-container" mb={1}>
<Box
sx={{ mb: 1 }}
className={
+130 -33
View File
@@ -206,6 +206,19 @@ const ItemDetail = () => {
refetchOnWindowFocus: true,
});
const upcomingEpisodes = useQuery({
queryKey: ["item", id, "episode", "upcomingEpisodes"],
queryFn: async () => {
const result = await getItemsApi(window.api).getItems({
userId: user.data.Id,
parentId: item.data.ParentId,
startIndex: item.data.IndexNumber,
});
return result.data;
},
enabled: item.isSuccess && item.data.Type == BaseItemKind.Episode,
});
const personMovies = useQuery({
queryKey: ["item", id, "personMovies"],
queryFn: async () => {
@@ -569,17 +582,23 @@ const ItemDetail = () => {
className="item-detail-header"
mb={2}
paddingTop={
item.data.Type.includes("Music") ? 10 : 0
item.data.Type.includes("Music") ||
item.data.Type === BaseItemKind.Episode
? 10
: 0
}
>
<Box className="item-detail-header-backdrop">
{item.data.Type != BaseItemKind.MusicAlbum
{item.data.Type != BaseItemKind.MusicAlbum &&
item.data.Type != BaseItemKind.Episode
? item.data.BackdropImageTags.length !=
0 && (
<img
src={
item.data.Type ==
BaseItemKind.MusicAlbum
item.data.Type ===
BaseItemKind.MusicAlbum ||
item.data.Type ===
BaseItemKind.Episode
? `${window.api.basePath}/Items/${item.data.ParentBackdropItemId}/Images/Backdrop`
: `${window.api.basePath}/Items/${item.data.Id}/Images/Backdrop`
}
@@ -599,8 +618,10 @@ const ItemDetail = () => {
: !!item.data.ParentBackdropItemId && (
<img
src={
item.data.Type ==
BaseItemKind.MusicAlbum
item.data.Type ===
BaseItemKind.MusicAlbum ||
item.data.Type ===
BaseItemKind.Episode
? `${window.api.basePath}/Items/${item.data.ParentBackdropItemId}/Images/Backdrop`
: `${window.api.basePath}/Items/${item.data.Id}/Images/Backdrop`
}
@@ -650,20 +671,20 @@ const ItemDetail = () => {
display: "flex",
gap: 3,
flexDirection: "row",
alignItems: "flex-end",
alignItems:
item.data.Type ===
BaseItemKind.Episode
? "center !important"
: "flex-end",
justifyContent: "flex-start",
width: "100%",
}}
>
<Box
className="item-detail-image-container"
sx={
item.data.Type.includes("Music")
? {
aspectRatio: "1",
}
: {}
}
className={`item-detail-image-container ${item.data.Type}`}
sx={{
aspectRatio: `${item.data.PrimaryImageAspectRatio}`,
}}
>
<Chip
className="card-indicator"
@@ -714,7 +735,9 @@ const ItemDetail = () => {
resolutionX={12}
resolutionY={8}
style={{
aspectRatio: 0.666,
aspectRatio:
item.data
.PrimaryImageAspectRatio,
}}
className="item-detail-image-blurhash"
/>
@@ -737,22 +760,59 @@ const ItemDetail = () => {
className="item-detail-title-name"
sx={{ mb: 1 }}
>
<Typography
variant="h3"
textOverflow="ellipsis"
whiteSpace="nowrap"
width="100%"
>
{!!item.data.ImageTags
.Logo ? (
<img
className="item-detail-title-logo"
src={`${window.api.basePath}/Items/${item.data.Id}/Images/Logo?cropWhitespace=True&quality=80&tag=${item.data.ImageTags.Logo}`}
/>
) : (
item.data.Name
)}
</Typography>
{item.data.Type ===
BaseItemKind.Episode && (
<Link
component={RouterLink}
to={`/item/${item.data.SeriesId}`}
variant="h3"
textOverflow="ellipsis"
whiteSpace="nowrap"
width="100%"
color="inherit"
underline="hover"
mb={1}
>
{!!item.data
.ParentLogoItemId ? (
<img
className="item-detail-title-logo"
src={`${window.api.basePath}/Items/${item.data.SeriesId}/Images/Logo?cropWhitespace=True&quality=80&tag=${item.data.ParentLogoImageTag}`}
/>
) : (
item.data.SeriesName
)}
</Link>
)}
{item.data.Type ===
BaseItemKind.Episode ? (
<Typography
variant="h4"
textOverflow="ellipsis"
whiteSpace="nowrap"
width="100%"
sx={{ opacity: 0.7 }}
>
{`S${item.data.ParentIndexNumber}:E${item.data.IndexNumber} - ${item.data.Name}`}
</Typography>
) : (
<Typography
variant="h3"
textOverflow="ellipsis"
whiteSpace="nowrap"
width="100%"
>
{!!item.data.ImageTags
.Logo ? (
<img
className="item-detail-title-logo"
src={`${window.api.basePath}/Items/${item.data.Id}/Images/Logo?cropWhitespace=True&quality=80&tag=${item.data.ImageTags.Logo}`}
/>
) : (
item.data.Name
)}
</Typography>
)}
<Typography
variant="h6"
sx={{ opacity: 0.7 }}
@@ -2796,6 +2856,44 @@ const ItemDetail = () => {
</Box>
)}
{item.data.Type === BaseItemKind.Episode && (
<CardScroller
headingProps={{
variant: "h5",
fontSize: "1.8em",
}}
displayCards={4}
title="Upcoming Episodes"
disableDecoration
boxProps={{
mt: 2,
}}
>
{upcomingEpisodes.isSuccess &&
upcomingEpisodes.data.Items.map(
(episode, index) => {
return (
<Card
key={episode.Id}
itemName={`E${episode.ParentIndexNumber}:S${episode.IndexNumber} - ${episode.Name}`}
itemId={episode.Id}
imageTags={
!!episode
.ImageTags
?.Primary
}
iconType="Episode"
cardOrientation="landscape"
currentUser={
user.data
}
/>
);
},
)}
</CardScroller>
)}
{item.data.People.length != 0 && (
<CardScroller
headingProps={{
@@ -2815,7 +2913,6 @@ const ItemDetail = () => {
key={index}
itemName={person.Name}
itemId={person.Id}
// imageTags={false}
imageTags={
!!person.PrimaryImageTag
}
+4 -1
View File
@@ -52,10 +52,13 @@
width: 15%;
flex-shrink: 0;
position: relative;
aspect-ratio: 0.666;
border-radius: $border-radius-default;
overflow: hidden;
box-shadow: 0 0 15px rgb(0 0 0 / 0.4);
&.Episode {
flex-shrink: 0;
flex-grow: 0.25;
}
}
&-icon-container {
background: $clr-gradient-dark;
+1 -5
View File
@@ -46,13 +46,9 @@ body {
height: fit-content;
width: 100%;
position: relative;
overflow-y: visible;
overflow-y: hidden;
overflow-x: hidden;
min-height: 100vh;
// display: flex;
// flex-direction: column;
// justify-content: center;
// align-items: center;
}
.centered {