Reuse SplashScreen on LoginPage

This commit is contained in:
schroda
2025-09-10 00:53:16 +02:00
parent 3d023abc6c
commit 98e1cb2eff
2 changed files with 46 additions and 30 deletions

View File

@@ -7,16 +7,26 @@
*/ */
import { useTheme } from '@mui/material/styles'; import { useTheme } from '@mui/material/styles';
import Stack from '@mui/material/Stack'; import Stack, { StackProps } from '@mui/material/Stack';
import { ComponentProps } from 'react';
import { SuwayomiLogo } from '@/assets/SuwayomiLogo.tsx'; import { SuwayomiLogo } from '@/assets/SuwayomiLogo.tsx';
import { ServerAddressSetting } from '@/features/settings/components/ServerAddressSetting.tsx'; import { ServerAddressSetting } from '@/features/settings/components/ServerAddressSetting.tsx';
import { ThemeMode } from '@/features/theme/AppThemeContext.tsx'; import { ThemeMode } from '@/features/theme/AppThemeContext.tsx';
export const SplashScreen = () => { export const SplashScreen = ({
slots,
}: {
slots?: {
stackProps?: StackProps;
logoProps?: ComponentProps<typeof SuwayomiLogo>;
serverAddressProps?: StackProps;
};
}) => {
const theme = useTheme(); const theme = useTheme();
return ( return (
<Stack <Stack
{...slots?.stackProps}
sx={{ sx={{
position: 'relative', position: 'relative',
minWidth: '100vw', minWidth: '100vw',
@@ -27,20 +37,31 @@ export const SplashScreen = () => {
...theme.applyStyles('dark', { ...theme.applyStyles('dark', {
backgroundColor: 'primary.dark', backgroundColor: 'primary.dark',
}), }),
...slots?.stackProps?.sx,
}} }}
> >
<SuwayomiLogo <SuwayomiLogo
circleRingColor={ circleRingColor={
theme.palette.mode === ThemeMode.DARK ? theme.palette.primary.light : theme.palette.primary.dark theme.palette.mode === ThemeMode.DARK ? theme.palette.primary.light : theme.palette.primary.dark
} }
{...slots?.logoProps}
sx={{ sx={{
fontSize: 250, fontSize: 250,
[theme.breakpoints.up('lg')]: { [theme.breakpoints.up('lg')]: {
fontSize: 350, fontSize: 350,
}, },
...slots?.logoProps?.sx,
}} }}
/> />
<Stack sx={{ position: 'absolute', left: 0, bottom: 0 }}> <Stack
{...slots?.serverAddressProps}
sx={{
position: 'absolute',
left: 0,
bottom: 0,
...slots?.serverAddressProps?.sx,
}}
>
<ServerAddressSetting /> <ServerAddressSetting />
</Stack> </Stack>
</Stack> </Stack>

View File

@@ -19,11 +19,11 @@ import { requestManager } from '@/lib/requests/RequestManager.ts';
import { makeToast } from '@/base/utils/Toast.ts'; import { makeToast } from '@/base/utils/Toast.ts';
import { getErrorMessage } from '@/lib/HelperFunctions.ts'; import { getErrorMessage } from '@/lib/HelperFunctions.ts';
import { AuthManager } from '@/features/authentication/AuthManager.ts'; import { AuthManager } from '@/features/authentication/AuthManager.ts';
import { SuwayomiLogo } from '@/assets/SuwayomiLogo.tsx';
import { useSessionContext } from '@/features/authentication/SessionContext.tsx'; import { useSessionContext } from '@/features/authentication/SessionContext.tsx';
import { AppRoutes } from '@/base/AppRoute.constants.ts'; import { AppRoutes } from '@/base/AppRoute.constants.ts';
import { useNavBarContext } from '@/features/navigation-bar/NavbarContext.tsx'; import { useNavBarContext } from '@/features/navigation-bar/NavbarContext.tsx';
import { SearchParam } from '@/base/Base.types.ts'; import { SearchParam } from '@/base/Base.types.ts';
import { SplashScreen } from '@/features/authentication/components/SplashScreen.tsx';
import { ServerAddressSetting } from '@/features/settings/components/ServerAddressSetting.tsx'; import { ServerAddressSetting } from '@/features/settings/components/ServerAddressSetting.tsx';
export const LoginPage = () => { export const LoginPage = () => {
@@ -60,7 +60,7 @@ export const LoginPage = () => {
return () => setOverride({ status: false, value: null }); return () => setOverride({ status: false, value: null });
}, []); }, []);
if (isAuthenticated) { if (false && isAuthenticated) {
return <Navigate to={AppRoutes.root.path} replace />; return <Navigate to={AppRoutes.root.path} replace />;
} }
@@ -72,33 +72,28 @@ export const LoginPage = () => {
}, },
}} }}
> >
<Stack <SplashScreen
sx={{ slots={{
minHeight: '50vh', stackProps: {
flexBasis: '60%', sx: {
p: 4, position: 'unset',
justifyContent: 'center', minWidth: 'auto',
alignItems: 'center', minHeight: '50vh',
backgroundColor: 'primary.light', flexBasis: '60%',
...theme.applyStyles('dark', { p: 4,
backgroundColor: 'primary.dark', [theme.breakpoints.up('lg')]: {
}), minHeight: '0vh',
[theme.breakpoints.up('lg')]: { height: '100vh',
minHeight: '0vh', },
height: '100vh', },
},
serverAddressProps: {
sx: {
display: 'none',
},
}, },
}} }}
> />
<SuwayomiLogo
sx={{
fontSize: 250,
[theme.breakpoints.up('lg')]: {
fontSize: 350,
},
}}
circleRingColor={theme.palette.primary.light}
/>
</Stack>
<Stack <Stack
sx={{ sx={{
position: 'relative', position: 'relative',