Start working on new appBar
This commit is contained in:
9 files changed
+329
-115
No files matched your search
+1
-1
@@ -456,7 +456,7 @@ function App() {
|
||||
}}
|
||||
>
|
||||
<CssBaseline />
|
||||
<SideMenu />
|
||||
{/* <SideMenu /> */}
|
||||
<AppBar />
|
||||
<AudioPlayer key={audioPlayerVisible} />
|
||||
<ErrorBoundary FallbackComponent={ErrorNotice}>
|
||||
|
||||
@@ -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}
|
||||
>
|
||||
<Toolbar
|
||||
sx={{
|
||||
justifyContent: "space-between",
|
||||
padding: "13px !important",
|
||||
display: "flex",
|
||||
gap: "1.2em",
|
||||
display: "grid",
|
||||
gap: "0.6em",
|
||||
gridTemplateColumns: "30% 1fr 30%",
|
||||
}}
|
||||
>
|
||||
<IconButton
|
||||
onClick={() => navigate(-1)}
|
||||
disabled={!backButtonVisible}
|
||||
<div
|
||||
className="flex flex-row flex-center"
|
||||
style={{
|
||||
gap: "1.2em",
|
||||
justifySelf: "start",
|
||||
}}
|
||||
>
|
||||
<div className="material-symbols-rounded">
|
||||
arrow_back
|
||||
</div>
|
||||
</IconButton>
|
||||
|
||||
<IconButton onClick={() => navigate("/search")}>
|
||||
<div className="material-symbols-rounded">
|
||||
search
|
||||
</div>
|
||||
</IconButton>
|
||||
<IconButton onClick={() => navigate("/favorite")}>
|
||||
<div className="material-symbols-rounded">
|
||||
favorite
|
||||
</div>
|
||||
</IconButton>
|
||||
<IconButton sx={{ p: 0 }} onClick={handleMenuOpen}>
|
||||
{user.isSuccess &&
|
||||
(user.data.PrimaryImageTag == undefined ? (
|
||||
<Avatar
|
||||
className="appBar-avatar"
|
||||
alt={user.data.Name}
|
||||
>
|
||||
<MdiAccount className="appBar-avatar-icon" />
|
||||
</Avatar>
|
||||
) : (
|
||||
<Avatar
|
||||
className="appBar-avatar"
|
||||
src={
|
||||
api.basePath +
|
||||
"/Users/" +
|
||||
user.data.Id +
|
||||
"/Images/Primary"
|
||||
}
|
||||
alt={user.data.Name}
|
||||
>
|
||||
<MdiAccount className="appBar-avatar-icon" />
|
||||
</Avatar>
|
||||
))}
|
||||
</IconButton>
|
||||
<Menu
|
||||
anchorEl={anchorEl}
|
||||
open={openMenu}
|
||||
onClose={handleMenuClose}
|
||||
sx={{ mt: 1 }}
|
||||
disableScrollLock
|
||||
>
|
||||
<MenuItem
|
||||
onClick={() => navigate("/settings")}
|
||||
disabled
|
||||
>
|
||||
<ListItemIcon>
|
||||
<div className="material-symbols-rounded">
|
||||
settings
|
||||
</div>
|
||||
</ListItemIcon>
|
||||
Settings
|
||||
</MenuItem>
|
||||
<MenuItem onClick={() => navigate("/about")}>
|
||||
<ListItemIcon>
|
||||
<div className="material-symbols-rounded">
|
||||
info
|
||||
</div>
|
||||
</ListItemIcon>
|
||||
About
|
||||
</MenuItem>
|
||||
<MenuItem onClick={handleLogout}>
|
||||
<ListItemIcon>
|
||||
<div className="material-symbols-rounded">
|
||||
logout
|
||||
</div>
|
||||
</ListItemIcon>
|
||||
Logout
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
onClick={async () => {
|
||||
navigate("/servers/list");
|
||||
<IconButton
|
||||
onClick={() => navigate(-1)}
|
||||
disabled={!backButtonVisible}
|
||||
style={{
|
||||
justifySelf: "left",
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<div className="material-symbols-rounded appBar-icon">
|
||||
dns
|
||||
</div>
|
||||
</ListItemIcon>
|
||||
Select Server
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
<div className="material-symbols-rounded">
|
||||
arrow_back
|
||||
</div>
|
||||
</IconButton>
|
||||
<img src={logo} className="appBar-logo" />
|
||||
</div>
|
||||
|
||||
<div
|
||||
className="flex flex-row flex-center"
|
||||
style={{
|
||||
gap: "2.6em",
|
||||
}}
|
||||
>
|
||||
<NavLink to="/home" className="appBar-text">
|
||||
<Typography variant="subtitle1">
|
||||
Home
|
||||
</Typography>
|
||||
</NavLink>
|
||||
<Typography
|
||||
ref={librariesText}
|
||||
variant="subtitle1"
|
||||
className={
|
||||
isBrowsingLibrary
|
||||
? "appBar-text active"
|
||||
: "appBar-text"
|
||||
}
|
||||
onMouseEnter={popoverEnter}
|
||||
// onMouseLeave={popoverLeave}
|
||||
>
|
||||
Libraries
|
||||
</Typography>
|
||||
<Menu
|
||||
open={Boolean(librariesPopover)}
|
||||
anchorEl={librariesPopover}
|
||||
// anchorOrigin={{
|
||||
// vertical: "bottom",
|
||||
// horizontal: "right",
|
||||
// }}
|
||||
// transformOrigin={{
|
||||
// vertical: "top",
|
||||
// horizontal: "left",
|
||||
// }}
|
||||
// slotProps={{
|
||||
// paper: {
|
||||
// onMouseEnter: popoverEnter,
|
||||
// onMouseLeave: popoverLeave,
|
||||
// },
|
||||
// }}
|
||||
anchorOrigin={{
|
||||
horizontal: "center",
|
||||
vertical: "bottom",
|
||||
}}
|
||||
transformOrigin={{
|
||||
horizontal: "center",
|
||||
vertical: "top",
|
||||
}}
|
||||
sx={{
|
||||
mt: 3,
|
||||
maxHeight: "72em",
|
||||
}}
|
||||
onClose={popoverLeave}
|
||||
MenuListProps={{
|
||||
onMouseLeave: popoverLeave,
|
||||
}}
|
||||
disableScrollLock
|
||||
>
|
||||
{libraries.isPending
|
||||
? "loading..."
|
||||
: libraries.data.Items.map(
|
||||
(library) => (
|
||||
<MenuItem
|
||||
key={library.Id}
|
||||
onClick={() =>
|
||||
navigate(
|
||||
`/library/${library.Id}`,
|
||||
)
|
||||
}
|
||||
>
|
||||
<ListItemIcon>
|
||||
{getTypeIcon(
|
||||
library.CollectionType,
|
||||
)}
|
||||
</ListItemIcon>
|
||||
{library.Name}
|
||||
</MenuItem>
|
||||
),
|
||||
)}
|
||||
</Menu>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className="flex flex-row"
|
||||
style={{ justifySelf: "right", gap: "0.6em" }}
|
||||
>
|
||||
<IconButton onClick={() => navigate("/search")}>
|
||||
<div className="material-symbols-rounded">
|
||||
search
|
||||
</div>
|
||||
</IconButton>
|
||||
<IconButton onClick={() => navigate("/favorite")}>
|
||||
<div className="material-symbols-rounded">
|
||||
favorite
|
||||
</div>
|
||||
</IconButton>
|
||||
<IconButton
|
||||
sx={{ p: 0 }}
|
||||
onClick={handleMenuOpen}
|
||||
>
|
||||
{user.isSuccess &&
|
||||
(user.data.PrimaryImageTag ==
|
||||
undefined ? (
|
||||
<Avatar
|
||||
className="appBar-avatar"
|
||||
alt={user.data.Name}
|
||||
>
|
||||
<MdiAccount className="appBar-avatar-icon" />
|
||||
</Avatar>
|
||||
) : (
|
||||
<Avatar
|
||||
className="appBar-avatar"
|
||||
src={
|
||||
api.basePath +
|
||||
"/Users/" +
|
||||
user.data.Id +
|
||||
"/Images/Primary"
|
||||
}
|
||||
alt={user.data.Name}
|
||||
>
|
||||
<MdiAccount className="appBar-avatar-icon" />
|
||||
</Avatar>
|
||||
))}
|
||||
</IconButton>
|
||||
<Menu
|
||||
anchorEl={anchorEl}
|
||||
open={openMenu}
|
||||
onClose={handleMenuClose}
|
||||
sx={{ mt: 2 }}
|
||||
disableScrollLock
|
||||
>
|
||||
<MenuItem
|
||||
onClick={() => navigate("/settings")}
|
||||
disabled
|
||||
>
|
||||
<ListItemIcon>
|
||||
<div className="material-symbols-rounded">
|
||||
settings
|
||||
</div>
|
||||
</ListItemIcon>
|
||||
Settings
|
||||
</MenuItem>
|
||||
<MenuItem onClick={() => navigate("/about")}>
|
||||
<ListItemIcon>
|
||||
<div className="material-symbols-rounded">
|
||||
info
|
||||
</div>
|
||||
</ListItemIcon>
|
||||
About
|
||||
</MenuItem>
|
||||
<MenuItem onClick={handleLogout}>
|
||||
<ListItemIcon>
|
||||
<div className="material-symbols-rounded">
|
||||
logout
|
||||
</div>
|
||||
</ListItemIcon>
|
||||
Logout
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
onClick={async () => {
|
||||
navigate("/servers/list");
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<div className="material-symbols-rounded appBar-icon">
|
||||
dns
|
||||
</div>
|
||||
</ListItemIcon>
|
||||
Select Server
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
</div>
|
||||
</Toolbar>
|
||||
</MuiAppBar>
|
||||
);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -369,7 +369,7 @@ const LibraryView = () => {
|
||||
);
|
||||
} else if (currentLib.isSuccess) {
|
||||
return (
|
||||
<main className="scrollY library">
|
||||
<main className="scrollY library padded-top">
|
||||
<div
|
||||
style={{
|
||||
padding: "1em 1em 1em 0.6em",
|
||||
@@ -378,7 +378,7 @@ const LibraryView = () => {
|
||||
zIndex: 10,
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
justifyContent: "flex-start",
|
||||
}}
|
||||
>
|
||||
<div
|
||||
@@ -386,6 +386,7 @@ const LibraryView = () => {
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
width: "fit-content",
|
||||
padding: "0 1em",
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
|
||||
@@ -36,7 +36,8 @@
|
||||
}
|
||||
|
||||
.library {
|
||||
padding: 0 !important;
|
||||
padding-left: 0 !important;
|
||||
padding-right: 0 !important;
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -48,12 +49,10 @@
|
||||
align-items: start;
|
||||
}
|
||||
&-items {
|
||||
height: calc(100vh - 4em);
|
||||
height: calc(100vh - 8.4em);
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
padding-bottom: 1em;
|
||||
padding-right: 1em;
|
||||
padding-top: 4.5em;
|
||||
padding: 1.5em 1em;
|
||||
&-header {
|
||||
position: absolute;
|
||||
top: 4.4em;
|
||||
|
||||
+15
-2
@@ -122,8 +122,10 @@ h1 {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
min-height: 100vh;
|
||||
padding-left: 1em;
|
||||
padding-right: calc(1em + 14px);
|
||||
padding: 0 1.2em;
|
||||
&.padded-top {
|
||||
padding-top: 4.4em;
|
||||
}
|
||||
}
|
||||
|
||||
.home {
|
||||
@@ -199,3 +201,14 @@ h1 {
|
||||
transform: translate(-50%, -50%) scale(4);
|
||||
}
|
||||
}
|
||||
|
||||
.flex {
|
||||
display: flex;
|
||||
&-row {
|
||||
flex-direction: row;
|
||||
}
|
||||
&-center {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
@@ -49,5 +49,21 @@ export const theme = createTheme({
|
||||
},
|
||||
},
|
||||
},
|
||||
MuiPaper: {
|
||||
styleOverrides: {
|
||||
root: {},
|
||||
},
|
||||
},
|
||||
MuiMenu: {
|
||||
styleOverrides: {
|
||||
paper: {
|
||||
borderRadius: "10px",
|
||||
// boxShadow: "0 0 5px hsl(273, 100%, 36%)",
|
||||
background: "hsl(256, 100%, 2%, 40%)",
|
||||
backdropFilter: "blur(20px)",
|
||||
// border: "1.8px solid hsl(273, 100%, 36%)",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user