Skip to content

Commit f9ec96c

Browse files
committed
Fix login error message width, closes pterodactyl#1792
1 parent 11c430c commit f9ec96c

File tree

2 files changed

+78
-75
lines changed

2 files changed

+78
-75
lines changed

resources/scripts/components/auth/LoginContainer.tsx

Lines changed: 75 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,33 @@ import { httpErrorToHuman } from '@/api/http';
1212
import { FlashMessage } from '@/state/flashes';
1313
import ReCAPTCHA from 'react-google-recaptcha';
1414
import Spinner from '@/components/elements/Spinner';
15+
import styled from 'styled-components';
16+
import { breakpoint } from 'styled-components-breakpoint';
1517

1618
type OwnProps = RouteComponentProps & {
1719
clearFlashes: ActionCreator<void>;
1820
addFlash: ActionCreator<FlashMessage>;
1921
}
2022

23+
const Container = styled.div`
24+
${breakpoint('sm')`
25+
${tw`w-4/5 mx-auto`}
26+
`};
27+
28+
${breakpoint('md')`
29+
${tw`p-10`}
30+
`};
31+
32+
${breakpoint('lg')`
33+
${tw`w-3/5`}
34+
`};
35+
36+
${breakpoint('xl')`
37+
${tw`w-full`}
38+
max-width: 660px;
39+
`};
40+
`;
41+
2142
const LoginContainer = ({ isSubmitting, setFieldValue, values, submitForm, handleSubmit }: OwnProps & FormikProps<LoginData>) => {
2243
const ref = useRef<ReCAPTCHA | null>(null);
2344
const { enabled: recaptchaEnabled, siteKey } = useStoreState<ApplicationStore, any>(state => state.settings.data!.recaptcha);
@@ -38,58 +59,63 @@ const LoginContainer = ({ isSubmitting, setFieldValue, values, submitForm, handl
3859
<h2 className={'text-center text-neutral-100 font-medium py-4'}>
3960
Login to Continue
4061
</h2>
41-
<FlashMessageRender className={'mb-2'}/>
42-
<LoginFormContainer onSubmit={submit}>
43-
<label htmlFor={'username'}>Username or Email</label>
44-
<Field
45-
type={'text'}
46-
id={'username'}
47-
name={'username'}
48-
className={'input'}
49-
/>
50-
<div className={'mt-6'}>
51-
<label htmlFor={'password'}>Password</label>
62+
<Container>
63+
<FlashMessageRender className={'mb-2 px-1'}/>
64+
<LoginFormContainer
65+
className={'w-full flex'}
66+
onSubmit={submit}
67+
>
68+
<label htmlFor={'username'}>Username or Email</label>
5269
<Field
53-
type={'password'}
54-
id={'password'}
55-
name={'password'}
70+
type={'text'}
71+
id={'username'}
72+
name={'username'}
5673
className={'input'}
5774
/>
58-
</div>
59-
<div className={'mt-6'}>
60-
<button
61-
type={'submit'}
62-
className={'btn btn-primary btn-jumbo'}
63-
>
64-
{isSubmitting ?
65-
<Spinner size={'tiny'} className={'mx-auto'}/>
66-
:
67-
'Login'
68-
}
69-
</button>
70-
</div>
71-
{recaptchaEnabled &&
72-
<ReCAPTCHA
73-
ref={ref}
74-
size={'invisible'}
75-
sitekey={siteKey || '_invalid_key'}
76-
onChange={token => {
77-
ref.current && ref.current.reset();
78-
setFieldValue('recaptchaData', token);
79-
submitForm();
80-
}}
81-
onExpired={() => setFieldValue('recaptchaData', null)}
82-
/>
83-
}
84-
<div className={'mt-6 text-center'}>
85-
<Link
86-
to={'/auth/password'}
87-
className={'text-xs text-neutral-500 tracking-wide no-underline uppercase hover:text-neutral-600'}
88-
>
89-
Forgot password?
90-
</Link>
91-
</div>
92-
</LoginFormContainer>
75+
<div className={'mt-6'}>
76+
<label htmlFor={'password'}>Password</label>
77+
<Field
78+
type={'password'}
79+
id={'password'}
80+
name={'password'}
81+
className={'input'}
82+
/>
83+
</div>
84+
<div className={'mt-6'}>
85+
<button
86+
type={'submit'}
87+
className={'btn btn-primary btn-jumbo'}
88+
>
89+
{isSubmitting ?
90+
<Spinner size={'tiny'} className={'mx-auto'}/>
91+
:
92+
'Login'
93+
}
94+
</button>
95+
</div>
96+
{recaptchaEnabled &&
97+
<ReCAPTCHA
98+
ref={ref}
99+
size={'invisible'}
100+
sitekey={siteKey || '_invalid_key'}
101+
onChange={token => {
102+
ref.current && ref.current.reset();
103+
setFieldValue('recaptchaData', token);
104+
submitForm();
105+
}}
106+
onExpired={() => setFieldValue('recaptchaData', null)}
107+
/>
108+
}
109+
<div className={'mt-6 text-center'}>
110+
<Link
111+
to={'/auth/password'}
112+
className={'text-xs text-neutral-500 tracking-wide no-underline uppercase hover:text-neutral-600'}
113+
>
114+
Forgot password?
115+
</Link>
116+
</div>
117+
</LoginFormContainer>
118+
</Container>
93119
</React.Fragment>
94120
);
95121
};
Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,17 @@
11
import React, { forwardRef } from 'react';
2-
import styled from 'styled-components';
32
import { Form } from 'formik';
4-
import { breakpoint } from 'styled-components-breakpoint';
53

64
type Props = React.DetailedHTMLProps<React.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;
75

8-
const LoginContainer = styled.div`
9-
${tw`bg-white shadow-lg rounded-lg p-6 mx-1`};
10-
11-
${breakpoint('sm')`
12-
${tw`w-4/5 mx-auto`}
13-
`};
14-
15-
${breakpoint('md')`
16-
${tw`flex p-10`}
17-
`};
18-
19-
${breakpoint('lg')`
20-
${tw`w-3/5`}
21-
`};
22-
23-
${breakpoint('xl')`
24-
${tw`w-full`}
25-
max-width: 660px;
26-
`};
27-
`;
28-
29-
export default forwardRef<any, Props>(({ className, ...props }, ref) => (
6+
export default forwardRef<any, Props>(({ ...props }, ref) => (
307
<Form {...props}>
31-
<LoginContainer>
8+
<div className={'md:flex w-full bg-white shadow-lg rounded-lg p-6 mx-1'}>
329
<div className={'flex-none select-none mb-6 md:mb-0 self-center'}>
3310
<img src={'/assets/pterodactyl.svg'} className={'block w-48 md:w-64 mx-auto'}/>
3411
</div>
3512
<div className={'flex-1'}>
3613
{props.children}
3714
</div>
38-
</LoginContainer>
15+
</div>
3916
</Form>
4017
));

0 commit comments

Comments
 (0)