Update hero carousel [6/-] #136

This commit is contained in:
Prayag Prajapati committed 2023-08-20 21:58:17 +05:30
1 parent 8bd719ece9
commit 464a4508e3
9 files changed
+108 -181

No files matched your search

+5 -5
View File
@@ -11,7 +11,7 @@
"dependencies": { "dependencies": {
"@emotion/react": "^11.11.1", "@emotion/react": "^11.11.1",
"@emotion/styled": "^11.10.5", "@emotion/styled": "^11.10.5",
"@fontsource/open-sans": "^5.0.5", "@fontsource-variable/open-sans": "^5.0.9",
"@jellyfin/sdk": "^0.8.2", "@jellyfin/sdk": "^0.8.2",
"@mdi/js": "^7.2.96", "@mdi/js": "^7.2.96",
"@mui/lab": "^5.0.0-alpha.134", "@mui/lab": "^5.0.0-alpha.134",
@@ -840,10 +840,10 @@
"node": ">=12" "node": ">=12"
} }
}, },
"node_modules/@fontsource/open-sans": { "node_modules/@fontsource-variable/open-sans": {
"version": "5.0.8", "version": "5.0.9",
"resolved": "https://registry.npmjs.org/@fontsource/open-sans/-/open-sans-5.0.8.tgz", "resolved": "https://registry.npmjs.org/@fontsource-variable/open-sans/-/open-sans-5.0.9.tgz",
"integrity": "sha512-d3Shc6QHoZMzZIL6m4M/geyK0EXHqLvUm9fmlkr1L/AEWgIasoLEBMKEdMczV2e66SHYAYKagIsBwfWnVhmPGQ==" "integrity": "sha512-J44/EFkcEpSlceL4frtK0g5nEjPlJLYSnPN+eQed9ePp6HXf4WUwCeU7QhAS0ScIm6whK9auVygc8lkDshlM+Q=="
}, },
"node_modules/@jellyfin/sdk": { "node_modules/@jellyfin/sdk": {
"version": "0.8.2", "version": "0.8.2",
+1 -1
View File
@@ -12,7 +12,7 @@
"dependencies": { "dependencies": {
"@emotion/react": "^11.11.1", "@emotion/react": "^11.11.1",
"@emotion/styled": "^11.10.5", "@emotion/styled": "^11.10.5",
"@fontsource/open-sans": "^5.0.5", "@fontsource-variable/open-sans": "^5.0.9",
"@jellyfin/sdk": "^0.8.2", "@jellyfin/sdk": "^0.8.2",
"@mdi/js": "^7.2.96", "@mdi/js": "^7.2.96",
"@mui/lab": "^5.0.0-alpha.134", "@mui/lab": "^5.0.0-alpha.134",
+4 -2
View File
@@ -54,7 +54,9 @@ import { SideMenu } from "./components/menu/sidemenu.jsx";
import { AppBar } from "./components/appBar/appBar.jsx"; import { AppBar } from "./components/appBar/appBar.jsx";
// Fonts // 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 // Jellyfin SDK TypeScript
import { import {
@@ -394,7 +396,7 @@ function App() {
<CssBaseline /> <CssBaseline />
<SideMenu /> <SideMenu />
<AppBar /> <AppBar />
<Routes key={location.pathname} location={location}> <Routes key={location.key} location={location}>
<Route element={<AnimationWrapper />}> <Route element={<AnimationWrapper />}>
<Route <Route
path="/" path="/"
+2 -3
View File
@@ -2,11 +2,10 @@
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import IconButton from "@mui/material/IconButton"; import IconButton from "@mui/material/IconButton";
import CircularProgress from "@mui/material/CircularProgress";
import { useMutation, useQueryClient } from "@tanstack/react-query"; import { useMutation, useQueryClient } from "@tanstack/react-query";
import { green, pink } from "@mui/material/colors"; import { green } from "@mui/material/colors";
import { MdiHeart } from "../icons/mdiHeart";
import { MdiHeartOutline } from "../icons/mdiHeartOutline";
import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api/playstate-api"; import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api/playstate-api";
import { MdiCheck } from "../icons/mdiCheck"; import { MdiCheck } from "../icons/mdiCheck";
+50 -73
View File
@@ -1,4 +1,5 @@
/** @format */ /** @format */
import { memo } from "react";
import { Blurhash } from "react-blurhash"; import { Blurhash } from "react-blurhash";
import { motion } from "framer-motion"; import { motion } from "framer-motion";
@@ -8,11 +9,9 @@ import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography"; import Typography from "@mui/material/Typography";
import Stack from "@mui/material/Stack"; import Stack from "@mui/material/Stack";
import Chip from "@mui/material/Chip"; import Chip from "@mui/material/Chip";
import LinearProgress from "@mui/material/LinearProgress";
import Button from "@mui/material/Button"; 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"; 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 { useSnackbar } from "notistack";
import LikeButton from "../buttons/likeButton"; import LikeButton from "../buttons/likeButton";
import MarkPlayedButton from "../buttons/markPlayedButton"; import MarkPlayedButton from "../buttons/markPlayedButton";
import { theme } from "../../theme";
const CarouselSlide = ({ item }) => { const CarouselSlide = ({ item }) => {
const navigate = useNavigate(); const navigate = useNavigate();
@@ -45,6 +45,8 @@ const CarouselSlide = ({ item }) => {
networkMode: "always", networkMode: "always",
}); });
// consoe;
// const favouriteButtonMutation = // const favouriteButtonMutation =
return ( return (
@@ -53,6 +55,7 @@ const CarouselSlide = ({ item }) => {
className="hero-carousel-slide" className="hero-carousel-slide"
sx={{ sx={{
background: "transparent", background: "transparent",
px: 3,
}} }}
> >
<div className="hero-carousel-background-container"> <div className="hero-carousel-background-container">
@@ -80,12 +83,9 @@ const CarouselSlide = ({ item }) => {
<div <div
className="hero-carousel-background-image" className="hero-carousel-background-image"
style={{ style={{
backgroundImage: `url(${ backgroundImage: !!item.ParentBackdropItemId
window.api.basePath + ? `url('${window.api.basePath}/Items/${item.ParentBackdropItemId}/Images/Backdrop')`
"/Items/" + : `url('${window.api.basePath}/Items/${item.Id}/Images/Backdrop')`,
item.Id +
"/Images/Backdrop"
})`,
}} }}
></div> ></div>
<div className="hero-carousel-background-icon-container"> <div className="hero-carousel-background-icon-container">
@@ -116,6 +116,7 @@ const CarouselSlide = ({ item }) => {
y: 0, y: 0,
opacity: 1, opacity: 1,
}} }}
overflow="visible"
> >
{!item.ImageTags.Logo ? ( {!item.ImageTags.Logo ? (
item.Name item.Name
@@ -166,21 +167,14 @@ const CarouselSlide = ({ item }) => {
} }
className="hero-carousel-info" className="hero-carousel-info"
> >
<Typography <Typography variant="subtitle1">
variant="subtitle1"
// color="GrayText"
>
{!!item.ProductionYear {!!item.ProductionYear
? item.ProductionYear ? item.ProductionYear
: "Unknown"} : "Unknown"}
</Typography> </Typography>
<Chip <Chip
variant="filled" variant="filled"
label={ label={item.OfficialRating ?? "Not Rated"}
!!item.OfficialRating
? item.OfficialRating
: "Not Rated"
}
/> />
<Box <Box
sx={{ sx={{
@@ -254,54 +248,6 @@ const CarouselSlide = ({ item }) => {
{item.Overview} {item.Overview}
</Typography> </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 */} {/* TODO Link PLay and More info buttons in carousel */}
<Stack <Stack
component={motion.div} component={motion.div}
@@ -324,16 +270,47 @@ const CarouselSlide = ({ item }) => {
mt={3} mt={3}
direction="row" direction="row"
gap={3} gap={3}
width="100%"
className="hero-carousel-button-container" className="hero-carousel-button-container"
alignItems="center"
> >
<Button <Stack
variant="contained" direction="row"
endIcon={<MdiPlayOutline />} gap="1em"
disabled 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 <Button
size="large"
color="white" color="white"
variant="outlined" variant="outlined"
endIcon={<MdiChevronRight />} endIcon={<MdiChevronRight />}
@@ -364,4 +341,4 @@ const CarouselSlide = ({ item }) => {
); );
}; };
export default CarouselSlide; export default memo(CarouselSlide);
+2 -2
View File
@@ -90,8 +90,8 @@
-webkit-line-clamp: 2; -webkit-line-clamp: 2;
margin-bottom: 0.5em; margin-bottom: 0.5em;
&-logo { &-logo {
max-width: 12em; max-width: 9em;
height: 2em; height: 3em;
object-fit: contain; object-fit: contain;
object-position: bottom; object-position: bottom;
} }
+40 -92
View File
@@ -95,6 +95,18 @@ const Home = () => {
networkMode: "always", 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({ const latestMedia = useQuery({
queryKey: ["home", "latestMedia"], queryKey: ["home", "latestMedia"],
queryFn: async () => { queryFn: async () => {
@@ -110,7 +122,6 @@ const Home = () => {
], ],
enableUserData: true, enableUserData: true,
enableImages: true, enableImages: true,
limit: 16,
}, },
); );
return media.data; return media.data;
@@ -172,30 +183,22 @@ const Home = () => {
const excludeTypes = ["boxsets", "playlists", "livetv", "channels"]; 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 = []; let tempData = [];
if (libraries.status == "success") { if (libraries.status == "success") {
libraries.data.Items.map((lib) => { libraries.data.Items.map((lib) => {
if (!excludeTypes.includes(lib.CollectionType)) { if (excludeTypes.includes(lib.CollectionType)) {
tempData = latestMediaLibs; return;
if ( }
!tempData.some( tempData = latestMediaLibs;
(el) => if (
JSON.stringify(el) == !tempData.some(
JSON.stringify([lib.Id, lib.Name]), (el) =>
) JSON.stringify(el) ==
) { JSON.stringify([lib.Id, lib.Name]),
tempData.push([lib.Id, lib.Name]); )
setLatestMediaLibs(tempData); ) {
} tempData.push([lib.Id, lib.Name]);
setLatestMediaLibs(tempData);
} }
}); });
} }
@@ -226,6 +229,7 @@ const Home = () => {
autoPlay={false} autoPlay={false}
animation="fade" animation="fade"
height="100vh" height="100vh"
// navButtonsAlwaysVisible
IndicatorIcon={ IndicatorIcon={
<div className="hero-carousel-indicator"></div> <div className="hero-carousel-indicator"></div>
} }
@@ -257,10 +261,20 @@ const Home = () => {
}} }}
onChange={(now) => { onChange={(now) => {
if (latestMedia.isSuccess) { if (latestMedia.isSuccess) {
setAppBackdrop( if (
`${window.api.basePath}/Items/${latestMedia.data[now].Id}/Images/Backdrop`, !!latestMedia.data[now]
latestMedia.data[now].Id, .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} 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; export default Home;
+3 -2
View File
@@ -30,7 +30,7 @@ div::-webkit-scrollbar {
} }
body { body {
font-family: "Open Sans"; font-family: "Open Sans Variable";
background: $clr-background-default; background: $clr-background-default;
margin: 0; margin: 0;
padding: 0; padding: 0;
@@ -39,6 +39,7 @@ body {
height: 100vh; height: 100vh;
overflow-x: hidden; overflow-x: hidden;
overflow-y: overlay; overflow-y: overlay;
overscroll-behavior: none;
} }
.app-backdrop { .app-backdrop {
@@ -127,7 +128,7 @@ h1 {
.home { .home {
padding-left: 0 !important; padding-left: 0 !important;
padding-right: 0 !important; padding-right: 14px !important;
} }
.empty { .empty {
+1 -1
View File
@@ -32,7 +32,7 @@ export const theme = createTheme({
mode: "dark", mode: "dark",
}, },
typography: { typography: {
fontFamily: "Open Sans", fontFamily: "Open Sans Variable",
}, },
components: { components: {
MuiButton: { MuiButton: {