@@ -12,12 +12,33 @@ import { httpErrorToHuman } from '@/api/http';
1212import { FlashMessage } from '@/state/flashes' ;
1313import ReCAPTCHA from 'react-google-recaptcha' ;
1414import Spinner from '@/components/elements/Spinner' ;
15+ import styled from 'styled-components' ;
16+ import { breakpoint } from 'styled-components-breakpoint' ;
1517
1618type 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+
2142const 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} ;
0 commit comments