From 73085f736f2e611c03b16afbd149739a80a8fd67 Mon Sep 17 00:00:00 2001 From: Prayag Prajapati Date: Mon, 14 Aug 2023 18:58:59 +0530 Subject: [PATCH] Add app backdrop --- src/App.jsx | 32 ++++++++++++++++++++++++++++---- src/App.module.scss | 1 - src/routes/home/index.jsx | 10 ++++++++++ src/styles/global.scss | 18 ++++++++++++++++++ src/utils/store/backdrop.js | 10 ++++++++++ 5 files changed, 66 insertions(+), 5 deletions(-) delete mode 100644 src/App.module.scss create mode 100644 src/utils/store/backdrop.js diff --git a/src/App.jsx b/src/App.jsx index 20ac99e..e7b7f10 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -2,8 +2,6 @@ import React, { useState, useEffect } from "react"; -import { appWindow } from "@tauri-apps/api/window"; - import useKonami from "react-use-konami"; import { ThemeProvider } from "@mui/material/styles"; @@ -38,8 +36,7 @@ import DialogContentText from "@mui/material/DialogContentText"; import DialogTitle from "@mui/material/DialogTitle"; import Button from "@mui/material/Button"; import Slide from "@mui/material/Slide"; -// import Slide from "@mui/material/Slide"; -import CircularProgress from "@mui/material/CircularProgress"; +import Box from "@mui/material/Box"; // Routes import { ServerSetup, ServerList } from "./routes/setup/server"; @@ -71,6 +68,7 @@ import { delServer, getServer } from "./utils/storage/servers.js"; import { delUser, getUser } from "./utils/storage/user.js"; import axios from "axios"; +import { useBackdropStore } from "./utils/store/backdrop.js"; const jellyfin = new Jellyfin({ clientInfo: { @@ -268,6 +266,12 @@ function App() { } }); } + + const [backdropUrl, backdropId] = useBackdropStore((state) => [ + state.backdropUrl, + state.backdropId, + ]); + const [easterEgg, setEasterEgg] = useState(false); const sixtyNine = () => { setEasterEgg(true); @@ -362,6 +366,26 @@ function App() { width: "calc(100vw - 14px)", }} > + + + diff --git a/src/App.module.scss b/src/App.module.scss deleted file mode 100644 index 1a1f0eb..0000000 --- a/src/App.module.scss +++ /dev/null @@ -1 +0,0 @@ -/** @format */ diff --git a/src/routes/home/index.jsx b/src/routes/home/index.jsx index e250a06..f9a32dd 100644 --- a/src/routes/home/index.jsx +++ b/src/routes/home/index.jsx @@ -53,6 +53,7 @@ import { ErrorBoundary } from "react-error-boundary"; import CarouselSlideError from "../../components/errors/carousel"; import { motion } from "framer-motion"; +import { useBackdropStore } from "../../utils/store/backdrop"; const Home = () => { const authUser = useQuery({ queryKey: ["home", "authenticateUser"], @@ -196,6 +197,8 @@ const Home = () => { }); } + const [setAppBackdrop] = useBackdropStore((state) => [state.setBackdrop]); + if (user.isPaused) { user.refetch(); console.log(user.isError); @@ -245,6 +248,13 @@ const Home = () => { sx={{ marginBottom: "1.5em", }} + onChange={(now) => { + console.log(latestMedia.data[now]); + setAppBackdrop( + `${window.api.basePath}/Items/${latestMedia.data[now].Id}/Images/Backdrop`, + latestMedia.data[now].Id, + ); + }} duration={400} interval={10000} > diff --git a/src/styles/global.scss b/src/styles/global.scss index 9ad0706..a02cfbc 100644 --- a/src/styles/global.scss +++ b/src/styles/global.scss @@ -41,6 +41,24 @@ body { overflow-y: overlay; } +.app-backdrop { + object-fit: cover; + width: 100%; + height: 100%; + position: absolute; + top: 0; + left: 0; + filter: blur(50px); + + &-container { + position: fixed; + width: 100vw; + height: 100vh; + left: 0; + top: 0; + } +} + #root, .root-page { height: fit-content; diff --git a/src/utils/store/backdrop.js b/src/utils/store/backdrop.js new file mode 100644 index 0000000..18d33f7 --- /dev/null +++ b/src/utils/store/backdrop.js @@ -0,0 +1,10 @@ +/** @format */ + +import { create } from "zustand"; + +export const useBackdropStore = create((set) => ({ + backdropUrl: "", + backdropId: "", + setBackdrop: (url, id) => + set((state) => ({ backdropUrl: url, backdropId: id })), +}));