Update Appbar

This commit is contained in:
Prayag Prajapati committed 2024-01-04 12:40:33 +05:30
1 parent 73ac8a529e
commit 87f9eaf8b6
5 files changed
+253 -77

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

+1 -2
View File
@@ -474,8 +474,7 @@ function App() {
element={ element={
<Navigate to={initialRoute} /> <Navigate to={initialRoute} />
} }
// element={<></>} ></Route>
/>
<Route <Route
path="/error" path="/error"
element={ element={
+182 -66
View File
@@ -12,7 +12,10 @@ import Menu from "@mui/material/Menu";
import MenuItem from "@mui/material/MenuItem"; import MenuItem from "@mui/material/MenuItem";
import useScrollTrigger from "@mui/material/useScrollTrigger"; import useScrollTrigger from "@mui/material/useScrollTrigger";
import Typography from "@mui/material/Typography"; import Typography from "@mui/material/Typography";
import Button from "@mui/material/Button";
import Popper from "@mui/material/Popper"; import Popper from "@mui/material/Popper";
import Paper from "@mui/material/Paper";
import Grow from "@mui/material/Grow";
import { red } from "@mui/material/colors"; import { red } from "@mui/material/colors";
@@ -43,6 +46,23 @@ import { getTypeIcon } from "../../components/utils/iconsCollection";
import logo from "../../assets/icon.svg"; import logo from "../../assets/icon.svg";
const forwardRefNavLink = React.forwardRef({
displayName: "NavLink",
render: (props, ref) => (
<NavLink
ref={ref}
to={props.to}
className={({ isActive }) =>
`${props.className} ${
isActive ? props.activeClassName : ""
}`
}
>
{props.children}
</NavLink>
),
});
export const AppBar = () => { export const AppBar = () => {
const [api] = useApi((state) => [state.api]); const [api] = useApi((state) => [state.api]);
const navigate = useNavigate(); const navigate = useNavigate();
@@ -110,16 +130,15 @@ export const AppBar = () => {
navigate("/login/index"); navigate("/login/index");
}; };
const [librariesPopover, setLibrariesPopover] = useState(false); const [librariesPopper, setLibrariesPopper] = useState(false);
const librariesText = useRef(null); const librariesText = useRef(null);
const popoverEnter = (event) => {
if (anchorEl !== event.currentTarget) {
setLibrariesPopover(event.currentTarget);
}
};
const popoverLeave = () => { const handlePopper = (event) => {
setLibrariesPopover(null); if (librariesPopper) {
setLibrariesPopper(null);
} else {
setLibrariesPopper(event.currentTarget);
}
}; };
const [isBrowsingLibrary, setIsBrowsingLibrary] = useState(false); const [isBrowsingLibrary, setIsBrowsingLibrary] = useState(false);
@@ -190,16 +209,70 @@ export const AppBar = () => {
gap: "2.6em", gap: "2.6em",
}} }}
> >
<NavLink to="/home" className="appBar-text"> <NavLink to="/home">
{({ isActive }) =>
isActive ? (
<Button
style={{
textTransform: "none",
}}
size="large"
>
<Typography
className="appBar-text active"
variant="subtitle1"
fontWeight={600}
>
Home
</Typography>
</Button>
) : (
<Button
style={{
textTransform: "none",
}}
// className="appBar-text "
color="white"
>
<Typography
className="appBar-text "
variant="subtitle1"
fontWeight={600}
>
Home
</Typography>
</Button>
)
}
</NavLink>
<Button
variant="text"
// disableRipple
disableElevation
onClick={handlePopper}
style={{ textTransform: "none" }}
size="large"
disableFocusRipple={false}
color={
isBrowsingLibrary ? "primary" : "white"
}
// ref={librariesText}
>
<Typography <Typography
variant="subtitle1" variant="subtitle1"
fontWeight={600} fontWeight={600}
className={
isBrowsingLibrary
? "appBar-text active"
: "appBar-text"
}
> >
Home Libraries
</Typography> </Typography>
</NavLink> </Button>
<Typography {/* <Typography
ref={librariesText}
variant="subtitle1" variant="subtitle1"
fontWeight={600} fontWeight={600}
onMouseEnter={popoverEnter} onMouseEnter={popoverEnter}
@@ -211,61 +284,104 @@ export const AppBar = () => {
: "appBar-text" : "appBar-text"
} }
// onMouseLeave={popoverLeave} // onMouseLeave={popoverLeave}
> ></Typography> */}
Libraries
</Typography>
<Menu <Popper
open={Boolean(librariesPopover)} open={Boolean(librariesPopper)}
anchorEl={librariesPopover} anchorEl={librariesPopper}
anchorOrigin={{ placement="bottom"
horizontal: "center", disablePortal
vertical: "bottom", modifiers={[
}} {
transformOrigin={{ name: "flip",
horizontal: "center", enabled: true,
vertical: "top", options: {
}} altBoundary: true,
sx={{ rootBoundary: "document",
mt: 3, padding: 8,
maxHeight: "72em", },
}} },
onClose={popoverLeave} {
MenuListProps={{ name: "preventOverflow",
onMouseLeave: popoverLeave, enabled: true,
}} options: {
disableScrollLock altAxis: true,
hideBackdrop altBoundary: true,
tether: true,
rootBoundary: "document",
padding: 8,
},
},
]}
transition
> >
{libraries.isPending {({ TransitionProps }) => (
? "loading..." <Grow
: libraries.data.Items.map( {...TransitionProps}
(library) => ( style={{
<MenuItem transformOrigin: "50% 0 0",
component={NavLink} }}
to={ timeout={250}
"/library/" + >
library.Id <Paper
} sx={{
key={library.Id} mt: "1.1em",
// onClick={() => maxHeight: "72em",
// navigate( }}
// `/library/${library.Id}`, style={{
// ) boxShadow:
// } "0px 5px 5px -3px rgba(0,0,0,0.2), 0px 8px 10px 1px rgba(0,0,0,0.14), 0px 3px 14px 2px rgba(0,0,0,0.12)",
tabIndex={0} overflow: "hidden",
className="appBar-library" borderRadius: "25px",
> }}
<ListItemIcon> >
{getTypeIcon( <div className="appBar-library-scrollContainer">
library.CollectionType, {libraries.isPending
)} ? "loading..."
</ListItemIcon> : libraries.data.Items.map(
{library.Name} (
</MenuItem> library,
), ) => (
)} <NavLink
</Menu> key={
library.Id
}
className="appBar-library"
to={`library/${library.Id}`}
style={{
borderRadius:
"10px",
}}
>
{Object.keys(
library.ImageTags,
).includes(
"Primary",
) ? (
<img
src={`${api.basePath}/Items/${library.Id}/Images/Primary?quality=90&fillHeight=226&fillWidth=127`}
/>
) : (
<div className="appBar-library-icon">
{" "}
{getTypeIcon(
library.CollectionType,
)}{" "}
<Typography variant="h6">
{
library.Name
}
</Typography>
</div>
)}
</NavLink>
),
)}
</div>
</Paper>
</Grow>
)}
</Popper>
</div> </div>
<div <div
+69 -3
View File
@@ -15,7 +15,6 @@
} }
} }
&-text { &-text {
cursor: default;
opacity: 0.7; opacity: 0.7;
transition: opacity $transition-time-fast; transition: opacity $transition-time-fast;
position: relative; position: relative;
@@ -53,9 +52,76 @@
} }
} }
&-library { &-library {
transition: all 0.2s; position: relative;
width: 20rem;
text-decoration: none;
&::after {
content: "";
position: absolute;
inset: 5px;
background: rgb(0 0 0 / 0.3);
opacity: 0;
transition: opacity $transition-time-fast;
border-radius: 5px;
}
> img {
border: 0px solid white;
width: inherit;
object-fit: cover;
height: 100%;
border-radius: 10px;
transition: border $transition-time-fast;
}
&-icon {
height: 100%;
width: inherit;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
color: white !important;
background: rgb(255 255 255 / 0.1);
border: 0px solid white;
border-radius: 10px;
transition: border $transition-time-fast;
.material-symbols-rounded {
font-size: 3em;
}
}
&.active { &.active {
background: $clr-gradient-default; &::after {
opacity: 1;
}
> img {
border: 5px solid white;
}
.material-symbols-rounded {
font-variation-settings: "FILL" 1, "wght" 300, "GRAD" 25,
"opsz" 40;
}
.appBar-library-icon {
border: 5px solid white;
}
}
&-scrollContainer {
display: flex;
max-width: 35vw;
overflow: auto;
gap: 1em;
height: inherit;
padding: 15px;
// Magic scrollbar
&::-webkit-scrollbar {
&-thumb {
width: 150px;
}
&-track {
margin-left: 25px;
margin-right: 25px;
background: transparent !important;
}
}
} }
} }
} }
+1 -6
View File
@@ -35,18 +35,13 @@ const jellyfin = new Jellyfin({
* @typedef {import("@jellyfin/sdk").Api} Api * @typedef {import("@jellyfin/sdk").Api} Api
*/ */
export const useApi = create((set) => ({ export const useApi = create(() => ({
/** /**
* @type {Api} * @type {Api}
*/ */
api: null, api: null,
deviceId: localStorage.getItem("deviceId"), deviceId: localStorage.getItem("deviceId"),
jellyfin: jellyfin, jellyfin: jellyfin,
createApi: (serverAddress, accessToken) =>
set((state) => ({
...state,
api: jellyfin.createApi(serverAddress, accessToken, axiosClient),
})),
})); }));
/** /**