mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
added nowhere motel scene
This commit is contained in:
parent
7458fb2e55
commit
a3501859a0
7 changed files with 5355 additions and 75 deletions
5294
public/images/nowhere_motel.svg
Normal file
5294
public/images/nowhere_motel.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 481 KiB |
|
@ -1,58 +0,0 @@
|
||||||
import { FC } from 'react';
|
|
||||||
|
|
||||||
import { Group } from '~/components/containers/Group';
|
|
||||||
import { Button } from '~/components/input/Button';
|
|
||||||
import { InputText } from '~/components/input/InputText';
|
|
||||||
import { useLoginForm } from '~/hooks/auth/useLoginForm';
|
|
||||||
import { IUser } from '~/types/auth';
|
|
||||||
|
|
||||||
import styles from './styles.module.scss';
|
|
||||||
|
|
||||||
interface LoginFormProps {
|
|
||||||
login: (username: string, password: string) => Promise<IUser>;
|
|
||||||
onSuccess: () => void;
|
|
||||||
onRestoreRequest: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
const LoginForm: FC<LoginFormProps> = ({
|
|
||||||
login,
|
|
||||||
onSuccess,
|
|
||||||
onRestoreRequest,
|
|
||||||
}) => {
|
|
||||||
const { values, errors, handleSubmit, handleChange } = useLoginForm(
|
|
||||||
login,
|
|
||||||
onSuccess,
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Group>
|
|
||||||
<form onSubmit={handleSubmit}>
|
|
||||||
<InputText
|
|
||||||
title="Логин"
|
|
||||||
handler={handleChange('username')}
|
|
||||||
value={values.username}
|
|
||||||
error={errors.username}
|
|
||||||
autoFocus
|
|
||||||
/>
|
|
||||||
|
|
||||||
<InputText
|
|
||||||
title="Пароль"
|
|
||||||
handler={handleChange('password')}
|
|
||||||
value={values.password}
|
|
||||||
error={errors.password}
|
|
||||||
type="password"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
color="link"
|
|
||||||
type="button"
|
|
||||||
onClick={onRestoreRequest}
|
|
||||||
className={styles.forgot_button}
|
|
||||||
>
|
|
||||||
Вспомнить пароль
|
|
||||||
</Button>
|
|
||||||
</form>
|
|
||||||
</Group>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
export { LoginForm };
|
|
|
@ -1,3 +0,0 @@
|
||||||
.forgot_button {
|
|
||||||
opacity: 0.5;
|
|
||||||
}
|
|
|
@ -1,11 +1,15 @@
|
||||||
import React, { FC } from 'react';
|
import React, { FC } from 'react';
|
||||||
|
|
||||||
|
import classNames from 'classnames';
|
||||||
|
|
||||||
import styles from './styles.module.scss';
|
import styles from './styles.module.scss';
|
||||||
|
|
||||||
interface LoginStaticSceneProps {}
|
interface LoginStaticSceneProps {
|
||||||
|
scene?: 'clouds' | 'nowhere';
|
||||||
|
}
|
||||||
|
|
||||||
const LoginStaticScene: FC<LoginStaticSceneProps> = () => (
|
const LoginStaticScene: FC<LoginStaticSceneProps> = ({ scene = 'login' }) => (
|
||||||
<div className={styles.scene} />
|
<div className={classNames(styles.scene, styles[scene])} />
|
||||||
);
|
);
|
||||||
|
|
||||||
export { LoginStaticScene };
|
export { LoginStaticScene };
|
||||||
|
|
|
@ -4,6 +4,13 @@
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
|
|
||||||
|
&.clouds {
|
||||||
background: url('/images/clouds.svg') no-repeat 50% 50%;
|
background: url('/images/clouds.svg') no-repeat 50% 50%;
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.nowhere {
|
||||||
|
background: url('/images/nowhere_motel.svg') no-repeat 50% 50%;
|
||||||
|
background-size: cover;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
import { FC, useCallback } from 'react';
|
import { FC, useCallback, useRef } from 'react';
|
||||||
|
|
||||||
import { LoginDialogButtons } from '~/components/auth/login/LoginDialogButtons';
|
import { LoginDialogButtons } from '~/components/auth/login/LoginDialogButtons';
|
||||||
import { LoginForm } from '~/components/auth/login/LoginForm';
|
|
||||||
import { LoginStaticScene } from '~/components/auth/login/LoginStaticScene';
|
import { LoginStaticScene } from '~/components/auth/login/LoginStaticScene';
|
||||||
import { Group } from '~/components/containers/Group';
|
import { Group } from '~/components/containers/Group';
|
||||||
import { Padder } from '~/components/containers/Padder';
|
import { Padder } from '~/components/containers/Padder';
|
||||||
import { BetterScrollDialog } from '~/components/dialogs/BetterScrollDialog';
|
import { BetterScrollDialog } from '~/components/dialogs/BetterScrollDialog';
|
||||||
import { DialogTitle } from '~/components/dialogs/DialogTitle';
|
import { DialogTitle } from '~/components/dialogs/DialogTitle';
|
||||||
|
import { Button } from '~/components/input/Button';
|
||||||
|
import { InputText } from '~/components/input/InputText';
|
||||||
import { Dialog } from '~/constants/modal';
|
import { Dialog } from '~/constants/modal';
|
||||||
import { useCloseOnEscape } from '~/hooks';
|
import { useCloseOnEscape } from '~/hooks';
|
||||||
import { useAuth } from '~/hooks/auth/useAuth';
|
import { useAuth } from '~/hooks/auth/useAuth';
|
||||||
|
import { useLoginForm } from '~/hooks/auth/useLoginForm';
|
||||||
import { useOAuth } from '~/hooks/auth/useOAuth';
|
import { useOAuth } from '~/hooks/auth/useOAuth';
|
||||||
import { useShowModal } from '~/hooks/modal/useShowModal';
|
import { useShowModal } from '~/hooks/modal/useShowModal';
|
||||||
import { DialogComponentProps } from '~/types/modal';
|
import { DialogComponentProps } from '~/types/modal';
|
||||||
|
@ -19,6 +21,10 @@ import styles from './styles.module.scss';
|
||||||
type LoginDialogProps = DialogComponentProps & {};
|
type LoginDialogProps = DialogComponentProps & {};
|
||||||
|
|
||||||
const LoginDialog: FC<LoginDialogProps> = ({ onRequestClose }) => {
|
const LoginDialog: FC<LoginDialogProps> = ({ onRequestClose }) => {
|
||||||
|
const feature = useRef<'clouds' | 'nowhere'>(
|
||||||
|
Math.random() <= 0.5 ? 'clouds' : 'nowhere',
|
||||||
|
).current;
|
||||||
|
|
||||||
useCloseOnEscape(onRequestClose);
|
useCloseOnEscape(onRequestClose);
|
||||||
|
|
||||||
const { login } = useAuth();
|
const { login } = useAuth();
|
||||||
|
@ -28,29 +34,55 @@ const LoginDialog: FC<LoginDialogProps> = ({ onRequestClose }) => {
|
||||||
showRestoreDialog({});
|
showRestoreDialog({});
|
||||||
}, [showRestoreDialog]);
|
}, [showRestoreDialog]);
|
||||||
|
|
||||||
|
const backdrop = <LoginStaticScene scene={feature} />;
|
||||||
|
|
||||||
|
const { values, errors, handleSubmit, handleChange } = useLoginForm(
|
||||||
|
login,
|
||||||
|
onRequestClose,
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<form onSubmit={handleSubmit}>
|
||||||
<BetterScrollDialog
|
<BetterScrollDialog
|
||||||
width={300}
|
width={300}
|
||||||
onClose={onRequestClose}
|
onClose={onRequestClose}
|
||||||
footer={<LoginDialogButtons openOauthWindow={openOauthWindow} />}
|
footer={<LoginDialogButtons openOauthWindow={openOauthWindow} />}
|
||||||
backdrop={<LoginStaticScene />}
|
backdrop={backdrop}
|
||||||
>
|
>
|
||||||
<Padder>
|
<Padder>
|
||||||
<div className={styles.wrap}>
|
<div className={styles.wrap}>
|
||||||
<Group>
|
<Group>
|
||||||
<DialogTitle>Решительно войти</DialogTitle>
|
<DialogTitle>Решительно войти</DialogTitle>
|
||||||
|
|
||||||
<LoginForm
|
<InputText
|
||||||
login={login}
|
title="Логин"
|
||||||
onRestoreRequest={onRestoreRequest}
|
handler={handleChange('username')}
|
||||||
onSuccess={onRequestClose}
|
value={values.username}
|
||||||
|
error={errors.username}
|
||||||
|
autoFocus
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<InputText
|
||||||
|
title="Пароль"
|
||||||
|
handler={handleChange('password')}
|
||||||
|
value={values.password}
|
||||||
|
error={errors.password}
|
||||||
|
type="password"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
color="link"
|
||||||
|
type="button"
|
||||||
|
onClick={onRestoreRequest}
|
||||||
|
className={styles.forgot_button}
|
||||||
|
>
|
||||||
|
Вспомнить пароль
|
||||||
|
</Button>
|
||||||
</Group>
|
</Group>
|
||||||
</div>
|
</div>
|
||||||
</Padder>
|
</Padder>
|
||||||
</BetterScrollDialog>
|
</BetterScrollDialog>
|
||||||
</div>
|
</form>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -10,3 +10,7 @@
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.forgot_button {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue