From 690070207b90747b41c44051b65f0a874c509eb3 Mon Sep 17 00:00:00 2001 From: --remove-section Date: Sat, 17 Jan 2026 20:20:20 +0530 Subject: [PATCH] refactor: improve UI components --- src/components/addServerDialog/index.tsx | 158 ++++++++++-------- src/components/appBar/appBar.scss | 13 +- src/components/appBar/appBar.tsx | 10 +- src/components/buttons/likeButton.tsx | 16 +- src/components/buttons/playButton.tsx | 12 +- src/components/buttons/queueButton.tsx | 19 ++- src/components/buttons/quickConnectButton.tsx | 7 +- src/components/buttons/trailerButton.tsx | 1 + src/components/card/card.scss | 5 +- src/components/filtersDialog/index.tsx | 36 +++- src/components/queueListItem/index.tsx | 20 ++- src/components/settings/index.tsx | 152 ++++------------- src/components/userAvatarMenu/index.tsx | 9 +- src/styles/global.scss | 8 +- 14 files changed, 220 insertions(+), 246 deletions(-) diff --git a/src/components/addServerDialog/index.tsx b/src/components/addServerDialog/index.tsx index ea4bf36..c8e42b5 100644 --- a/src/components/addServerDialog/index.tsx +++ b/src/components/addServerDialog/index.tsx @@ -1,17 +1,17 @@ -import { setServer } from "@/utils/storage/servers"; -import { jellyfin } from "@/utils/store/api"; import { LoadingButton } from "@mui/lab"; import { + Box, Button, Dialog, - DialogActions, - DialogContent, - DialogTitle, - TextField, + InputBase, + Stack, + Typography, } from "@mui/material"; import { useMutation } from "@tanstack/react-query"; import { enqueueSnackbar } from "notistack"; import React, { useState } from "react"; +import { setServer } from "@/utils/storage/servers"; +import { jellyfin } from "@/utils/store/api"; type AddServerDialogProps = { open: boolean; @@ -64,72 +64,98 @@ export default function AddServerDialog(props: AddServerDialogProps) { return ( setAddServerDialog(false)} hideBackdrop={Boolean(hideBackdrop)} fullWidth maxWidth="sm" disableScrollLock={true} + PaperProps={{ + sx: { + backgroundColor: "rgba(20, 20, 30, 0.7)", + backdropFilter: "blur(24px) saturate(180%)", + backgroundImage: + "linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0))", + border: "1px solid rgba(255, 255, 255, 0.08)", + boxShadow: "0 20px 50px rgba(0,0,0,0.5)", + borderRadius: 4, + overflow: "hidden", + }, + }} > - - Add Server - - - setServerIp(e.target.value)} - /> - - - - {/* @ts-ignore */} - - add_circle - - } - variant="contained" - loading={addServer.isPending} - loadingPosition="start" - onClick={addServer.mutate} - color="success" - > - Add - - + + dns + + setServerIp(e.target.value)} + sx={{ py: 1.5 }} + autoFocus + onKeyDown={(e) => { + if (e.key === "Enter") { + addServer.mutate(); + } + }} + /> + + + + + addServer.mutate()} + variant="contained" + color="primary" + sx={{ borderRadius: 2, px: 3 }} + disabled={!serverIp} + > + Connect + + + ); } \ No newline at end of file diff --git a/src/components/appBar/appBar.scss b/src/components/appBar/appBar.scss index c99f72c..460c333 100644 --- a/src/components/appBar/appBar.scss +++ b/src/components/appBar/appBar.scss @@ -16,15 +16,20 @@ &::after { content: ""; position: absolute; - backdrop-filter: blur(40px); inset: -0.35em; pointer-events: none; border-radius: inherit; - box-shadow: 0 0 25px rgb(0 0 0 / 0.45); - background: rgb(0 0 0 / 0.4); + + // Glass styling matching Search Dialog + background-color: rgba(20, 20, 30, 0.7); + backdrop-filter: blur(24px) saturate(180%); + background-image: linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0)); + border: 1px solid rgba(255, 255, 255, 0.08); + box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4); + opacity: 0; z-index: -1; - transition: opacity $transition-time-fast; + transition: all $transition-time-fast; } } diff --git a/src/components/appBar/appBar.tsx b/src/components/appBar/appBar.tsx index 72d2bda..61dc733 100644 --- a/src/components/appBar/appBar.tsx +++ b/src/components/appBar/appBar.tsx @@ -130,11 +130,11 @@ export const AppBar = () => { >
-
menu
+ menu
-
{ } > home -
+
-
search
+ search
-
favorite
+ favorite
diff --git a/src/components/buttons/likeButton.tsx b/src/components/buttons/likeButton.tsx index 593dde7..ce06097 100644 --- a/src/components/buttons/likeButton.tsx +++ b/src/components/buttons/likeButton.tsx @@ -1,13 +1,11 @@ -import React from "react"; - -import IconButton from "@mui/material/IconButton"; - -import { useApiInContext } from "@/utils/store/api"; import type { UserItemDataDto } from "@jellyfin/sdk/lib/generated-client"; import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api"; import { pink } from "@mui/material/colors"; +import IconButton from "@mui/material/IconButton"; import { useMutation, useQueryClient } from "@tanstack/react-query"; import { useSnackbar } from "notistack"; +import React from "react"; +import { useApiInContext } from "@/utils/store/api"; export default function LikeButton({ itemId, @@ -78,24 +76,24 @@ export default function LikeButton({ transition: "opacity 250ms", }} > -
favorite -
+ ); } diff --git a/src/components/buttons/playButton.tsx b/src/components/buttons/playButton.tsx index 7eaf222..679e7a7 100644 --- a/src/components/buttons/playButton.tsx +++ b/src/components/buttons/playButton.tsx @@ -263,14 +263,14 @@ const PlayButton = ({ } {...buttonProps} > -
play_arrow -
+ ); } @@ -295,7 +295,7 @@ const PlayButton = ({ } }} startIcon={ -
play_arrow -
+ } {...buttonProps} sx={{ @@ -384,7 +384,7 @@ const PlayButton = ({ item.Type === "Episode" ? handleClick(e, item.Id) : handleClick(e) } startIcon={ -
play_arrow -
+ } {...buttonProps} sx={{ diff --git a/src/components/buttons/queueButton.tsx b/src/components/buttons/queueButton.tsx index 35f8a5e..5da32d9 100644 --- a/src/components/buttons/queueButton.tsx +++ b/src/components/buttons/queueButton.tsx @@ -160,13 +160,21 @@ const QueueButton = () => { open={open} onClose={() => setOpen(false)} PaperProps={{ + className: "glass", sx: { width: 450, maxWidth: "100%", display: "flex", flexDirection: "column", - bgcolor: "background.default", - backgroundImage: "none", + borderLeft: "1px solid rgba(255, 255, 255, 0.08)", + }, + }} + ModalProps={{ + BackdropProps: { + sx: { + backgroundColor: "rgba(0, 0, 0, 0.2)", + backdropFilter: "blur(4px)", + }, }, }} > @@ -179,9 +187,10 @@ const QueueButton = () => { position: "sticky", top: 0, zIndex: 20, - bgcolor: "background.default", borderBottom: "1px solid", - borderColor: "divider", + borderColor: "rgba(255, 255, 255, 0.08)", + backgroundColor: "rgba(20, 20, 30, 0.4)", + backdropFilter: "blur(12px)", }} > @@ -194,7 +203,7 @@ const QueueButton = () => { sx={{ ml: 1, fontWeight: 600, - bgcolor: "action.hover", + bgcolor: "rgba(255, 255, 255, 0.08)", px: 1, py: 0.5, borderRadius: 2, diff --git a/src/components/buttons/quickConnectButton.tsx b/src/components/buttons/quickConnectButton.tsx index ed8774a..aa9a101 100644 --- a/src/components/buttons/quickConnectButton.tsx +++ b/src/components/buttons/quickConnectButton.tsx @@ -1,6 +1,3 @@ -import useInterval from "@/utils/hooks/useInterval"; -import { saveUser } from "@/utils/storage/user"; -import { useApiInContext } from "@/utils/store/api"; import { getQuickConnectApi } from "@jellyfin/sdk/lib/utils/api/quick-connect-api"; import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api"; import { LoadingButton, type LoadingButtonProps } from "@mui/lab"; @@ -22,6 +19,9 @@ import { useNavigate } from "@tanstack/react-router"; import { writeText } from "@tauri-apps/plugin-clipboard-manager"; import { useSnackbar } from "notistack"; import React, { useCallback, useState } from "react"; +import useInterval from "@/utils/hooks/useInterval"; +import { saveUser } from "@/utils/storage/user"; +import { useApiInContext } from "@/utils/store/api"; const Transition = React.forwardRef(function Transition( props: TransitionProps & { @@ -185,6 +185,7 @@ const QuickConnectButton = (props: LoadingButtonProps) => { fullWidth maxWidth="xs" TransitionComponent={Transition} + PaperProps={{ className: "glass", sx: { borderRadius: "24px" } }} > { fullWidth open={dialog} PaperProps={{ + className: "glass", style: { overflow: "hidden", }, diff --git a/src/components/card/card.scss b/src/components/card/card.scss index aa280a7..109601e 100644 --- a/src/components/card/card.scss +++ b/src/components/card/card.scss @@ -82,12 +82,13 @@ top: 0; z-index: 10; opacity: 0; - transition: opacity $transition-time-default; + transition: all $transition-time-default; display: flex; align-items: flex-end; justify-content: flex-end; padding: 0.5em; - background: rgb(0 0 0 / 0.6); + background: rgba(20, 20, 30, 0.6); + backdrop-filter: blur(12px); } &:hover, &:focus, diff --git a/src/components/filtersDialog/index.tsx b/src/components/filtersDialog/index.tsx index 2f2becd..3d8fcfd 100644 --- a/src/components/filtersDialog/index.tsx +++ b/src/components/filtersDialog/index.tsx @@ -164,9 +164,19 @@ export const FiltersDialog: React.FC = React.memo( const restoreGenres = () => setLocalGenreIds(initialGenres); return ( - + Filters - + = React.memo( "& .MuiAccordionSummary-content": { my: 0 }, }} expandIcon={ -
expand_more
+ expand_more } > General @@ -236,7 +246,9 @@ export const FiltersDialog: React.FC = React.memo( "& .MuiAccordionSummary-content": { my: 0 }, }} expandIcon={ -
expand_more
+ + expand_more + } > Video features @@ -288,7 +300,9 @@ export const FiltersDialog: React.FC = React.memo( "& .MuiAccordionSummary-content": { my: 0 }, }} expandIcon={ -
expand_more
+ + expand_more + } > Resolution @@ -334,7 +348,9 @@ export const FiltersDialog: React.FC = React.memo( "& .MuiAccordionSummary-content": { my: 0 }, }} expandIcon={ -
expand_more
+ + expand_more + } > Media type @@ -383,7 +399,9 @@ export const FiltersDialog: React.FC = React.memo( "& .MuiAccordionSummary-content": { my: 0 }, }} expandIcon={ -
expand_more
+ + expand_more + } > Genres @@ -475,7 +493,7 @@ export const FiltersDialogTrigger: React.FC = () => { onClick={() => setOpen(true)} aria-label="Open filters dialog" > -
@@ -498,7 +516,7 @@ export const FiltersDialogTrigger: React.FC = () => { {activeCount} )} -
+ setOpen(false)} /> diff --git a/src/components/queueListItem/index.tsx b/src/components/queueListItem/index.tsx index 4a82f0c..ef65234 100644 --- a/src/components/queueListItem/index.tsx +++ b/src/components/queueListItem/index.tsx @@ -1,5 +1,6 @@ import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client"; import { + alpha, Box, IconButton, ListItem, @@ -94,16 +95,23 @@ const QueueListItem = ({ } sx={{ opacity: active ? 1 : 1, - bgcolor: active ? "transparent" : "background.paper", + bgcolor: active ? "rgba(255, 255, 255, 0.1)" : "rgba(0,0,0,0.2)", borderRadius: 3, mb: 0, transition: "all 0.2s ease", - border: active ? "none" : "1px solid", - borderColor: "divider", + border: "1px solid", + borderColor: active + ? "rgba(255, 255, 255, 0.2)" + : "rgba(255,255,255,0.05)", "&:hover": { - bgcolor: active ? "transparent" : "action.hover", + bgcolor: active + ? "rgba(255, 255, 255, 0.15)" + : "rgba(255,255,255,0.05)", transform: active ? "none" : "translateY(-2px)", - boxShadow: active ? "none" : 2, + borderColor: active + ? "rgba(255, 255, 255, 0.3)" + : "rgba(255,255,255,0.2)", + boxShadow: active ? "none" : "0 4px 12px rgba(0,0,0,0.2)", }, pr: onDelete ? 6 : 2, ...sx, @@ -117,7 +125,7 @@ const QueueListItem = ({ marginRight: 12, display: "flex", alignItems: "center", - opacity: 0.3, + opacity: 0.5, transition: "opacity 0.2s", }} className="drag-handle" diff --git a/src/components/settings/index.tsx b/src/components/settings/index.tsx index bdc58cc..6138ebd 100644 --- a/src/components/settings/index.tsx +++ b/src/components/settings/index.tsx @@ -1,7 +1,6 @@ -import useSettingsStore, { - setSettingsDialogOpen, - setSettingsTabValue, -} from "@/utils/store/settings"; +import { getDisplayPreferencesApi } from "@jellyfin/sdk/lib/utils/api/display-preferences-api"; +import { getLocalizationApi } from "@jellyfin/sdk/lib/utils/api/localization-api"; +import { getSystemApi } from "@jellyfin/sdk/lib/utils/api/system-api"; import { Button, Chip, @@ -18,19 +17,25 @@ import { TextField, Typography, } from "@mui/material"; +import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { AnimatePresence, motion } from "motion/react"; -import React, { useState, useMemo, useCallback } from "react"; - +import React, { useCallback, useMemo, useState } from "react"; import logo from "@/assets/logo.png"; - import { jellyfin, useApiInContext } from "@/utils/store/api"; import { useCentralStore } from "@/utils/store/central"; -import { getDisplayPreferencesApi } from "@jellyfin/sdk/lib/utils/api/display-preferences-api"; -import { getLocalizationApi } from "@jellyfin/sdk/lib/utils/api/localization-api"; -import { getSystemApi } from "@jellyfin/sdk/lib/utils/api/system-api"; -import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; +import useSettingsStore, { + setSettingsDialogOpen, + setSettingsTabValue, +} from "@/utils/store/settings"; import "./settings.scss"; +import type { RecommendedServerInfo } from "@jellyfin/sdk"; +import { LoadingButton } from "@mui/lab"; +import { red } from "@mui/material/colors"; +import { useNavigate } from "@tanstack/react-router"; +import { relaunch } from "@tauri-apps/plugin-process"; +import { check } from "@tauri-apps/plugin-updater"; +import { useSnackbar } from "notistack"; import { delServer, getAllServers, @@ -40,13 +45,7 @@ import { } from "@/utils/storage/servers"; import { allSettings } from "@/utils/storage/settings"; import { delUser } from "@/utils/storage/user"; -import type { RecommendedServerInfo } from "@jellyfin/sdk"; -import { LoadingButton } from "@mui/lab"; -import { red } from "@mui/material/colors"; -import { useNavigate } from "@tanstack/react-router"; -import { relaunch } from "@tauri-apps/plugin-process"; -import { check } from "@tauri-apps/plugin-updater"; -import { useSnackbar } from "notistack"; +import AddServerDialog from "../addServerDialog"; import SettingOption from "../settingOption"; import SettingOptionSelect from "../settingOptionSelect"; @@ -64,12 +63,12 @@ const Settings = () => { state.dialogOpen, state.tabValue, ]); - + const api = useApiInContext((s) => s.api); const createApi = useApiInContext((s) => s.createApi); const user = useCentralStore((state) => state.currentUser); - + const systemInfo = useQuery({ queryKey: ["about", "systemInfo"], queryFn: async () => { @@ -83,7 +82,9 @@ const Settings = () => { const navigate = useNavigate(); const { enqueueSnackbar } = useSnackbar(); - const [applicationVersion] = useCentralStore((state) => [state.clientVersion]); + const [applicationVersion] = useCentralStore((state) => [ + state.clientVersion, + ]); const serversOnDisk = useQuery({ queryKey: ["settings", "serversOnDisk"], @@ -113,7 +114,7 @@ const Settings = () => { enabled: open, }); - const clientSettingsOnServer = useQuery({ + const _clientSettingsOnServer = useQuery({ queryKey: ["settings", "clientSettings"], queryFn: async () => { if (!api) return; @@ -127,13 +128,11 @@ const Settings = () => { enabled: open, }); - const queryClient = useQueryClient(); // Server Management const [updating, setUpdating] = useState(false); const [addServerDialog, setAddServerDialog] = useState(false); - const [serverIp, setServerIp] = useState(""); const handleServerChange = useMutation({ mutationFn: async (server: RecommendedServerInfo) => { @@ -181,40 +180,6 @@ const Settings = () => { }, }); - const addServer = useMutation({ - mutationFn: async () => { - const servers = - await jellyfin.discovery.getRecommendedServerCandidates(serverIp); - const bestServer = jellyfin.discovery.findBestServer(servers); - return bestServer; - }, - onSuccess: async (bestServer) => { - if (bestServer) { - await setServer(bestServer.systemInfo?.Id ?? "", bestServer); - setAddServerDialog(false); - enqueueSnackbar( - "Client added successfully. You might need to refresh client list.", - { - variant: "success", - }, - ); - await serversOnDisk.refetch(); - } - }, - onError: (err) => { - console.error(err); - enqueueSnackbar(`${err}`, { variant: "error" }); - enqueueSnackbar("Something went wrong", { variant: "error" }); - }, - onSettled: async (bestServer) => { - if (!bestServer) { - enqueueSnackbar("Provided server address is not a Jellyfin server.", { - variant: "error", - }); - } - }, - }); - // Memoize PaperProps to prevent unnecessary re-renders const paperProps = useMemo( () => ({ @@ -636,73 +601,14 @@ const Settings = () => { - {/* Add Server */} - - Add Server - - setServerIp(e.target.value)} - /> - - - - {/* @ts-ignore */} - - add_circle - - } - variant="contained" - loading={addServer.isPending} - loadingPosition="start" - onClick={addServer.mutate} - color="success" - > - Add - - - + sideEffect={async () => { + await serversOnDisk.refetch(); + }} + />
); }; diff --git a/src/components/userAvatarMenu/index.tsx b/src/components/userAvatarMenu/index.tsx index 0fbccd2..f2a6103 100644 --- a/src/components/userAvatarMenu/index.tsx +++ b/src/components/userAvatarMenu/index.tsx @@ -91,6 +91,7 @@ export const UserAvatarMenu = () => { onClose={handleMenuClose} sx={menuStyle} disableScrollLock + PaperProps={{ className: "glass" }} > { @@ -99,7 +100,7 @@ export const UserAvatarMenu = () => { }} > -
logout
+ logout
Logout
@@ -112,7 +113,7 @@ export const UserAvatarMenu = () => { }} > -
settings
+ settings
Settings @@ -123,7 +124,7 @@ export const UserAvatarMenu = () => { }} > -
tune
+ tune
Preferences @@ -134,7 +135,7 @@ export const UserAvatarMenu = () => { }} > -
info
+ info
About diff --git a/src/styles/global.scss b/src/styles/global.scss index c134906..15e891d 100644 --- a/src/styles/global.scss +++ b/src/styles/global.scss @@ -296,10 +296,10 @@ h1 { } .glass { - background: rgba(0, 0, 0, 0.6) !important; - backdrop-filter: blur(20px); - border: 1px solid rgba(255, 255, 255, 0.1); - box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37); + background-color: rgba(20, 20, 30, 0.7) !important; + backdrop-filter: blur(24px) saturate(180%) !important; + border: 1px solid rgba(255, 255, 255, 0.08); + box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5); } .opacity-07{