ui: implement new appBar #284

This commit is contained in:
Prayag Prajapati committed 2024-04-23 09:48:01 +05:30
1 parent fae934dbe1
commit 41ff0f1d15
6 files changed
+283 -324

No files matched your search

+47 -72
View File
@@ -1,11 +1,20 @@
.appBar {
transition: background-color $transition-time-fast,
backdrop-filter $transition-time-fast,
box-shadow $transition-time-default !important;
&.backdropVisible {
background-color: rgb(0 0 0 / 0.6) !important;
backdrop-filter: blur(10px);
backdrop-filter $transition-time-fast,
box-shadow $transition-time-default !important;
padding: 0.8em ($page-margin - 1.7em);
.flex {
transition: $transition-time-fast;
border-radius: 1000px;
}
&.elevated{
.flex {
padding: 0.5em;
background: rgb(0 0 0 / 0.4);
backdrop-filter: blur(40px);
box-shadow: 0 0 15px rgb(0 0 0 / 0.2);
}
}
&-avatar {
background: rgb(255 255 255 / 0.1) !important;
@@ -30,8 +39,8 @@
left: 0;
transform: scaleX(0);
transition: transform $transition-time-fast,
background $transition-time-fast,
opacity $transition-time-fast;
background $transition-time-fast,
opacity $transition-time-fast;
}
&:hover {
opacity: 0.8;
@@ -50,78 +59,44 @@
}
}
}
&-library {
}
.library-drawer{
.library-drawer-item{
position: relative;
width: 20rem;
text-decoration: none;
&::after {
overflow: hidden;
border-radius: 1000px;
> div::before{
content: "";
position: absolute;
inset: 5px;
background: rgb(0 0 0 / 0.3);
opacity: 0;
transition: opacity $transition-time-fast;
border-radius: 5px;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: transparent;
transition: $transition-time-default;
z-index: -1;
border-radius: 100px;
}
> img {
border: 0px solid white;
width: inherit;
object-fit: cover;
height: 100%;
border-radius: 10px;
transition: border $transition-time-fast;
}
.active.library-drawer-item {
.material-symbols-rounded{
--fill: 1;
}
&-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;
}
&> div::before {
background: $clr-accent-default;
}
&.active {
&::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;
}
}
// Magic scrollbar
&::-webkit-scrollbar {
&-thumb {
height: 150px;
max-height: 33%;
}
&-scrollContainer {
display: flex;
max-width: 35vw;
overflow: auto;
gap: 1em;
height: inherit;
padding: 15px;
// Magic scrollbar
&::-webkit-scrollbar {
&-thumb {
width: 150px;
max-width: 33%;
}
&-track {
margin-left: 25px;
margin-right: 25px;
background: transparent !important;
}
}
&-track {
margin-top: 15px;
margin-bottom: 15px;
background: transparent !important;
}
}
}
+190 -220
View File
@@ -18,7 +18,13 @@ import useScrollTrigger from "@mui/material/useScrollTrigger";
import { red } from "@mui/material/colors";
import { Link, NavLink, useLocation, useNavigate } from "react-router-dom";
import {
NavLink as NavLinkBase,
Link as RouterLink,
type LinkProps as RouterLinkProps,
useLocation,
useNavigate,
} 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";
@@ -35,27 +41,63 @@ import { useApi } from "../../utils/store/api";
import { getTypeIcon } from "../utils/iconsCollection";
import { Divider } from "@mui/material";
import logo from "../../assets/icon.svg";
import {
Divider,
Drawer,
List,
ListItem,
ListItemButton,
ListItemText,
} from "@mui/material";
import logo from "../../assets/icon.svg";
import useSettingsStore, {
setSettingsDialogOpen,
setSettingsTabValue,
} from "../../utils/store/settings";
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>
),
});
interface ListItemLinkProps {
icon?: React.ReactElement;
primary: string;
to: string;
}
const NavLink = React.forwardRef((props, ref) => (
<NavLinkBase
ref={ref}
{...props}
style={{ textDecoration: "none" }}
className={({ isActive }) =>
`${props.className} ${isActive ? props.activeClassName : ""}`
}
/>
));
function ListItemLink(props: ListItemLinkProps) {
const { icon, primary, to } = props;
return (
<li>
<ListItem
component={NavLink}
activeClassName="active"
className="library-drawer-item"
to={to}
>
<ListItemButton
style={{
borderRadius: "100px",
gap: "0.85em",
color: "white",
textDecoration: "none",
}}
>
<div className="material-symbols-rounded">{icon}</div>
<ListItemText primary={primary} />
</ListItemButton>
</ListItem>
</li>
);
}
export const AppBar = () => {
const [api] = useApi((state) => [state.api]);
@@ -108,11 +150,8 @@ export const AppBar = () => {
const queryClient = useQueryClient();
const [setDrawerOpen] = useDrawerStore((state) => [state.setOpen]);
const [tabValue] = useSettingsStore((state) => [state.tabValue]);
const handleDrawerOpen = () => {
setDrawerOpen(true);
};
const handleLogout = async () => {
console.log("Logging out user...");
await api.logout();
@@ -124,19 +163,6 @@ export const AppBar = () => {
navigate("/login/index");
};
const [librariesPopper, setLibrariesPopper] = useState(false);
const librariesText = useRef(null);
const handlePopper = (event) => {
if (librariesPopper) {
setLibrariesPopper(null);
} else {
setLibrariesPopper(event.currentTarget);
}
};
const [isBrowsingLibrary, setIsBrowsingLibrary] = useState(false);
useEffect(() => {
if (
location.pathname.includes("login") ||
@@ -156,202 +182,53 @@ export const AppBar = () => {
} else {
setBackButtonVisible(true);
}
if (location.pathname.includes("library")) {
setIsBrowsingLibrary(true);
} else {
setIsBrowsingLibrary(false);
}
}, [location]);
const [showDrawer, setShowDrawer] = useState(false);
if (!display) {
return <></>;
}
if (display) {
return (
<MuiAppBar
style={{
backgroundColor: "transparent",
paddingRight: "0 !important",
}}
className={trigger ? "appBar backdropVisible" : "appBar"}
elevation={trigger ? 4 : 0}
color="transparent"
>
<Toolbar
sx={{
display: "grid",
gap: "0.6em",
gridTemplateColumns: "30% 1fr 30%",
<>
<MuiAppBar
style={{
backgroundColor: "transparent",
paddingRight: "0 !important",
}}
className={
trigger
? "appBar flex flex-row flex-justify-spaced-between elevated"
: "appBar flex flex-row flex-justify-spaced-between"
}
elevation={0}
color="transparent"
>
<IconButton
onClick={() => navigate(-1)}
disabled={!backButtonVisible}
style={{
justifySelf: "left",
}}
>
<div className="material-symbols-rounded">arrow_back</div>
</IconButton>
<div
className="flex flex-row flex-center"
style={{
gap: "2.6em",
}}
>
<NavLink to="/home">
{({ isActive }) =>
isActive ? (
<Button
style={{
textTransform: "none",
}}
size="large"
className="appBar-text active"
>
<Typography variant="subtitle1" fontWeight={600}>
Home
</Typography>
</Button>
) : (
<Button
style={{
textTransform: "none",
}}
className="appBar-text"
size="large"
color="white"
>
<Typography 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"}
className={
isBrowsingLibrary ? "appBar-text active" : "appBar-text"
}
<div className="flex flex-row" style={{ gap: "0.6em" }}>
<IconButton onClick={() => setShowDrawer(true)}>
<div className="material-symbols-rounded">menu</div>
</IconButton>
<IconButton
disabled={!backButtonVisible}
onClick={() => navigate(-1)}
>
<Typography variant="subtitle1" fontWeight={600}>
Libraries
</Typography>
</Button>
{/* <Typography
variant="subtitle1"
fontWeight={600}
onMouseEnter={popoverEnter}
onFocus={popoverEnter}
tabIndex={0}
className={
isBrowsingLibrary
? "appBar-text active"
: "appBar-text"
}
// onMouseLeave={popoverLeave}
></Typography> */}
<Popper
open={Boolean(librariesPopper)}
anchorEl={librariesPopper}
placement="bottom"
disablePortal
modifiers={[
{
name: "flip",
enabled: true,
options: {
altBoundary: true,
rootBoundary: "document",
padding: 8,
},
},
{
name: "preventOverflow",
enabled: true,
options: {
altAxis: true,
altBoundary: true,
tether: true,
rootBoundary: "document",
padding: 8,
},
},
]}
transition
>
{({ TransitionProps }) => (
<Grow
{...TransitionProps}
style={{
transformOrigin: "50% 0 0",
}}
timeout={250}
>
<Paper
sx={{
mt: "1.1em",
maxHeight: "72em",
}}
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)",
overflow: "hidden",
borderRadius: "25px",
}}
>
<div className="appBar-library-scrollContainer">
{libraries.isPending
? "loading..."
: libraries.data.Items.map((library) => (
<NavLink
key={library.Id}
className="appBar-library"
to={`library/${library.Id}`}
style={{
borderRadius: "10px",
}}
>
{Object.keys(library.ImageTags).includes(
"Primary",
) ? (
<img
alt={library.Name}
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 className="material-symbols-rounded">arrow_back</div>
</IconButton>
<IconButton onClick={() => navigate("/home")}>
<div
className={
location.pathname === "/home"
? "material-symbols-rounded fill"
: "material-symbols-rounded"
}
>
home
</div>
</IconButton>
</div>
<div
className="flex flex-row"
style={{ justifySelf: "right", gap: "0.6em" }}
>
<div className="flex flex-row" style={{ gap: "0.6em" }}>
<IconButton onClick={() => navigate("/search")}>
<div className="material-symbols-rounded">search</div>
</IconButton>
@@ -423,8 +300,101 @@ export const AppBar = () => {
</MenuItem>
</Menu>
</div>
</Toolbar>
</MuiAppBar>
</MuiAppBar>
<Drawer
open={showDrawer}
PaperProps={{
className: "glass library-drawer",
style: {
width: "20em",
margin: "1.4em",
height: "calc(100vh - 2.8em)",
borderRadius: "20px",
overflowX: "hidden",
overflowY: "auto",
border: "1.2px solid rgb(255 255 255 / 0.2)",
},
}}
className="library-drawer"
onClose={() => setShowDrawer(false)}
>
<List>
<ListItem>
<ListItemButton
onClick={() => setShowDrawer(false)}
style={{
borderRadius: "100px",
gap: "0.85em",
}}
>
<span className="material-symbols-rounded">menu_open</span>
Close
</ListItemButton>
</ListItem>
</List>
<Divider variant="middle" />
<List>
<ListItemLink to="/home" icon="home" primary="Home" />
{libraries.isSuccess &&
libraries.data.Items?.map((library, index) => (
<ListItemLink
key={library.Id}
to={`/library/${library.Id}`}
icon={getTypeIcon(library.CollectionType)}
primary={library.Name}
/>
))}
</List>
<Divider variant="middle" />
<List>
<ListItem>
<ListItemButton
onClick={() => {
setSettingsDialogOpen(true);
setSettingsTabValue(1);
}}
style={{
borderRadius: "100px",
gap: "0.85em",
}}
>
<span className="material-symbols-rounded">settings</span>
Settings
</ListItemButton>
</ListItem>
<ListItem>
<ListItemButton
onClick={() => {
setSettingsDialogOpen(true);
setSettingsTabValue(2);
}}
style={{
borderRadius: "100px",
gap: "0.85em",
}}
>
<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>
</>
);
}
};
+23 -19
View File
@@ -17,6 +17,7 @@ import {
SortOrder,
type UserItemDataDto,
} from "@jellyfin/sdk/lib/generated-client";
import { getDlnaApi } from "@jellyfin/sdk/lib/utils/api/dlna-api";
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
import { getPlaylistsApi } from "@jellyfin/sdk/lib/utils/api/playlists-api";
import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
@@ -135,6 +136,8 @@ const PlayButton = ({
mutationFn: async () => {
setPlaybackDataLoading(true);
let result: any;
const deviceProfile = await getDlnaApi(api).getDefaultProfile();
console.log(deviceProfile);
if (playlistItem) {
result = await getPlaylistsApi(api).getPlaylistItems({
userId: userId,
@@ -246,31 +249,32 @@ const PlayButton = ({
enableSubtitles = false;
}
playItem(
itemName,
episodeTitle,
currentVideoTrack,
currentAudioTrack,
selectedSubtitleTrack,
result.Items[0].Container,
enableSubtitles,
`${api.basePath}/Videos/${result.Items[0].Id}/stream.${result.Items[0].Container}?Static=true&mediaSourceId=${result.Items[0].Id}&deviceId=${api.deviceInfo.id}&api_key=${api.accessToken}&Tag=${result.Items[0].MediaSources[0].ETag}&videoStreamIndex=${currentVideoTrack}&audioStreamIndex=${currentAudioTrack}`,
userId,
result?.Items[0].UserData?.PlaybackPositionTicks,
result.Items[0].RunTimeTicks,
result.Items[0],
queue,
0,
subtitles,
result?.Items[0].MediaSources[0].Id,
);
navigate("/player");
// playItem(
// itemName,
// episodeTitle,
// currentVideoTrack,
// currentAudioTrack,
// selectedSubtitleTrack,
// result.Items[0].Container,
// enableSubtitles,
// `${api.basePath}/Videos/${result.Items[0].Id}/stream.${result.Items[0].Container}?Static=true&mediaSourceId=${result.Items[0].Id}&deviceId=${api.deviceInfo.id}&api_key=${api.accessToken}&Tag=${result.Items[0].MediaSources[0].ETag}&videoStreamIndex=${currentVideoTrack}&audioStreamIndex=${currentAudioTrack}`,
// userId,
// result?.Items[0].UserData?.PlaybackPositionTicks,
// result.Items[0].RunTimeTicks,
// result.Items[0],
// queue,
// 0,
// subtitles,
// result?.Items[0].MediaSources[0].Id,
// );
// navigate("/player");
}
},
onSettled: () => {
setPlaybackDataLoading(false);
},
onError: (error) => {
console.error(error);
enqueueSnackbar(`${error}`, {
variant: "error",
});
+7 -7
View File
@@ -34,7 +34,7 @@ import { createApi, useApi } from "../../utils/store/api";
import { useCentralStore } from "../../utils/store/central";
import "./settings.module.scss";
import { RecommendedServerInfo } from "@jellyfin/sdk";
import type { RecommendedServerInfo } from "@jellyfin/sdk";
import { LoadingButton } from "@mui/lab";
import { red, yellow } from "@mui/material/colors";
import { relaunch } from "@tauri-apps/api/process";
@@ -194,7 +194,7 @@ const Settings = () => {
fullWidth
maxWidth="md"
PaperProps={{
className: "settings",
className: "settings glass",
}}
onClose={() => setSettingsDialogOpen(false)}
>
@@ -205,7 +205,7 @@ const Settings = () => {
setSettingsTabValue(newValue);
}}
style={{
borderRight: "1.2px solid rgb(255 255 255 / 0.1)",
background: "rgb(0 0 0 / 0.6)",
}}
>
<Tab
@@ -679,8 +679,8 @@ const Settings = () => {
{updateInfo.isFetching
? "Checking for new updates..."
: updateInfo.data?.shouldUpdate
? updateInfo.data.manifest?.version
: "No update found."}
? updateInfo.data.manifest?.version
: "No update found."}
</Typography>
</div>
<LoadingButton
@@ -708,8 +708,8 @@ const Settings = () => {
{updateInfo.isFetching
? "Checking for Update..."
: updateInfo.data?.shouldUpdate
? "Update"
: "No Update Found"}
? "Update"
: "No Update Found"}
</LoadingButton>
</div>
{systemInfo.isSuccess ? (
+6 -1
View File
@@ -226,7 +226,7 @@ h1 {
.flex {
display: flex;
&-row {
flex-direction: row;
flex-direction: row !important;
}
&-column {
flex-direction: column;
@@ -288,4 +288,9 @@ h1 {
.fullWidth {
width: 100%;
}
.glass {
background: rgb(0 0 0 / 0.4) !important;
backdrop-filter: blur(40px);
}
+10 -5
View File
@@ -55,8 +55,6 @@ export const theme = createTheme({
styleOverrides: {
paper: {
borderRadius: "10px",
background: "hsl(256, 100%, 2%, 40%)",
backdropFilter: "blur(20px)",
border: "1px solid rgb(255 255 255 / 0.1)",
},
list: {
@@ -65,6 +63,11 @@ export const theme = createTheme({
},
defaultProps: {
disableScrollLock: true,
slotProps: {
paper: {
className: "glass",
},
},
},
},
MuiMenuItem: {
@@ -79,9 +82,11 @@ export const theme = createTheme({
styleOverrides: {
paper: {
borderRadius: "20px",
background: "rgb(0 0 0 / 0.5)",
backdropFilter: "blur(10px)",
border: "1px solid rgb(255 255 255 / 0.2)",
},
},
defaultProps: {
PaperProps: {
className: "glass",
},
},
},