Add error slide for carousel

This commit is contained in:
Prayag Prajapati committed 2023-07-25 15:47:18 +05:30
1 parent d5daa6d9dc
commit 0bcb7a6cff
9 files changed
+367 -266

No files matched your search

+42 -6
View File
@@ -4,9 +4,7 @@ import React, { useState, useEffect } from "react";
import { appWindow } from "@tauri-apps/api/window";
import Konami from "react-konami-code";
// @ts-ignore
const Kon = Konami.default ? Konami.default : Konami;
import useKonami from "react-use-konami";
import { ThemeProvider } from "@mui/material/styles";
import { SnackbarProvider, useSnackbar } from "notistack";
@@ -39,7 +37,8 @@ import DialogContent from "@mui/material/DialogContent";
import DialogContentText from "@mui/material/DialogContentText";
import DialogTitle from "@mui/material/DialogTitle";
import Button from "@mui/material/Button";
import Box from "@mui/material/Box";
import Slide from "@mui/material/Slide";
// import Slide from "@mui/material/Slide";
import CircularProgress from "@mui/material/CircularProgress";
// Routes
@@ -278,23 +277,60 @@ function App() {
appWindow.setFullscreen(false);
}, [location]);
useKonami(sixtyNine, {
code: [
"ArrowUp",
"ArrowUp",
"ArrowDown",
"ArrowDown",
"ArrowLeft",
"ArrowRight",
"ArrowLeft",
"ArrowRight",
"b",
"a",
],
});
return (
<SnackbarProvider maxSnack={5}>
<ThemeProvider theme={theme}>
<Kon resetDelay={1000} action={sixtyNine}></Kon>
<Dialog
open={easterEgg}
onClose={() => setEasterEgg(false)}
sx={{
background: "black",
}}
>
<iframe
width="560"
height="315"
src="https://www.youtube.com/embed/dQw4w9WgXcQ?controls=0&autoplay=1"
src="https://www.youtube.com/embed/dQw4w9WgXcQ?autoplay=1&disablekb=1"
title="EasterEgg"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
></iframe>
</Dialog>
<Slide
direction="up"
in={easterEgg}
mountOnEnter
unmountOnExit
>
<img
src="https://i.gifer.com/PYh.gif"
width={320}
height={320}
style={{
zIndex: "99999999",
position: "fixed",
bottom: 0,
left: 0,
objectFit: "cover",
}}
/>
</Slide>
{/* Show Dialog if server not reachable */}
<Dialog
open={!serverReachable}
Binary file not shown.

After

Width:  |  Height:  |  Size: 834 KiB

+48
View File
@@ -0,0 +1,48 @@
/** @format */
import Paper from "@mui/material/Paper";
import Stack from "@mui/material/Stack";
import Typography from "@mui/material/Typography";
import { MdiEmoticonDead } from "../icons/mdiEmoticonDead";
import Divider from "@mui/material/Divider";
import { red } from "@mui/material/colors";
import slideBackground from "../../assets/errorbg.png";
const CarouselSlideError = ({ itemName }) => {
return (
<Paper className="hero-carousel-slide">
<Stack
justifyContent="center"
alignItems="center"
sx={{
width: "100%",
height: "100%",
background: `url(${slideBackground})`,
backgroundSize: "cover",
}}
>
<MdiEmoticonDead
sx={{ fontSize: "10em", opacity: "0.8" }}
/>
<Typography mb={2} variant="h4" sx={{ opacity: "0.5" }}>
Error caused by
</Typography>
<Typography
mt={2}
variant="h3"
sx={{
background: "rgb(255 255 255 /0.1)",
padding: 1,
borderRadius: 3,
}}
>
{itemName}
</Typography>
</Stack>
</Paper>
);
};
export default CarouselSlideError;
+1
View File
@@ -32,5 +32,6 @@ ReactDOM.createRoot(document.getElementById("root")).render(
document.addEventListener("DOMContentLoaded", () => {
// This will wait for the window to load, but you could
// run this function on whatever trigger you want
console.info("Initial render complete");
invoke("close_splashscreen");
});
+9 -8
View File
@@ -50,6 +50,7 @@ import { endsAt, getRuntime } from "../../utils/date/time";
import { BaseItemKind, ItemFields } from "@jellyfin/sdk/lib/generated-client";
import { ErrorBoundary } from "react-error-boundary";
import CarouselSlideError from "../../components/errors/carousel";
const Home = () => {
const authUser = useQuery({
@@ -253,12 +254,9 @@ const Home = () => {
return (
<ErrorBoundary
fallback={
<div>
Something went wrong in
carousel slide for
{" --- "}
{item.Name}
</div>
<CarouselSlideError
itemName={item.Name}
/>
}
>
<Paper
@@ -320,8 +318,11 @@ const Home = () => {
item
.ImageBlurHashes
.Backdrop[
item
.BackdropImageTags[2]
Object.keys(
item
.ImageBlurHashes
.Backdrop,
)[0]
]
}
// hash="LEHV6nWB2yk8pyo0adR*.7kCMdnj"