Update hero carousel [6/-] #136
This commit is contained in:
9 files changed
+108
-181
No files matched your search
+4
-2
@@ -54,7 +54,9 @@ import { SideMenu } from "./components/menu/sidemenu.jsx";
|
||||
import { AppBar } from "./components/appBar/appBar.jsx";
|
||||
|
||||
// Fonts
|
||||
import "@fontsource/open-sans";
|
||||
import "@fontsource-variable/open-sans"; // Defaults to wght axis
|
||||
import "@fontsource-variable/open-sans/wght.css"; // Specify axis
|
||||
import "@fontsource-variable/open-sans/wght-italic.css"; // Specify axis and style
|
||||
|
||||
// Jellyfin SDK TypeScript
|
||||
import {
|
||||
@@ -394,7 +396,7 @@ function App() {
|
||||
<CssBaseline />
|
||||
<SideMenu />
|
||||
<AppBar />
|
||||
<Routes key={location.pathname} location={location}>
|
||||
<Routes key={location.key} location={location}>
|
||||
<Route element={<AnimationWrapper />}>
|
||||
<Route
|
||||
path="/"
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import CircularProgress from "@mui/material/CircularProgress";
|
||||
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { green, pink } from "@mui/material/colors";
|
||||
import { MdiHeart } from "../icons/mdiHeart";
|
||||
import { MdiHeartOutline } from "../icons/mdiHeartOutline";
|
||||
import { green } from "@mui/material/colors";
|
||||
|
||||
import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api/playstate-api";
|
||||
import { MdiCheck } from "../icons/mdiCheck";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/** @format */
|
||||
import { memo } from "react";
|
||||
import { Blurhash } from "react-blurhash";
|
||||
|
||||
import { motion } from "framer-motion";
|
||||
@@ -8,11 +9,9 @@ import Box from "@mui/material/Box";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import Stack from "@mui/material/Stack";
|
||||
import Chip from "@mui/material/Chip";
|
||||
import LinearProgress from "@mui/material/LinearProgress";
|
||||
import Button from "@mui/material/Button";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
|
||||
import { pink, yellow } from "@mui/material/colors";
|
||||
import { yellow } from "@mui/material/colors";
|
||||
|
||||
import { ErrorBoundary } from "react-error-boundary";
|
||||
|
||||
@@ -32,6 +31,7 @@ import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { useSnackbar } from "notistack";
|
||||
import LikeButton from "../buttons/likeButton";
|
||||
import MarkPlayedButton from "../buttons/markPlayedButton";
|
||||
import { theme } from "../../theme";
|
||||
|
||||
const CarouselSlide = ({ item }) => {
|
||||
const navigate = useNavigate();
|
||||
@@ -45,6 +45,8 @@ const CarouselSlide = ({ item }) => {
|
||||
networkMode: "always",
|
||||
});
|
||||
|
||||
// consoe;
|
||||
|
||||
// const favouriteButtonMutation =
|
||||
|
||||
return (
|
||||
@@ -53,6 +55,7 @@ const CarouselSlide = ({ item }) => {
|
||||
className="hero-carousel-slide"
|
||||
sx={{
|
||||
background: "transparent",
|
||||
px: 3,
|
||||
}}
|
||||
>
|
||||
<div className="hero-carousel-background-container">
|
||||
@@ -80,12 +83,9 @@ const CarouselSlide = ({ item }) => {
|
||||
<div
|
||||
className="hero-carousel-background-image"
|
||||
style={{
|
||||
backgroundImage: `url(${
|
||||
window.api.basePath +
|
||||
"/Items/" +
|
||||
item.Id +
|
||||
"/Images/Backdrop"
|
||||
})`,
|
||||
backgroundImage: !!item.ParentBackdropItemId
|
||||
? `url('${window.api.basePath}/Items/${item.ParentBackdropItemId}/Images/Backdrop')`
|
||||
: `url('${window.api.basePath}/Items/${item.Id}/Images/Backdrop')`,
|
||||
}}
|
||||
></div>
|
||||
<div className="hero-carousel-background-icon-container">
|
||||
@@ -116,6 +116,7 @@ const CarouselSlide = ({ item }) => {
|
||||
y: 0,
|
||||
opacity: 1,
|
||||
}}
|
||||
overflow="visible"
|
||||
>
|
||||
{!item.ImageTags.Logo ? (
|
||||
item.Name
|
||||
@@ -166,21 +167,14 @@ const CarouselSlide = ({ item }) => {
|
||||
}
|
||||
className="hero-carousel-info"
|
||||
>
|
||||
<Typography
|
||||
variant="subtitle1"
|
||||
// color="GrayText"
|
||||
>
|
||||
<Typography variant="subtitle1">
|
||||
{!!item.ProductionYear
|
||||
? item.ProductionYear
|
||||
: "Unknown"}
|
||||
</Typography>
|
||||
<Chip
|
||||
variant="filled"
|
||||
label={
|
||||
!!item.OfficialRating
|
||||
? item.OfficialRating
|
||||
: "Not Rated"
|
||||
}
|
||||
label={item.OfficialRating ?? "Not Rated"}
|
||||
/>
|
||||
<Box
|
||||
sx={{
|
||||
@@ -254,54 +248,6 @@ const CarouselSlide = ({ item }) => {
|
||||
{item.Overview}
|
||||
</Typography>
|
||||
|
||||
{item.UserData.PlaybackPositionTicks > 0 && (
|
||||
<Stack
|
||||
component={motion.div}
|
||||
initial={{
|
||||
y: 10,
|
||||
opacity: 0,
|
||||
}}
|
||||
transition={{
|
||||
duration: 0.25,
|
||||
delay: 0.3,
|
||||
}}
|
||||
whileInView={{
|
||||
y: 0,
|
||||
opacity: 1,
|
||||
}}
|
||||
exit={{
|
||||
y: 10,
|
||||
opacity: 0,
|
||||
}}
|
||||
direction="row"
|
||||
gap="1em"
|
||||
mt={2}
|
||||
width="50%"
|
||||
alignItems="center"
|
||||
justifyContent="center"
|
||||
>
|
||||
<Typography
|
||||
variant="subtitle1"
|
||||
whiteSpace="nowrap"
|
||||
>
|
||||
{getRuntime(
|
||||
item.RunTimeTicks -
|
||||
item.UserData
|
||||
.PlaybackPositionTicks,
|
||||
)}
|
||||
</Typography>
|
||||
<LinearProgress
|
||||
variant="determinate"
|
||||
value={item.UserData.PlayedPercentage}
|
||||
color="white"
|
||||
sx={{
|
||||
borderRadius: 1,
|
||||
height: "2.5px",
|
||||
width: "100%",
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
)}
|
||||
{/* TODO Link PLay and More info buttons in carousel */}
|
||||
<Stack
|
||||
component={motion.div}
|
||||
@@ -324,16 +270,47 @@ const CarouselSlide = ({ item }) => {
|
||||
mt={3}
|
||||
direction="row"
|
||||
gap={3}
|
||||
width="100%"
|
||||
className="hero-carousel-button-container"
|
||||
alignItems="center"
|
||||
>
|
||||
<Button
|
||||
variant="contained"
|
||||
endIcon={<MdiPlayOutline />}
|
||||
disabled
|
||||
<Stack
|
||||
direction="row"
|
||||
gap="1em"
|
||||
alignItems="center"
|
||||
justifyContent="center"
|
||||
>
|
||||
Play
|
||||
</Button>
|
||||
<Button
|
||||
variant="contained"
|
||||
size="large"
|
||||
disabled
|
||||
startIcon={
|
||||
<MdiPlayOutline
|
||||
sx={{ fontSize: "1.4em" }}
|
||||
/>
|
||||
}
|
||||
sx={{
|
||||
textTransform: "none !important",
|
||||
}}
|
||||
>
|
||||
{item.UserData.PlaybackPositionTicks >
|
||||
0 ? (
|
||||
<Stack
|
||||
direction="column"
|
||||
gap="0.2em"
|
||||
alignItems="flex-start"
|
||||
justifyContent="center"
|
||||
>
|
||||
Resume
|
||||
</Stack>
|
||||
) : (
|
||||
"Play"
|
||||
)}
|
||||
</Button>
|
||||
</Stack>
|
||||
|
||||
<Button
|
||||
size="large"
|
||||
color="white"
|
||||
variant="outlined"
|
||||
endIcon={<MdiChevronRight />}
|
||||
@@ -364,4 +341,4 @@ const CarouselSlide = ({ item }) => {
|
||||
);
|
||||
};
|
||||
|
||||
export default CarouselSlide;
|
||||
export default memo(CarouselSlide);
|
||||
@@ -90,8 +90,8 @@
|
||||
-webkit-line-clamp: 2;
|
||||
margin-bottom: 0.5em;
|
||||
&-logo {
|
||||
max-width: 12em;
|
||||
height: 2em;
|
||||
max-width: 9em;
|
||||
height: 3em;
|
||||
object-fit: contain;
|
||||
object-position: bottom;
|
||||
}
|
||||
|
||||
+40
-92
@@ -95,6 +95,18 @@ const Home = () => {
|
||||
networkMode: "always",
|
||||
});
|
||||
|
||||
const latestMediaLibraries = useQuery({
|
||||
queryKey: ["libraries"],
|
||||
queryFn: async () => {
|
||||
let libs = await getUserViewsApi(window.api).getUserViews({
|
||||
userId: user.data.Id,
|
||||
});
|
||||
return libs.data;
|
||||
},
|
||||
enabled: !!user.data,
|
||||
networkMode: "always",
|
||||
});
|
||||
|
||||
const latestMedia = useQuery({
|
||||
queryKey: ["home", "latestMedia"],
|
||||
queryFn: async () => {
|
||||
@@ -110,7 +122,6 @@ const Home = () => {
|
||||
],
|
||||
enableUserData: true,
|
||||
enableImages: true,
|
||||
limit: 16,
|
||||
},
|
||||
);
|
||||
return media.data;
|
||||
@@ -172,30 +183,22 @@ const Home = () => {
|
||||
|
||||
const excludeTypes = ["boxsets", "playlists", "livetv", "channels"];
|
||||
|
||||
const handleLogout = async () => {
|
||||
console.log("Logging out user...");
|
||||
await window.api.logout();
|
||||
delUser();
|
||||
sessionStorage.removeItem("accessToken");
|
||||
event.emit("create-jellyfin-api", window.api.basePath);
|
||||
navigate("/login");
|
||||
};
|
||||
|
||||
let tempData = [];
|
||||
if (libraries.status == "success") {
|
||||
libraries.data.Items.map((lib) => {
|
||||
if (!excludeTypes.includes(lib.CollectionType)) {
|
||||
tempData = latestMediaLibs;
|
||||
if (
|
||||
!tempData.some(
|
||||
(el) =>
|
||||
JSON.stringify(el) ==
|
||||
JSON.stringify([lib.Id, lib.Name]),
|
||||
)
|
||||
) {
|
||||
tempData.push([lib.Id, lib.Name]);
|
||||
setLatestMediaLibs(tempData);
|
||||
}
|
||||
if (excludeTypes.includes(lib.CollectionType)) {
|
||||
return;
|
||||
}
|
||||
tempData = latestMediaLibs;
|
||||
if (
|
||||
!tempData.some(
|
||||
(el) =>
|
||||
JSON.stringify(el) ==
|
||||
JSON.stringify([lib.Id, lib.Name]),
|
||||
)
|
||||
) {
|
||||
tempData.push([lib.Id, lib.Name]);
|
||||
setLatestMediaLibs(tempData);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -226,6 +229,7 @@ const Home = () => {
|
||||
autoPlay={false}
|
||||
animation="fade"
|
||||
height="100vh"
|
||||
// navButtonsAlwaysVisible
|
||||
IndicatorIcon={
|
||||
<div className="hero-carousel-indicator"></div>
|
||||
}
|
||||
@@ -257,10 +261,20 @@ const Home = () => {
|
||||
}}
|
||||
onChange={(now) => {
|
||||
if (latestMedia.isSuccess) {
|
||||
setAppBackdrop(
|
||||
`${window.api.basePath}/Items/${latestMedia.data[now].Id}/Images/Backdrop`,
|
||||
latestMedia.data[now].Id,
|
||||
);
|
||||
if (
|
||||
!!latestMedia.data[now]
|
||||
.ParentBackdropImageTags
|
||||
) {
|
||||
setAppBackdrop(
|
||||
`${window.api.basePath}/Items/${latestMedia.data[now].ParentBackdropItemId}/Images/Backdrop`,
|
||||
latestMedia.data[now].Id,
|
||||
);
|
||||
} else {
|
||||
setAppBackdrop(
|
||||
`${window.api.basePath}/Items/${latestMedia.data[now].Id}/Images/Backdrop`,
|
||||
latestMedia.data[now].Id,
|
||||
);
|
||||
}
|
||||
}
|
||||
}}
|
||||
changeOnFirstRender={true}
|
||||
@@ -579,70 +593,4 @@ const Home = () => {
|
||||
);
|
||||
};
|
||||
|
||||
/* <MuiDrawer
|
||||
anchor="left"
|
||||
open={drawerState}
|
||||
onClose={handleDrawerClose}
|
||||
>
|
||||
<DrawerHeader
|
||||
className="Mui-DrawerHeader"
|
||||
sx={{ position: "relative", height: "20vh" }}
|
||||
>
|
||||
<div>
|
||||
<Avatar src={""}/>
|
||||
<Typography variant="h3">
|
||||
{user["Name"]}
|
||||
</Typography>
|
||||
</div>
|
||||
<IconButton
|
||||
onClick={handleDrawerClose}
|
||||
sx={{
|
||||
position: "absolute",
|
||||
top: "10%",
|
||||
right: "5%",
|
||||
}}
|
||||
>
|
||||
<Close />
|
||||
</IconButton>
|
||||
</DrawerHeader>
|
||||
<Divider />
|
||||
<List sx={{ border: "none" }}>
|
||||
{userLibraries.map((library, index) => {
|
||||
return (
|
||||
<ListItem disablePadding key={index}>
|
||||
<ListItemButton
|
||||
sx={{
|
||||
minHeight: 48,
|
||||
justifyContent:
|
||||
drawerState
|
||||
? "initial"
|
||||
: "center",
|
||||
px: 2.5,
|
||||
}}
|
||||
>
|
||||
<ListItemIcon
|
||||
sx={{
|
||||
minWidth: 0,
|
||||
mr: 3,
|
||||
justifyContent:
|
||||
"center",
|
||||
}}
|
||||
>
|
||||
{
|
||||
MediaCollectionTypeIconCollection[
|
||||
library
|
||||
.CollectionType
|
||||
]
|
||||
}
|
||||
</ListItemIcon>
|
||||
<ListItemText
|
||||
primary={library.Name}
|
||||
/>
|
||||
</ListItemButton>
|
||||
</ListItem>
|
||||
);
|
||||
})}
|
||||
</List>
|
||||
</MuiDrawer> */
|
||||
|
||||
export default Home;
|
||||
@@ -30,7 +30,7 @@ div::-webkit-scrollbar {
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: "Open Sans";
|
||||
font-family: "Open Sans Variable";
|
||||
background: $clr-background-default;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
@@ -39,6 +39,7 @@ body {
|
||||
height: 100vh;
|
||||
overflow-x: hidden;
|
||||
overflow-y: overlay;
|
||||
overscroll-behavior: none;
|
||||
}
|
||||
|
||||
.app-backdrop {
|
||||
@@ -127,7 +128,7 @@ h1 {
|
||||
|
||||
.home {
|
||||
padding-left: 0 !important;
|
||||
padding-right: 0 !important;
|
||||
padding-right: 14px !important;
|
||||
}
|
||||
|
||||
.empty {
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ export const theme = createTheme({
|
||||
mode: "dark",
|
||||
},
|
||||
typography: {
|
||||
fontFamily: "Open Sans",
|
||||
fontFamily: "Open Sans Variable",
|
||||
},
|
||||
components: {
|
||||
MuiButton: {
|
||||
|
||||
Reference in new issue
Block a user