refactor: redesign sidebar component
This commit is contained in:
9 files changed
+487
-330
No files matched your search
@@ -90,48 +90,98 @@
|
||||
}
|
||||
}
|
||||
|
||||
.library-drawer{
|
||||
width: 20em;
|
||||
margin: 1.4em;
|
||||
height: calc(100vh - 2.8em) !important;
|
||||
border-radius: 20px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
.library-drawer-item{
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
border-radius: 1000px;
|
||||
> div::before{
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: transparent;
|
||||
transition: $transition-time-default;
|
||||
z-index: -1;
|
||||
border-radius: 100px;
|
||||
.library-drawer {
|
||||
// Ensure the drawer paper itself gets the styling
|
||||
&.MuiDrawer-paper {
|
||||
width: 280px;
|
||||
margin: 16px;
|
||||
height: calc(100% - 32px) !important; // float in the middle
|
||||
border-radius: 24px;
|
||||
background: rgba(20, 20, 25, 0.75); // Darker, substantial base
|
||||
backdrop-filter: blur(24px) saturate(180%);
|
||||
border: 1px solid rgba(255, 255, 255, 0.06);
|
||||
box-shadow:
|
||||
0 24px 48px rgba(0, 0, 0, 0.4),
|
||||
0 4px 8px rgba(0, 0, 0, 0.2);
|
||||
overflow: hidden; // Contain scrollbars
|
||||
}
|
||||
|
||||
.MuiList-root {
|
||||
padding: 8px; // Reduced from 16px
|
||||
gap: 2px; // Reduced gap
|
||||
}
|
||||
|
||||
.MuiDivider-root {
|
||||
border-color: rgba(255, 255, 255, 0.1);
|
||||
margin: 4px 12px; // Reduced margins
|
||||
}
|
||||
|
||||
// Navigation Items
|
||||
.MuiListItemButton-root {
|
||||
border-radius: 12px !important; // Slightly smaller radius
|
||||
padding: 8px 12px; // Reduced padding (was 12px 16px)
|
||||
margin-bottom: 2px;
|
||||
transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
color: #fff;
|
||||
transform: scale(1.02);
|
||||
}
|
||||
|
||||
.material-symbols-rounded {
|
||||
margin-right: 12px; // Reduced spacing
|
||||
font-size: 22px; // Slightly smaller icons usually look better with less padding
|
||||
transition: all 0.2s ease;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.MuiListItemText-primary {
|
||||
font-weight: 600;
|
||||
font-size: 0.9rem; // Slightly smaller text
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
}
|
||||
.active.library-drawer-item {
|
||||
.material-symbols-rounded{
|
||||
--fill: 1;
|
||||
}
|
||||
&> div::before {
|
||||
background: $clr-accent-default;
|
||||
|
||||
// Active State
|
||||
.library-drawer-item.active {
|
||||
.MuiListItemButton-root {
|
||||
background: linear-gradient(90deg, rgba($clr-accent-default, 0.2), rgba($clr-accent-default, 0.05));
|
||||
color: $clr-accent-default;
|
||||
|
||||
.material-symbols-rounded {
|
||||
font-variation-settings: 'FILL' 1;
|
||||
color: $clr-accent-default;
|
||||
}
|
||||
|
||||
// Active Indicator Bar
|
||||
&::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
height: 24px;
|
||||
width: 4px;
|
||||
background: $clr-accent-default;
|
||||
border-radius: 0 4px 4px 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Magic scrollbar
|
||||
|
||||
// Custom Scrollbar for the drawer content
|
||||
&::-webkit-scrollbar {
|
||||
&-thumb {
|
||||
height: 150px;
|
||||
max-height: 33%;
|
||||
}
|
||||
&-track {
|
||||
margin-top: 15px;
|
||||
margin-bottom: 15px;
|
||||
background: transparent !important;
|
||||
width: 4px;
|
||||
}
|
||||
&::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 4px;
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,20 @@
|
||||
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
||||
import MuiAppBar from "@mui/material/AppBar";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import useScrollTrigger from "@mui/material/useScrollTrigger";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { useLocation, useNavigate } from "@tanstack/react-router";
|
||||
import React, { useCallback, useMemo, useState } from "react";
|
||||
|
||||
import "./appBar.scss";
|
||||
|
||||
import { Divider, Drawer, List, ListItem, ListItemButton } from "@mui/material";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
// removed search placeholder; library state now managed via zustand
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import useHeaderStore from "@/utils/store/header";
|
||||
import useSearchStore from "@/utils/store/search";
|
||||
import {
|
||||
setSettingsDialogOpen,
|
||||
setSettingsTabValue,
|
||||
} from "@/utils/store/settings";
|
||||
import BackButton from "../buttons/backButton";
|
||||
import ListItemLink from "../listItemLink";
|
||||
import { UserAvatarMenu } from "../userAvatarMenu";
|
||||
import { getTypeIcon } from "../utils/iconsCollection";
|
||||
import { NavigationDrawer } from "./navigationDrawer";
|
||||
|
||||
const MemoizeBackButton = React.memo(BackButton);
|
||||
|
||||
@@ -39,8 +30,6 @@ const HIDDEN_PATHS = [
|
||||
];
|
||||
|
||||
export const AppBar = () => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
|
||||
@@ -55,23 +44,6 @@ export const AppBar = () => {
|
||||
location.pathname === "/",
|
||||
);
|
||||
|
||||
|
||||
const [user] = useCentralStore((s) => [s.currentUser]);
|
||||
const libraries = useQuery({
|
||||
queryKey: ["libraries"],
|
||||
queryFn: async () => {
|
||||
if (!user?.Id || !api?.accessToken) {
|
||||
return;
|
||||
}
|
||||
const libs = await getUserViewsApi(api).getUserViews({
|
||||
userId: user.Id,
|
||||
});
|
||||
return libs.data;
|
||||
},
|
||||
enabled: !!user?.Id && !!api?.accessToken,
|
||||
networkMode: "always",
|
||||
});
|
||||
|
||||
const trigger = useScrollTrigger({
|
||||
disableHysteresis: true,
|
||||
threshold: 20,
|
||||
@@ -86,13 +58,6 @@ export const AppBar = () => {
|
||||
};
|
||||
}, []);
|
||||
|
||||
const drawerPaperProps = useMemo(() => {
|
||||
return {
|
||||
className: "glass library-drawer",
|
||||
elevation: 6,
|
||||
};
|
||||
}, []);
|
||||
|
||||
const _handleNavigateToSearch = useCallback(
|
||||
() => navigate({ to: "/search", search: { query: "" } }),
|
||||
[navigate],
|
||||
@@ -157,92 +122,8 @@ export const AppBar = () => {
|
||||
<UserAvatarMenu />
|
||||
</div>
|
||||
</MuiAppBar>
|
||||
<Drawer
|
||||
open={showDrawer}
|
||||
slotProps={{ paper: drawerPaperProps }}
|
||||
className="library-drawer"
|
||||
onClose={handleDrawerClose}
|
||||
>
|
||||
<List>
|
||||
<ListItem>
|
||||
<ListItemButton
|
||||
onClick={handleDrawerClose}
|
||||
style={{
|
||||
borderRadius: "100px",
|
||||
gap: "0.85em",
|
||||
}}
|
||||
>
|
||||
<span className="material-symbols-rounded">menu_open</span>
|
||||
Close
|
||||
</ListItemButton>
|
||||
</ListItem>
|
||||
</List>
|
||||
<Divider variant="middle" />
|
||||
<List>
|
||||
<ListItemLink
|
||||
className="library-drawer-item"
|
||||
to="/home"
|
||||
icon="home"
|
||||
primary="Home"
|
||||
/>
|
||||
{libraries.isSuccess &&
|
||||
libraries.data?.Items?.map((library) => (
|
||||
<ListItemLink
|
||||
className="library-drawer-item"
|
||||
key={library.Id}
|
||||
to="/library/$id"
|
||||
params={{ id: library.Id ?? "" }}
|
||||
icon={
|
||||
library.CollectionType &&
|
||||
getTypeIcon(library.CollectionType)
|
||||
}
|
||||
primary={library.Name ?? "Library"}
|
||||
/>
|
||||
))}
|
||||
</List>
|
||||
<Divider variant="middle" />
|
||||
<List>
|
||||
<ListItem>
|
||||
<ListItemLink
|
||||
to="/settings"
|
||||
icon="settings"
|
||||
primary="Settings"
|
||||
style={{
|
||||
borderRadius: "100px",
|
||||
gap: "0.85em",
|
||||
}}
|
||||
/>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<ListItemButton
|
||||
style={{
|
||||
borderRadius: "100px",
|
||||
gap: "0.85em",
|
||||
}}
|
||||
disabled
|
||||
>
|
||||
<span className="material-symbols-rounded">dns</span>
|
||||
Change Server
|
||||
</ListItemButton>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<ListItemButton
|
||||
onClick={() => {
|
||||
setSettingsDialogOpen(true);
|
||||
setSettingsTabValue(10);
|
||||
}}
|
||||
style={{
|
||||
borderRadius: "100px",
|
||||
gap: "0.85em",
|
||||
}}
|
||||
>
|
||||
<span className="material-symbols-rounded">info</span>
|
||||
About
|
||||
</ListItemButton>
|
||||
</ListItem>
|
||||
</List>
|
||||
</Drawer>
|
||||
<NavigationDrawer open={showDrawer} onClose={handleDrawerClose} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,107 @@
|
||||
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
||||
import { Divider, Drawer, List, ListItem, ListItemButton } from "@mui/material";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import React, { useMemo } from "react";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import ListItemLink from "../listItemLink";
|
||||
import { getTypeIcon } from "../utils/iconsCollection";
|
||||
|
||||
interface NavigationDrawerProps {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export const NavigationDrawer = ({ open, onClose }: NavigationDrawerProps) => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const [user] = useCentralStore((s) => [s.currentUser]);
|
||||
|
||||
const libraries = useQuery({
|
||||
queryKey: ["libraries"],
|
||||
queryFn: async () => {
|
||||
if (!user?.Id || !api?.accessToken) {
|
||||
return;
|
||||
}
|
||||
const libs = await getUserViewsApi(api).getUserViews({
|
||||
userId: user.Id,
|
||||
});
|
||||
return libs.data;
|
||||
},
|
||||
enabled: !!user?.Id && !!api?.accessToken,
|
||||
networkMode: "always",
|
||||
});
|
||||
|
||||
const drawerPaperProps = useMemo(() => {
|
||||
return {
|
||||
className: "glass library-drawer",
|
||||
elevation: 6,
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Drawer
|
||||
open={open}
|
||||
slotProps={{ paper: drawerPaperProps }}
|
||||
className="library-drawer"
|
||||
onClose={onClose}
|
||||
>
|
||||
<List>
|
||||
<ListItem>
|
||||
<ListItemButton onClick={onClose}>
|
||||
<span className="material-symbols-rounded">menu_open</span>
|
||||
<div style={{ marginLeft: "8px" }}>Close</div>
|
||||
</ListItemButton>
|
||||
</ListItem>
|
||||
</List>
|
||||
<Divider variant="middle" />
|
||||
<List>
|
||||
<ListItemLink
|
||||
className="library-drawer-item"
|
||||
to="/home"
|
||||
icon="home"
|
||||
primary="Home"
|
||||
onClick={onClose}
|
||||
/>
|
||||
{libraries.isSuccess &&
|
||||
libraries.data?.Items?.map((library) => (
|
||||
<ListItemLink
|
||||
className="library-drawer-item"
|
||||
key={library.Id}
|
||||
to="/library/$id"
|
||||
params={{ id: library.Id ?? "" }}
|
||||
icon={
|
||||
library.CollectionType &&
|
||||
getTypeIcon(library.CollectionType)
|
||||
}
|
||||
primary={library.Name ?? "Library"}
|
||||
onClick={onClose}
|
||||
/>
|
||||
))}
|
||||
</List>
|
||||
<Divider variant="middle" />
|
||||
<List>
|
||||
<ListItemLink
|
||||
to="/settings/preferences"
|
||||
icon="settings"
|
||||
primary="Settings"
|
||||
className="library-drawer-item"
|
||||
onClick={onClose}
|
||||
/>
|
||||
<ListItemLink
|
||||
to="/settings/changeServer"
|
||||
icon="dns"
|
||||
primary="Change Server"
|
||||
className="library-drawer-item"
|
||||
onClick={onClose}
|
||||
/>
|
||||
<ListItemLink
|
||||
to="/settings/about"
|
||||
icon="info"
|
||||
primary="About"
|
||||
className="library-drawer-item"
|
||||
onClick={onClose}
|
||||
/>
|
||||
</List>
|
||||
</Drawer>
|
||||
);
|
||||
};
|
||||
Reference in new issue
Block a user