From 41ff0f1d15abde4145b9ae87058e593a318a1e8b Mon Sep 17 00:00:00 2001 From: Prayag Prajapati Date: Tue, 23 Apr 2024 09:48:01 +0530 Subject: [PATCH] ui: implement new appBar #284 --- src/components/appBar/appBar.module.scss | 119 +++---- src/components/appBar/appBar.tsx | 410 +++++++++++------------ src/components/buttons/playButton.tsx | 42 +-- src/components/settings/index.tsx | 14 +- src/styles/global.scss | 7 +- src/theme.js | 15 +- 6 files changed, 283 insertions(+), 324 deletions(-) diff --git a/src/components/appBar/appBar.module.scss b/src/components/appBar/appBar.module.scss index 2727b25..983e70c 100644 --- a/src/components/appBar/appBar.module.scss +++ b/src/components/appBar/appBar.module.scss @@ -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; } } } diff --git a/src/components/appBar/appBar.tsx b/src/components/appBar/appBar.tsx index e9550ce..f817ebd 100644 --- a/src/components/appBar/appBar.tsx +++ b/src/components/appBar/appBar.tsx @@ -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) => ( - - `${props.className} ${isActive ? props.activeClassName : ""}` - } - > - {props.children} - - ), -}); +interface ListItemLinkProps { + icon?: React.ReactElement; + primary: string; + to: string; +} + +const NavLink = React.forwardRef((props, ref) => ( + + `${props.className} ${isActive ? props.activeClassName : ""}` + } + /> +)); + +function ListItemLink(props: ListItemLinkProps) { + const { icon, primary, to } = props; + + return ( +
  • + + +
    {icon}
    + +
    +
    +
  • + ); +} 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 ( - - + - navigate(-1)} - disabled={!backButtonVisible} - style={{ - justifySelf: "left", - }} - > -
    arrow_back
    -
    - -
    - - {({ isActive }) => - isActive ? ( - - ) : ( - - ) - } - - - {/* */} - - - {({ TransitionProps }) => ( - - -
    - {libraries.isPending - ? "loading..." - : libraries.data.Items.map((library) => ( - - {Object.keys(library.ImageTags).includes( - "Primary", - ) ? ( - {library.Name} - ) : ( -
    - {" "} - {getTypeIcon(library.CollectionType)}{" "} - - {library.Name} - -
    - )} -
    - ))} -
    -
    -
    - )} -
    +
    arrow_back
    + + navigate("/home")}> +
    + home +
    +
    -
    +
    navigate("/search")}>
    search
    @@ -423,8 +300,101 @@ export const AppBar = () => {
    - - + + setShowDrawer(false)} + > + + + setShowDrawer(false)} + style={{ + borderRadius: "100px", + gap: "0.85em", + }} + > + menu_open + Close + + + + + + + {libraries.isSuccess && + libraries.data.Items?.map((library, index) => ( + + ))} + + + + + { + setSettingsDialogOpen(true); + setSettingsTabValue(1); + }} + style={{ + borderRadius: "100px", + gap: "0.85em", + }} + > + settings + Settings + + + + { + setSettingsDialogOpen(true); + setSettingsTabValue(2); + }} + style={{ + borderRadius: "100px", + gap: "0.85em", + }} + > + dns + Change Server + + + + { + setSettingsDialogOpen(true); + setSettingsTabValue(10); + }} + style={{ + borderRadius: "100px", + gap: "0.85em", + }} + > + info + About + + + + + ); } }; diff --git a/src/components/buttons/playButton.tsx b/src/components/buttons/playButton.tsx index 4314d21..028019f 100644 --- a/src/components/buttons/playButton.tsx +++ b/src/components/buttons/playButton.tsx @@ -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", }); diff --git a/src/components/settings/index.tsx b/src/components/settings/index.tsx index a32fe7e..bde434e 100644 --- a/src/components/settings/index.tsx +++ b/src/components/settings/index.tsx @@ -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)", }} > { {updateInfo.isFetching ? "Checking for new updates..." : updateInfo.data?.shouldUpdate - ? updateInfo.data.manifest?.version - : "No update found."} + ? updateInfo.data.manifest?.version + : "No update found."}
    { {updateInfo.isFetching ? "Checking for Update..." : updateInfo.data?.shouldUpdate - ? "Update" - : "No Update Found"} + ? "Update" + : "No Update Found"} {systemInfo.isSuccess ? ( diff --git a/src/styles/global.scss b/src/styles/global.scss index f5365cd..1856a9a 100644 --- a/src/styles/global.scss +++ b/src/styles/global.scss @@ -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); } \ No newline at end of file diff --git a/src/theme.js b/src/theme.js index 657b066..e30fc75 100644 --- a/src/theme.js +++ b/src/theme.js @@ -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", }, }, },