From 66f63c6d759ef7c5509fb937265ca54b8931b97a Mon Sep 17 00:00:00 2001 From: Prayag Prajapati Date: Thu, 28 Dec 2023 17:18:15 +0530 Subject: [PATCH] Start working on new appBar --- src/App.jsx | 2 +- src/components/appBar/appBar.jsx | 331 +++++++++++++------ src/components/appBar/appBar.module.scss | 46 ++- src/components/cardScroller/cardScroller.jsx | 16 +- src/components/menu/sidemenu.jsx | 2 +- src/routes/library/index.jsx | 5 +- src/routes/library/library.module.scss | 9 +- src/styles/global.scss | 17 +- src/theme.js | 16 + 9 files changed, 329 insertions(+), 115 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 7179277..05829e6 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -456,7 +456,7 @@ function App() { }} > - + {/* */} diff --git a/src/components/appBar/appBar.jsx b/src/components/appBar/appBar.jsx index c3b4c94..e206de6 100644 --- a/src/components/appBar/appBar.jsx +++ b/src/components/appBar/appBar.jsx @@ -1,5 +1,5 @@ /** @format */ -import React, { useEffect, useState } from "react"; +import React, { useEffect, useRef, useState } from "react"; import { relaunch } from "@tauri-apps/api/process"; @@ -11,12 +11,16 @@ import ListItemIcon from "@mui/material/ListItemIcon"; import Menu from "@mui/material/Menu"; import MenuItem from "@mui/material/MenuItem"; import useScrollTrigger from "@mui/material/useScrollTrigger"; +import Typography from "@mui/material/Typography"; +import Popper from "@mui/material/Popper"; import { red } from "@mui/material/colors"; -import { useLocation, useNavigate } from "react-router-dom"; +import { useLocation, useNavigate, NavLink } from "react-router-dom"; import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api"; +import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api"; + import { useQuery, useQueryClient } from "@tanstack/react-query"; import "./appBar.module.scss"; @@ -35,6 +39,10 @@ import { MdiLogoutVariant } from "../icons/mdiLogoutVariant"; import { EventEmitter as event } from "../../eventEmitter"; import { useApi } from "../../utils/store/api"; +import { getTypeIcon } from "../../components/utils/iconsCollection"; + +import logo from "../../assets/logo.svg"; + export const AppBar = () => { const [api] = useApi((state) => [state.api]); const navigate = useNavigate(); @@ -53,6 +61,17 @@ export const AppBar = () => { enabled: display, networkMode: "always", }); + let libraries = useQuery({ + queryKey: ["libraries"], + queryFn: async () => { + let libs = await getUserViewsApi(api).getUserViews({ + userId: user.data.Id, + }); + return libs.data; + }, + enabled: !!user.data, + networkMode: "always", + }); useEffect(() => { if (user.isError) { console.error(user.error); @@ -91,6 +110,20 @@ export const AppBar = () => { navigate("/login/index"); }; + const [librariesPopover, setLibrariesPopover] = useState(false); + const librariesText = useRef(null); + const popoverEnter = (event) => { + if (anchorEl !== event.currentTarget) { + setLibrariesPopover(event.currentTarget); + } + }; + + const popoverLeave = () => { + setLibrariesPopover(null); + }; + + const [isBrowsingLibrary, setIsBrowsingLibrary] = useState(false); + useEffect(() => { if ( location.pathname.includes("login") || @@ -104,14 +137,18 @@ export const AppBar = () => { } else { setDisplay(true); } - }, [location]); - useEffect(() => { if (location.pathname == "/home") { setBackButtonVisible(false); } else { setBackButtonVisible(true); } + + if (location.pathname.includes("library")) { + setIsBrowsingLibrary(true); + } else { + setIsBrowsingLibrary(false); + } }, [location]); if (!display) { @@ -123,109 +160,211 @@ export const AppBar = () => { style={{ backgroundColor: "transparent", paddingRight: "0 !important", - width: "fit-content", }} className={trigger ? "appBar backdropVisible" : "appBar"} elevation={0} > - navigate(-1)} - disabled={!backButtonVisible} +
-
- arrow_back -
- - - navigate("/search")}> -
- search -
-
- navigate("/favorite")}> -
- favorite -
-
- - {user.isSuccess && - (user.data.PrimaryImageTag == undefined ? ( - - - - ) : ( - - - - ))} - - - navigate("/settings")} - disabled - > - -
- settings -
-
- Settings -
- navigate("/about")}> - -
- info -
-
- About -
- - -
- logout -
-
- Logout -
- { - navigate("/servers/list"); + navigate(-1)} + disabled={!backButtonVisible} + style={{ + justifySelf: "left", }} > - -
- dns -
-
- Select Server -
-
+
+ arrow_back +
+ + +
+ +
+ + + Home + + + + Libraries + + + {libraries.isPending + ? "loading..." + : libraries.data.Items.map( + (library) => ( + + navigate( + `/library/${library.Id}`, + ) + } + > + + {getTypeIcon( + library.CollectionType, + )} + + {library.Name} + + ), + )} + +
+ +
+ navigate("/search")}> +
+ search +
+
+ navigate("/favorite")}> +
+ favorite +
+
+ + {user.isSuccess && + (user.data.PrimaryImageTag == + undefined ? ( + + + + ) : ( + + + + ))} + + + navigate("/settings")} + disabled + > + +
+ settings +
+
+ Settings +
+ navigate("/about")}> + +
+ info +
+
+ About +
+ + +
+ logout +
+
+ Logout +
+ { + navigate("/servers/list"); + }} + > + +
+ dns +
+
+ Select Server +
+
+
); diff --git a/src/components/appBar/appBar.module.scss b/src/components/appBar/appBar.module.scss index eccac5b..f6e166d 100644 --- a/src/components/appBar/appBar.module.scss +++ b/src/components/appBar/appBar.module.scss @@ -1,9 +1,6 @@ /** @format */ .appBar { - top: 8px !important; - right: 8px !important; - border-radius: 10000px; transition: background-color $transition-time-fast, backdrop-filter $transition-time-fast, box-shadow $transition-time-default !important; @@ -20,6 +17,49 @@ &-logo { height: 1.8em !important; } + &-text { + cursor: default; + opacity: 0.7; + transition: opacity $transition-time-fast; + position: relative; + color: white; + text-decoration: none; + &::after { + content: ""; + width: 100%; + height: 1.2px; + background: white; + opacity: 0.7; + position: absolute; + bottom: -2.6px; + left: 0; + transform: scaleX(0); + transition: transform $transition-time-fast, + background $transition-time-fast, + opacity $transition-time-fast; + } + &:hover { + opacity: 0.8; + &::after { + transform: scaleX(0.5); + opacity: 0.8; + } + } + &.active { + opacity: 1; + color: $clr-accent-default; + &::after { + transform: scaleX(0.75); + opacity: 1; + background: $clr-accent-default; + } + } + } + &-logo { + width: 20em; + object-fit: contain; + object-position: center; + } } .appLoading { diff --git a/src/components/cardScroller/cardScroller.jsx b/src/components/cardScroller/cardScroller.jsx index 83920cd..9ef5b3f 100644 --- a/src/components/cardScroller/cardScroller.jsx +++ b/src/components/cardScroller/cardScroller.jsx @@ -32,23 +32,29 @@ export const CardScroller = ({ partialVisibilityGutter: 40, }, desktop: { - breakpoint: { max: 3000, min: 625 }, + breakpoint: { max: 3000, min: 925 }, items: displayCards, slidesToSlide: displayCards, // optional, default to 1. partialVisibilityGutter: 30, }, tablet: { - breakpoint: { max: 624, min: 464 }, - items: displayCards - 2, - slidesToSlide: displayCards - 2, // optional, default to 1. + breakpoint: { max: 925, min: 600 }, + items: displayCards - 3, + slidesToSlide: displayCards - 3, // optional, default to 1. partialVisibilityGutter: 20, }, mobile: { - breakpoint: { max: 464, min: 0 }, + breakpoint: { max: 600, min: 424 }, items: displayCards - 5, slidesToSlide: displayCards - 5, // optional, default to 1. partialVisibilityGutter: 10, }, + smallScreen: { + breakpoint: { max: 424, min: 0 }, + items: 1, + slidesToSlide: 1, // optional, default to 1. + partialVisibilityGutter: 10, + }, }; const [carouselRef, setCarouselRef] = useState(); diff --git a/src/components/menu/sidemenu.jsx b/src/components/menu/sidemenu.jsx index 2661bd3..049492a 100644 --- a/src/components/menu/sidemenu.jsx +++ b/src/components/menu/sidemenu.jsx @@ -17,7 +17,7 @@ import { getTypeIcon } from "../../components/utils/iconsCollection.jsx"; import "./sidemenu.module.scss"; import { useApi } from "../../utils/store/api"; -import Icon from "../../assets/icon.png"; +import Icon from "../../assets/icon.svg"; const DrawerHeader = styled("div")(({ theme }) => ({ display: "flex", diff --git a/src/routes/library/index.jsx b/src/routes/library/index.jsx index 8312caf..76fbedc 100644 --- a/src/routes/library/index.jsx +++ b/src/routes/library/index.jsx @@ -369,7 +369,7 @@ const LibraryView = () => { ); } else if (currentLib.isSuccess) { return ( -
+
{ zIndex: 10, display: "flex", alignItems: "center", - justifyContent: "center", + justifyContent: "flex-start", }} >
{ display: "flex", alignItems: "center", width: "fit-content", + padding: "0 1em", }} >