From 73e3b865abc2f38ed3a584d7cfdef4553208a131 Mon Sep 17 00:00:00 2001 From: --remove-section Date: Sun, 1 Feb 2026 17:11:19 +0530 Subject: [PATCH] refactor: update UI for setup --- src/components/cardScroller/cardScroller.tsx | 1 - src/main.tsx | 2 +- src/routes/_api/login/$userId.$userName.tsx | 187 +++++++++------ src/routes/_api/login/list.tsx | 165 ++++++++++--- src/routes/_api/login/manual.tsx | 191 ++++++++++----- src/routes/setup/server.add.tsx | 138 ++++++----- src/routes/setup/server.list.tsx | 240 ++++++++++--------- src/theme.ts | 38 +++ 8 files changed, 624 insertions(+), 338 deletions(-) diff --git a/src/components/cardScroller/cardScroller.tsx b/src/components/cardScroller/cardScroller.tsx index 7df68aa..fefd6e3 100644 --- a/src/components/cardScroller/cardScroller.tsx +++ b/src/components/cardScroller/cardScroller.tsx @@ -2,7 +2,6 @@ import React, { type ReactNode, useRef, useState } from "react"; import Carousel from "react-multi-carousel"; import "react-multi-carousel/lib/styles.css"; -import { Box } from "@mui/material"; import IconButton from "@mui/material/IconButton"; import Typography from "@mui/material/Typography"; diff --git a/src/main.tsx b/src/main.tsx index a037456..053930d 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -11,7 +11,7 @@ import { } from "./utils/store/api"; import { CentralProvider, useCentralStore } from "./utils/store/central"; -export const queryClient = new QueryClient({ +const queryClient = new QueryClient({ defaultOptions: { queries: { networkMode: "always", diff --git a/src/routes/_api/login/$userId.$userName.tsx b/src/routes/_api/login/$userId.$userName.tsx index 0241b9c..ce88d6f 100644 --- a/src/routes/_api/login/$userId.$userName.tsx +++ b/src/routes/_api/login/$userId.$userName.tsx @@ -1,11 +1,9 @@ import LoadingButton from "@mui/lab/LoadingButton"; -import { OutlinedInput, Typography } from "@mui/material"; +import { Paper, TextField, Typography } from "@mui/material"; import Checkbox from "@mui/material/Checkbox"; -import FormControl from "@mui/material/FormControl"; import FormControlLabel from "@mui/material/FormControlLabel"; import IconButton from "@mui/material/IconButton"; import InputAdornment from "@mui/material/InputAdornment"; -import InputLabel from "@mui/material/InputLabel"; import { useSnackbar } from "notistack"; @@ -24,6 +22,7 @@ import React, { useEffect, useState, } from "react"; +import { useShallow } from "zustand/shallow"; import { saveUser } from "@/utils/storage/user"; import { useApiInContext } from "@/utils/store/api"; import { useBackdropStore } from "@/utils/store/backdrop.js"; @@ -71,13 +70,15 @@ function LoginUser() { }); }; - const setBackdrop = useBackdropStore((state) => state.setBackdrop); + const setBackdrop = useBackdropStore( + useShallow((state) => state.setBackdrop), + ); useEffect(() => { if (!api) { return; } - setBackdrop("", ""); + setBackdrop(""); }, []); const handleCheckRememberMe = ( @@ -129,82 +130,130 @@ function LoginUser() { return (
- -
- Login as - +
- {userName} - -
-
handleLogin.mutate(e)}> - +
+ + Login as + + + {userName} + +
+
+ + handleLogin.mutate(e)} style={{ width: "100%", + display: "flex", + flexDirection: "column", + gap: "1.5rem", }} > - Password - - - {password.showpass ? ( - visibility - ) : ( - - visibility_off - - )} - - - } + variant="outlined" + autoFocus + InputProps={{ + startAdornment: ( + + + key + + + ), + endAdornment: ( + + + {password.showpass ? ( + + visibility + + ) : ( + + visibility_off + + )} + + + ), + }} /> - - - } - label="Remember me" - /> - chevron_right - } - type="submit" - loading={handleLogin.isPending} - loadingPosition="end" - size="large" - fullWidth - > - Login - - + +
+ + } + label="Remember me" + sx={{ m: 0 }} + /> +
+ + login} + type="submit" + loading={handleLogin.isPending} + loadingPosition="end" + size="large" + fullWidth + sx={{ borderRadius: 2, height: 48 }} + > + Login + + +
); } diff --git a/src/routes/_api/login/list.tsx b/src/routes/_api/login/list.tsx index 2ca19ad..38a5c90 100644 --- a/src/routes/_api/login/list.tsx +++ b/src/routes/_api/login/list.tsx @@ -1,5 +1,5 @@ import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api"; -import { Chip, Typography } from "@mui/material"; +import { Box, Chip, Typography } from "@mui/material"; import { useQuery } from "@tanstack/react-query"; import React, { useEffect } from "react"; @@ -7,10 +7,10 @@ import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice.jsx"; import "./login.scss"; import type { UserDto } from "@jellyfin/sdk/lib/generated-client"; +import { Paper } from "@mui/material"; import { createFileRoute, Link } from "@tanstack/react-router"; import { useApiInContext } from "@/utils/store/api"; import { useBackdropStore } from "@/utils/store/backdrop.js"; - import avatar from "../../../assets/icons/avatar.png"; export const Route = createFileRoute("/_api/login/list")({ @@ -24,21 +24,66 @@ const UserCard = ({ user }: { user: UserDto }) => { to="/login/$userId/$userName" params={{ userId: user.Id ?? "", userName: user.Name ?? "" }} className="user-list-item user-card" + style={{ textDecoration: "none", display: "block" }} > -
- {user.PrimaryImageTag ? ( - {"user"} - ) : ( - user - )} -
- - {user.Name} - + +
+ {user.PrimaryImageTag ? ( + {"user"} + ) : ( + user + )} +
+ + {user.Name} + +
); }; @@ -63,27 +108,77 @@ function LoginPublicUsersList() { if (users.isSuccess) { return ( -
- - Users - +
+ + + Select User + -
- {users.data.map((item) => { - return ; - })} -
+ + {users.data.map((item) => { + return ; + })} + - - Don't see your user? Try using{" "} - Manual Login or{" "} - Changing Server - - } - /> + + Don't see your user? Try using{" "} + + Manual Login + {" "} + or{" "} + + Changing Server + + + } + sx={{ + bgcolor: "rgba(255,255,255,0.05)", + p: 1, + height: "auto", + "& .MuiChip-label": { + padding: "8px 12px", + }, + }} + /> +
); } diff --git a/src/routes/_api/login/manual.tsx b/src/routes/_api/login/manual.tsx index b9c6d56..c21525b 100644 --- a/src/routes/_api/login/manual.tsx +++ b/src/routes/_api/login/manual.tsx @@ -1,36 +1,31 @@ +import { getBrandingApi } from "@jellyfin/sdk/lib/utils/api/branding-api"; +import LoadingButton from "@mui/lab/LoadingButton"; +import { Paper, TextField, Typography } from "@mui/material"; +import Button from "@mui/material/Button"; +import Checkbox from "@mui/material/Checkbox"; +import FormControlLabel from "@mui/material/FormControlLabel"; +import IconButton from "@mui/material/IconButton"; +import InputAdornment from "@mui/material/InputAdornment"; import { useMutation, useQuery } from "@tanstack/react-query"; +import { useSnackbar } from "notistack"; import React, { type ChangeEvent, type FormEvent, useEffect, useState, } from "react"; - import { saveUser } from "@/utils/storage/user.js"; - -import LoadingButton from "@mui/lab/LoadingButton"; -import { OutlinedInput, Paper, TextField, Typography } from "@mui/material"; -import Button from "@mui/material/Button"; -import Checkbox from "@mui/material/Checkbox"; -import FormControl from "@mui/material/FormControl"; -import FormControlLabel from "@mui/material/FormControlLabel"; -import IconButton from "@mui/material/IconButton"; -import InputAdornment from "@mui/material/InputAdornment"; -import InputLabel from "@mui/material/InputLabel"; - -import { useSnackbar } from "notistack"; - import { useApiInContext } from "@/utils/store/api.js"; -import { getBrandingApi } from "@jellyfin/sdk/lib/utils/api/branding-api"; import "./login.scss"; -import { useBackdropStore } from "@/utils/store/backdrop.js"; import { blue } from "@mui/material/colors"; import { createFileRoute, useNavigate, useRouter, } from "@tanstack/react-router"; +import { useShallow } from "zustand/shallow"; +import { useBackdropStore } from "@/utils/store/backdrop.js"; export const Route = createFileRoute("/_api/login/manual")({ component: UserLoginManual, @@ -96,7 +91,12 @@ function UserLoginManual() { } createApi(api.basePath, authenticate.data?.AccessToken); - if (rememberMe) await saveUser(username, authenticate.data.AccessToken); + if (rememberMe) + await saveUser( + username, + authenticate.data.AccessToken, + authenticate.data.User?.Id ?? "", + ); router.invalidate().finally(() => { navigate({ to: searchParams.redirect || "/home", replace: true }); }); @@ -122,40 +122,85 @@ function UserLoginManual() { setRememberMe(checked); }; - const setBackdrop = useBackdropStore((state) => state.setBackdrop); + const setBackdrop = useBackdropStore( + useShallow((state) => state.setBackdrop), + ); useEffect(() => { - setBackdrop("", ""); + setBackdrop(""); }, []); return ( -
-
+ - + Login -
handleLogin.mutate(e)}> + handleLogin.mutate(e)} + > setUsername(e.currentTarget.value)} + InputProps={{ + startAdornment: ( + + + person + + + ), + }} /> - - Password - + + key + + + ), + endAdornment: ( {password.showpass ? ( @@ -168,48 +213,68 @@ function UserLoginManual() { )} - } - /> - + ), + }} + /> + + + } + label={ + + Remember me + } - label="Remember me" /> -
+ +
Login
-
+
{server.isSuccess && server.data?.LoginDisclaimer && (
info - Notice + + Notice +
- + {server.data.LoginDisclaimer}
diff --git a/src/routes/setup/server.add.tsx b/src/routes/setup/server.add.tsx index f5bc3e1..176d0c1 100644 --- a/src/routes/setup/server.add.tsx +++ b/src/routes/setup/server.add.tsx @@ -1,20 +1,19 @@ -import React, { type FormEvent, useState } from "react"; - -import { setDefaultServer, setServer } from "@/utils/storage/servers"; - import LoadingButton from "@mui/lab/LoadingButton"; +import { yellow } from "@mui/material/colors"; import Grid from "@mui/material/Grid"; import TextField from "@mui/material/TextField"; import Typography from "@mui/material/Typography"; +import { useMutation } from "@tanstack/react-query"; import { useSnackbar } from "notistack"; - +import React, { type FormEvent, useState } from "react"; +import { setDefaultServer, setServer } from "@/utils/storage/servers"; import { jellyfin, useApiInContext } from "@/utils/store/api"; -import { yellow } from "@mui/material/colors"; -import { useMutation } from "@tanstack/react-query"; // SCSS import "./server.scss"; +import { Paper, Stack } from "@mui/material"; import { createFileRoute, useNavigate } from "@tanstack/react-router"; +import logo from "../../assets/logoBlackTransparent.png"; export const Route = createFileRoute("/setup/server/add")({ component: ServerSetup, @@ -66,56 +65,85 @@ function ServerSetup() { }); return ( -
-
- Add Server -
-
checkServer.mutate(e)} - className="flex flex-column" - style={{ gap: "1em", width: "100%" }} - > - { - setServerIp(event.target.value); - }} - /> - chevron_right - } - loadingPosition="end" - type="submit" - > - Add Server - - - + + + Blink + + + Enter your Jellyfin server address to get started + + +
checkServer.mutate(e)} + className="flex flex-column" + style={{ gap: "1em", width: "100%" }} + > + { + setServerIp(event.target.value); + }} + InputProps={{ + startAdornment: ( + + dns + + ), + }} + /> + + Connect + + +
+
+ Example: https://demo.jellyfin.org/stable -
+
); } diff --git a/src/routes/setup/server.list.tsx b/src/routes/setup/server.list.tsx index 1e47b08..cdd083d 100644 --- a/src/routes/setup/server.list.tsx +++ b/src/routes/setup/server.list.tsx @@ -1,21 +1,7 @@ -import React, { useLayoutEffect, useState } from "react"; - import Chip from "@mui/material/Chip"; import IconButton from "@mui/material/IconButton"; import Paper from "@mui/material/Paper"; import Typography from "@mui/material/Typography"; -import { red } from "@mui/material/colors"; - -import AppBarBackOnly from "@/components/appBar/backOnly"; -import { - type ServerInfo, - delServer, - getAllServers, - getDefaultServer, - setDefaultServer, -} from "@/utils/storage/servers"; -import { delUser } from "@/utils/storage/user"; -import { useBackdropStore } from "@/utils/store/backdrop"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { createFileRoute, @@ -23,7 +9,19 @@ import { useRouter, } from "@tanstack/react-router"; import { useSnackbar } from "notistack"; +import React, { useLayoutEffect, useState } from "react"; +import AppBarBackOnly from "@/components/appBar/backOnly"; +import { + delServer, + getAllServers, + getDefaultServer, + type ServerInfo, + setDefaultServer, +} from "@/utils/storage/servers"; +import { delUser } from "@/utils/storage/user"; +import { useBackdropStore } from "@/utils/store/backdrop"; import "./serverList.scss"; +import { useShallow } from "zustand/shallow"; import AddServerDialog from "@/components/addServerDialog"; import { useApiInContext } from "@/utils/store/api"; @@ -95,124 +93,138 @@ function ServerList() { await defaultServer.refetch(); }; - const setBackdrop = useBackdropStore((state) => state.setBackdrop); + const setBackdrop = useBackdropStore( + useShallow((state) => state.setBackdrop), + ); useLayoutEffect(() => { - setBackdrop("", ""); + setBackdrop(""); }, []); const [addServerDialog, setAddServerDialog] = useState(false); return ( -
+
-
- - Servers - - setAddServerDialog(true)} > -
add
-
- servers.refetch()} - setAddServerDialog={setAddServerDialog} - /> -
- - {servers.isSuccess && - servers.data.map((server) => ( -
-
- dns -
-
- - {server.systemInfo?.ServerName} - {server.id === defaultServer.data && ( - - Current - - } - color="info" - sx={{ - ml: 2, - width: "5.4em", - }} - size="small" - /> - )} - - - {server.address} - - - Version: {server.systemInfo?.Version} - -
-
- { - handleServerChange.mutate(server); - }} - disabled={handleServerChange.isPending} - > -
start
-
- + Servers + + setAddServerDialog(true)} + sx={{ + bgcolor: "rgba(255,255,255,0.05)", + "&:hover": { bgcolor: "rgba(255,255,255,0.1)" }, + }} + > + add + +
- color: red[400], - }} - disabled={handleServerChange.isPending} - onClick={() => { - handleDelete(server); - }} +
+ {servers.isSuccess && + servers.data.map((server) => ( +
+
-
delete_forever
- + dns +
+
+ + {server.systemInfo?.ServerName} + {server.id === defaultServer.data && ( + + )} + + + {server.address} + +
+
+ { + handleServerChange.mutate(server); + }} + disabled={handleServerChange.isPending} + size="small" + sx={{ + bgcolor: "rgba(255,255,255,0.05)", + "&:hover": { bgcolor: "var(--mui-palette-primary-main)" }, + }} + > + login + + handleDelete(server)} + size="small" + sx={{ + bgcolor: "rgba(255,255,255,0.05)", + "&:hover": { bgcolor: "var(--mui-palette-error-main)" }, + }} + > + delete + +
-
- ))} + ))} +
+ servers.refetch()} + setAddServerDialog={setAddServerDialog} + />
); } diff --git a/src/theme.ts b/src/theme.ts index 29266fc..01610e5 100644 --- a/src/theme.ts +++ b/src/theme.ts @@ -91,5 +91,43 @@ export const theme = createTheme({ }, }, }, + MuiInputLabel: { + styleOverrides: { + root: { + marginLeft: "6px", + color: "rgba(255, 255, 255, 0.5)", + "&.Mui-focused": { + color: clrAccentDefault, + }, + }, + }, + }, + MuiOutlinedInput: { + styleOverrides: { + notchedOutline: { + paddingLeft: "15px", + }, + root: { + backgroundColor: "rgba(0,0,0,0.2)", + borderRadius: "16px", + transition: "border-color 0.2s, background-color 0.2s", + "&.Mui-focused": { + backgroundColor: "rgba(0,0,0,0.3)", + }, + "&:hover": { + backgroundColor: "rgba(0,0,0,0.25)", + }, + "& .MuiOutlinedInput-notchedOutline": { + borderColor: "rgba(255,255,255,0.1)", + }, + "&:hover .MuiOutlinedInput-notchedOutline": { + borderColor: "rgba(255,255,255,0.3)", + }, + "&.Mui-focused .MuiOutlinedInput-notchedOutline": { + borderColor: clrAccentDefault, + }, + }, + }, + }, }, });