Improve home-carousel display for smaller displays

This commit is contained in:
Prayag Prajapati committed 2024-01-12 14:52:27 +05:30
1 parent e330b7e2f9
commit 7730ad1858
8 files changed
+324 -134

No files matched your search

+48 -58
View File
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from "react";
import React, { useState, useEffect, useLayoutEffect } from "react";
import { ThemeProvider } from "@mui/material/styles";
import { AnimatePresence, motion } from "framer-motion";
@@ -27,15 +27,17 @@ import LoadingButton from "@mui/lab/LoadingButton";
import Button from "@mui/material/Button";
// MUI
import Dialog from "@mui/material/Dialog";
import DialogActions from "@mui/material/DialogActions";
import DialogContent from "@mui/material/DialogContent";
import DialogContentText from "@mui/material/DialogContentText";
import DialogTitle from "@mui/material/DialogTitle";
import IconButton from "@mui/material/IconButton";
import LinearProgress from "@mui/material/LinearProgress";
import SvgIcon from "@mui/material/SvgIcon";
import Typography from "@mui/material/Typography";
import {
Chip,
Dialog,
DialogActions,
DialogContent,
DialogContentText,
DialogTitle,
IconButton,
LinearProgress,
SvgIcon,
} from "@mui/material";
// Routes
import About from "./routes/about";
@@ -63,6 +65,7 @@ import { ServerSetup } from "./routes/setup/server";
import ServerList from "./routes/setup/serverList/index.jsx";
import Markdown from "react-markdown";
import remarkGfm from "remark-gfm";
// Fonts
import "@fontsource-variable/jetbrains-mono";
@@ -99,12 +102,12 @@ import { setInitialRoute, useCentralStore } from "./utils/store/central.js";
import { usePlaybackDataLoadStore } from "./utils/store/playback";
// 3rd Party
import { Api } from "@jellyfin/sdk";
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
import { CircularProgress } from "@mui/material";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import { useSnackbar } from "notistack";
import { ErrorBoundary } from "react-error-boundary";
import { EasterEgg } from "./components/utils/easterEgg.jsx";
import { handleRelaunch } from "./utils/misc/relaunch";
import {
@@ -117,38 +120,6 @@ import {
import { UserStore, delUser, getUser } from "./utils/storage/user";
import { createApi, useApi } from "./utils/store/api";
// const anim = {
// initial: {
// transform: "scale(0.98)",
// opacity: 0,
// },
// animate: {
// transform: "scale(1)",
// opacity: 1,
// },
// exit: {
// transform: "sscale(1.02)",
// opacity: 0,
// },
// };
// const AnimationWrapper = () => {
// return (
// <motion.div
// className="root-page"
// variants={anim}
// initial="initial"
// animate="animate"
// exit="exit"
// transition={{
// duration: 0.25,
// ease: "easeInOut",
// }}
// >
// <Outlet />
// </motion.div>
// );
// };
const handleAuthError = async () => {
await delUser();
setInitialRoute("/login/index");
@@ -273,7 +244,7 @@ function AppReady() {
window.scrollTo(0, 0);
}, [location.key]);
useEffect(() => {
useLayoutEffect(() => {
async function checkForUpdates() {
try {
const { shouldUpdate, manifest } = await checkUpdate();
@@ -289,7 +260,7 @@ function AppReady() {
}
}
checkForUpdates();
});
}, []);
if (!initialRoute) {
return (
@@ -322,27 +293,42 @@ function AppReady() {
/>
)}
<Dialog
// open={true}
open={updateDialog}
// onClose={}
// maxWidth="md"
fullWidth
PaperProps={{
style: {
borderRadius: "14px",
background: "rgb(0 0 0 / 0.5)",
backdropFilter: "blur(10px)",
border: "1px solid rgb(255 255 255 / 0.2)",
},
}}
>
{updateInfo !== undefined && (
<>
<DialogTitle>
<DialogTitle
variant="h5"
style={{
display: "flex",
flexDirection: "column",
alignItems: "flex-start",
gap: "0.4em",
}}
>
Update Available!
<Typography
style={{
opacity: "0.5",
}}
>
v{updateInfo.version}
</Typography>
<Chip
icon={
<span className="material-symbols-rounded">update</span>
}
label={`v${updateInfo.version}`}
color="success"
/>
</DialogTitle>
<DialogContent dividers>
<DialogContentText>
<Markdown>{updateInfo.body}</Markdown>
<Markdown remarkPlugins={[remarkGfm]}>
{updateInfo.body}
</Markdown>
</DialogContentText>
</DialogContent>
<DialogActions
@@ -350,7 +336,11 @@ function AppReady() {
padding: "1em",
}}
>
<IconButton disabled={updateDialogButton}>
<IconButton
disabled={updateDialogButton}
target="_blank"
href={`https://github.com/prayag17/JellyPlayer/releases/${updateInfo.version}`}
>
<SvgIcon>
<svg
xmlns="http://www.w3.org/2000/svg"
+1 -1
View File
@@ -2,7 +2,7 @@
.carousel {
position: relative;
height: 70vh;
margin: 4.4em 1.6em 1.6em 1.6em;
margin: 0.6em 1.6em 1.6em 1.6em;
&-button {
position: absolute !important;
top: 50%;
+1 -1
View File
@@ -24,7 +24,7 @@ const Carousel = ({ content, onChange }) => {
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
useEffect(() => {
onChange(currentSlide);
}, [content[currentSlide].key]);
}, [content[currentSlide]?.key]);
return (
<div className="carousel">
+20
View File
@@ -113,3 +113,23 @@
$clr-background-light
);
}
@media (max-width: 1140px) {
.carousel{
height: 60vh !important;
}
.hero-carousel{
&-background-image{
width: 100%;
}
&-text {
-webkit-line-clamp: 2 !important;
&-logo {
max-width: 7em;
max-height: 2em;
object-fit: contain;
object-position: bottom;
}
}
}
}
+26 -27
View File
@@ -26,9 +26,10 @@ import { useBackdropStore } from "../../utils/store/backdrop";
import { BaseItemKind, ItemFields } from "@jellyfin/sdk/lib/generated-client";
import Typography from "@mui/material/Typography";
import { useSnackbar } from "notistack";
import { ErrorBoundary } from "react-error-boundary";
import CarouselSlide from "../../components/carouselSlide";
import ErrorBoundary from "../../components/errorBoundary";
import CarouselSlideError from "../../components/errors/carousel";
import { ErrorNotice } from "../../components/notices/errorNotice/errorNotice";
import { useApi } from "../../utils/store/api";
const Home = () => {
@@ -70,13 +71,13 @@ const Home = () => {
ItemFields.MediaStreams,
ItemFields.MediaSources,
],
// limit: 16,
enableUserData: true,
enableImages: true,
});
return media.data;
},
enabled: !!user.data,
networkMode: "always",
});
const resumeItemsVideo = useQuery({
@@ -92,7 +93,6 @@ const Home = () => {
return resumeItems.data;
},
enabled: !!user.data,
networkMode: "always",
});
const resumeItemsAudio = useQuery({
@@ -108,7 +108,6 @@ const Home = () => {
return resumeItems.data;
},
enabled: !!user.data,
networkMode: "always",
});
const upNextItems = useQuery({
@@ -129,7 +128,6 @@ const Home = () => {
return upNext.data;
},
enabled: !!user.data,
networkMode: "always",
});
const [latestMediaLibs, setLatestMediaLibs] = useState([]);
@@ -166,37 +164,38 @@ const Home = () => {
return (
<>
<main
className="scrollY home"
className="scrollY home padded-top"
style={{
flexGrow: 1,
// paddingBottom: "3em",
position: "relative",
}}
>
<ErrorBoundary fallback={<CarouselSlideError />}>
<ErrorBoundary FallbackComponent={ErrorNotice}>
{latestMedia.isPending ? (
<CarouselSkeleton />
) : (
<Carousel
content={latestMedia.data?.map((item) => (
<CarouselSlide item={item} key={item.Id} />
))}
onChange={(now) => {
if (latestMedia.isSuccess) {
if (latestMedia.data[now].ParentBackdropImageTags) {
setAppBackdrop(
`${api.basePath}/Items/${latestMedia.data[now].ParentBackdropItemId}/Images/Backdrop`,
latestMedia.data[now].Id,
);
} else {
setAppBackdrop(
`${api.basePath}/Items/${latestMedia.data[now].Id}/Images/Backdrop`,
latestMedia.data[now].Id,
);
latestMedia.data.length > 0 && (
<Carousel
content={latestMedia.data?.map((item) => (
<CarouselSlide item={item} key={item.Id} />
))}
onChange={(now) => {
if (latestMedia.isSuccess && latestMedia.data.length > 0) {
if (latestMedia.data[now]?.ParentBackdropImageTags) {
setAppBackdrop(
`${api.basePath}/Items/${latestMedia.data[now].ParentBackdropItemId}/Images/Backdrop`,
latestMedia.data[now].Id,
);
} else {
setAppBackdrop(
`${api.basePath}/Items/${latestMedia.data[now].Id}/Images/Backdrop`,
latestMedia.data[now].Id,
);
}
}
}
}}
/>
}}
/>
)
)}
</ErrorBoundary>