Start adding NavBar #25
This commit is contained in:
10 files changed
+150
-5
No files matched your search
@@ -57,6 +57,7 @@ import { version as appVer } from "../package.json";
|
|||||||
import { v4 as uuidv4 } from "uuid";
|
import { v4 as uuidv4 } from "uuid";
|
||||||
import { delServer, getServer } from "./utils/storage/servers.js";
|
import { delServer, getServer } from "./utils/storage/servers.js";
|
||||||
import { getUser } from "./utils/storage/user.js";
|
import { getUser } from "./utils/storage/user.js";
|
||||||
|
import { AppBar } from "./components/appBar/appBar.jsx";
|
||||||
|
|
||||||
const jellyfin = new Jellyfin({
|
const jellyfin = new Jellyfin({
|
||||||
clientInfo: {
|
clientInfo: {
|
||||||
@@ -306,6 +307,7 @@ function App() {
|
|||||||
<div style={{ display: "flex" }}>
|
<div style={{ display: "flex" }}>
|
||||||
<CssBaseline />
|
<CssBaseline />
|
||||||
<SideMenu />
|
<SideMenu />
|
||||||
|
<AppBar />
|
||||||
<Suspense
|
<Suspense
|
||||||
fallback={
|
fallback={
|
||||||
<Box
|
<Box
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/** @format */
|
||||||
|
|
||||||
|
import MuiAppBar from "@mui/material/AppBar";
|
||||||
|
import TextField from "@mui/material/TextField";
|
||||||
|
import IconButton from "@mui/material/IconButton";
|
||||||
|
import InputAdornment from "@mui/material/InputAdornment";
|
||||||
|
import Toolbar from "@mui/material/Toolbar";
|
||||||
|
import { MdiMagnify } from "../icons/mdiMagnify";
|
||||||
|
import { theme } from "../../theme";
|
||||||
|
|
||||||
|
import { useSelector } from "react-redux";
|
||||||
|
|
||||||
|
import "./appBar.module.scss";
|
||||||
|
|
||||||
|
export const AppBar = () => {
|
||||||
|
const visible = useSelector((state) => state.appBar.visible);
|
||||||
|
const backdropVisible = useSelector((state) => state.appBar.backdrop);
|
||||||
|
|
||||||
|
// console.log(backdropVisible);
|
||||||
|
|
||||||
|
// const trigger = useScrollTrigger({
|
||||||
|
// disableHysteresis: true,
|
||||||
|
// threshold: 0,
|
||||||
|
// // target: document.querySelector(".scrollY"),
|
||||||
|
// });
|
||||||
|
|
||||||
|
// console.log(trigger);
|
||||||
|
|
||||||
|
return (
|
||||||
|
visible && (
|
||||||
|
<MuiAppBar
|
||||||
|
sx={{
|
||||||
|
width: `calc(100vw - ${theme.spacing(7)} - 10px)`,
|
||||||
|
background: backdropVisible
|
||||||
|
? theme.palette.background.paper
|
||||||
|
: "transparent",
|
||||||
|
}}
|
||||||
|
className="appBar"
|
||||||
|
elevation={backdropVisible ? 6 : 0}
|
||||||
|
>
|
||||||
|
<Toolbar>
|
||||||
|
<TextField
|
||||||
|
variant="outlined"
|
||||||
|
label="search"
|
||||||
|
InputProps={{
|
||||||
|
endAdornment: (
|
||||||
|
<InputAdornment position="end">
|
||||||
|
<IconButton size="small">
|
||||||
|
<MdiMagnify />
|
||||||
|
</IconButton>
|
||||||
|
</InputAdornment>
|
||||||
|
),
|
||||||
|
}}
|
||||||
|
size="small"
|
||||||
|
/>
|
||||||
|
</Toolbar>
|
||||||
|
</MuiAppBar>
|
||||||
|
)
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
/** @format */
|
||||||
|
|
||||||
|
.appBar {
|
||||||
|
transition: background $transition-time-default;
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
/** @format */
|
||||||
|
import SvgIcon from "@mui/material/SvgIcon";
|
||||||
|
|
||||||
|
import { mdiMagnify } from "@mdi/js";
|
||||||
|
|
||||||
|
export const MdiMagnify = (props) => {
|
||||||
|
return (
|
||||||
|
<SvgIcon {...props}>
|
||||||
|
<path d={mdiMagnify}></path>
|
||||||
|
</SvgIcon>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -57,6 +57,7 @@ const MiniDrawer = styled(MuiDrawer, {
|
|||||||
|
|
||||||
export const SideMenu = ({}) => {
|
export const SideMenu = ({}) => {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
const visible = useSelector((state) => state.sidebar.visible);
|
const visible = useSelector((state) => state.sidebar.visible);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const user = useQuery({
|
const user = useQuery({
|
||||||
|
|||||||
@@ -106,3 +106,11 @@
|
|||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.backdropContainer {
|
||||||
|
background: linear-gradient(
|
||||||
|
45deg,
|
||||||
|
$clr-background-default,
|
||||||
|
$clr-background-light
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/** @format */
|
/** @format */
|
||||||
|
|
||||||
import { useState, useEffect, useLayoutEffect } from "react";
|
import { useState, useEffect, useRef } from "react";
|
||||||
|
|
||||||
import { Blurhash } from "react-blurhash";
|
import { Blurhash } from "react-blurhash";
|
||||||
|
|
||||||
@@ -20,6 +20,7 @@ import Paper from "@mui/material/Paper";
|
|||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import Chip from "@mui/material/Chip";
|
import Chip from "@mui/material/Chip";
|
||||||
import Divider from "@mui/material/Divider";
|
import Divider from "@mui/material/Divider";
|
||||||
|
import useScrollTrigger from "@mui/material/useScrollTrigger";
|
||||||
|
|
||||||
import { yellow } from "@mui/material/colors";
|
import { yellow } from "@mui/material/colors";
|
||||||
|
|
||||||
@@ -40,6 +41,7 @@ import { MdiChevronRight } from "../../components/icons/mdiChevronRight";
|
|||||||
|
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { showSidemenu } from "../../utils/slice/sidemenu";
|
import { showSidemenu } from "../../utils/slice/sidemenu";
|
||||||
|
import { showAppBar, setBackdrop } from "../../utils/slice/appBar";
|
||||||
|
|
||||||
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||||
@@ -84,10 +86,10 @@ const Home = () => {
|
|||||||
const libraries = useQuery({
|
const libraries = useQuery({
|
||||||
queryKey: ["home", "libraries"],
|
queryKey: ["home", "libraries"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
dispatch(showSidemenu());
|
||||||
let libs = await getUserViewsApi(window.api).getUserViews({
|
let libs = await getUserViewsApi(window.api).getUserViews({
|
||||||
userId: user.data.Id,
|
userId: user.data.Id,
|
||||||
});
|
});
|
||||||
dispatch(showSidemenu());
|
|
||||||
return libs.data;
|
return libs.data;
|
||||||
},
|
},
|
||||||
enabled: !!user.data,
|
enabled: !!user.data,
|
||||||
@@ -187,6 +189,24 @@ const Home = () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const appBarVisiblity = useSelector((state) => state.appBar.visible);
|
||||||
|
|
||||||
|
if (!appBarVisiblity) {
|
||||||
|
dispatch(showAppBar());
|
||||||
|
}
|
||||||
|
|
||||||
|
const [scrollTarget, setScrollTarget] = useState(undefined);
|
||||||
|
|
||||||
|
const trigger = useScrollTrigger({
|
||||||
|
disableHysteresis: true,
|
||||||
|
threshold: 0,
|
||||||
|
target: scrollTarget,
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
dispatch(setBackdrop(trigger));
|
||||||
|
}, [trigger]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Box
|
<Box
|
||||||
@@ -197,7 +217,18 @@ const Home = () => {
|
|||||||
<Box
|
<Box
|
||||||
component="main"
|
component="main"
|
||||||
className="scrollY"
|
className="scrollY"
|
||||||
sx={{ flexGrow: 1, p: 3 }}
|
sx={{
|
||||||
|
flexGrow: 1,
|
||||||
|
pt: 11,
|
||||||
|
px: 3,
|
||||||
|
pb: 3,
|
||||||
|
position: "relative",
|
||||||
|
}}
|
||||||
|
ref={(node) => {
|
||||||
|
if (node) {
|
||||||
|
setScrollTarget(node);
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Carousel
|
<Carousel
|
||||||
className="hero-carousel"
|
className="hero-carousel"
|
||||||
@@ -648,6 +679,7 @@ const Home = () => {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
||||||
<Button variant="contained" onClick={handleLogout}>
|
<Button variant="contained" onClick={handleLogout}>
|
||||||
Logout
|
Logout
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
+2
-1
@@ -2,9 +2,10 @@
|
|||||||
|
|
||||||
import { configureStore } from "@reduxjs/toolkit";
|
import { configureStore } from "@reduxjs/toolkit";
|
||||||
import sideBarReducer from "./utils/slice/sidemenu";
|
import sideBarReducer from "./utils/slice/sidemenu";
|
||||||
|
import appBarReducer from "./utils/slice/appBar";
|
||||||
export default configureStore({
|
export default configureStore({
|
||||||
reducer: {
|
reducer: {
|
||||||
sidebar: sideBarReducer,
|
sidebar: sideBarReducer,
|
||||||
|
appBar: appBarReducer,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
/** @format */
|
||||||
|
|
||||||
|
import { createSlice } from "@reduxjs/toolkit";
|
||||||
|
export const appBarSlice = createSlice({
|
||||||
|
name: "appBar",
|
||||||
|
initialState: {
|
||||||
|
visible: false,
|
||||||
|
backdrop: false,
|
||||||
|
},
|
||||||
|
reducers: {
|
||||||
|
showAppBar: (state) => {
|
||||||
|
state.visible = true;
|
||||||
|
},
|
||||||
|
hideAppBar: (state) => {
|
||||||
|
state.visible = false;
|
||||||
|
},
|
||||||
|
setBackdrop: (state, action) => {
|
||||||
|
state.backdrop = action.payload;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const { showAppBar, hideAppBar, setBackdrop } = appBarSlice.actions;
|
||||||
|
export default appBarSlice.reducer;
|
||||||
@@ -11,7 +11,7 @@ export const sideBarSlice = createSlice({
|
|||||||
state.visible = true;
|
state.visible = true;
|
||||||
},
|
},
|
||||||
hideSidemenu: (state) => {
|
hideSidemenu: (state) => {
|
||||||
state.visible - false;
|
state.visible = false;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user