@@ -4,7 +4,7 @@ import styled from '@emotion/styled';
44import { ReactComponent as LogoImage } from 'assets/images/logo.svg' ;
55import { usePrefixedTranslation } from 'hooks' ;
66import { useStore } from 'store' ;
7- import { Background , Button , HeaderOne , Input } from 'components/base' ;
7+ import { Background , Button , ChevronDown , ChevronUp , HeaderOne } from 'components/base' ;
88
99const Styled = {
1010 Wrapper : styled . div `
@@ -33,22 +33,57 @@ const Styled = {
3333 text-align: center;
3434 ` ,
3535 Form : styled . form `
36+ max-width: 550px;
3637 display: flex;
3738 flex-direction: column;
3839 align-items: center;
3940 ` ,
40- Label : styled . label `
41- margin: 10px 0 80px;
41+ Password : styled . input `
42+ font-family: ${ props => props . theme . fonts . work . light } ;
43+ font-weight: 300;
44+ font-size: ${ props => props . theme . sizes . xxl } ;
45+ color: ${ props => props . theme . colors . offWhite } ;
46+ background-color: transparent;
47+ border-width: 0;
48+ border-bottom: 3px solid ${ props => props . theme . colors . offWhite } ;
49+ padding: 5px;
50+ text-align: center;
51+ width: 100%;
52+
53+ &:active,
54+ &:focus {
55+ outline: none;
56+ background-color: ${ props => props . theme . colors . overlay } ;
57+ border-bottom-color: ${ props => props . theme . colors . white } ;
58+ }
59+
60+ &::placeholder {
61+ color: ${ props => props . theme . colors . gray } ;
62+ }
4263 ` ,
64+ Label : styled . label `` ,
4365 ErrMessage : styled . div `
4466 width: 100%;
45- margin: 0 0 80px ;
67+ display: inline-block ;
4668 padding: 5px 0;
4769 background-color: ${ props => props . theme . colors . pink } ;
4870 color: ${ props => props . theme . colors . offWhite } ;
4971 text-align: center;
5072 ` ,
73+ ErrDetail : styled . div `
74+ width: 100%;
75+ display: inline-block;
76+ padding: 5px 0;
77+ color: ${ props => props . theme . colors . offWhite } ;
78+ text-align: center;
79+ ` ,
80+ ErrDetailToggle : styled ( Button ) `
81+ width: 100%;
82+ padding: 5px 0;
83+ background-color: transparent;
84+ ` ,
5185 Submit : styled ( Button ) `
86+ margin-top: 80px;
5287 background-color: transparent;
5388 ` ,
5489} ;
@@ -58,10 +93,17 @@ const AuthPage: React.FC = () => {
5893 const store = useStore ( ) ;
5994 const [ pass , setPass ] = useState ( '' ) ;
6095 const [ error , setError ] = useState ( '' ) ;
96+ const [ errorDetailLit , setErrorDetailLit ] = useState ( '' ) ;
97+ const [ errorDetailLnd , setErrorDetailLnd ] = useState ( '' ) ;
98+ const [ errorDetailVisible , setErrorDetailVisible ] = useState ( false ) ;
99+ const [ showDetailButton , setShowDetailButton ] = useState ( true ) ;
61100
62101 const handleChange = ( e : React . ChangeEvent < HTMLInputElement > ) => {
63102 setPass ( e . target . value ) ;
64103 setError ( '' ) ;
104+ setErrorDetailLit ( '' ) ;
105+ setErrorDetailLnd ( '' ) ;
106+ setShowDetailButton ( false ) ;
65107 } ;
66108
67109 const handleSubmit = async ( e : React . FormEvent < HTMLFormElement > ) => {
@@ -70,14 +112,32 @@ const AuthPage: React.FC = () => {
70112 await store . authStore . login ( pass ) ;
71113 } catch ( err ) {
72114 setError ( err . message ) ;
115+ const errors = store . authStore . errors ;
116+ setErrorDetailLit ( errors . litDetail ) ;
117+ setErrorDetailLnd ( errors . lndDetail ) ;
118+
119+ // don't display the detail toggle button if there is nothing to display
120+ setShowDetailButton ( errors . litDetail . length > 0 || errors . litDetail . length > 0 ) ;
73121 }
74122 } ;
75123
76124 // don't display the login UI until the app is fully initialized this prevents
77125 // a UI flicker while validating credentials stored in session storage
78126 if ( ! store . initialized ) return null ;
79127
80- const { Wrapper, Logo, Title, Subtitle, Form, Label, ErrMessage, Submit } = Styled ;
128+ const {
129+ Wrapper,
130+ Logo,
131+ Title,
132+ Subtitle,
133+ Form,
134+ Password,
135+ Label,
136+ ErrMessage,
137+ ErrDetail,
138+ ErrDetailToggle,
139+ Submit,
140+ } = Styled ;
81141 return (
82142 < Background gradient >
83143 < Wrapper >
@@ -86,15 +146,43 @@ const AuthPage: React.FC = () => {
86146 < Title > { l ( 'terminal' ) } </ Title >
87147 < Subtitle > { l ( 'subtitle' ) } </ Subtitle >
88148 < Form onSubmit = { handleSubmit } >
89- < Input
149+ < Password
90150 id = "auth"
91151 type = "password"
92152 autoFocus
93153 value = { pass }
94154 onChange = { handleChange }
95155 />
96156 { error ? (
97- < ErrMessage > { error } </ ErrMessage >
157+ < >
158+ < ErrMessage > { error } </ ErrMessage >
159+ { errorDetailVisible && errorDetailLit . length > 0 ? (
160+ < ErrDetail > { errorDetailLit } </ ErrDetail >
161+ ) : (
162+ ''
163+ ) }
164+ { errorDetailVisible && errorDetailLnd . length > 0 ? (
165+ < ErrDetail > { errorDetailLnd } </ ErrDetail >
166+ ) : (
167+ ''
168+ ) }
169+ { showDetailButton ? (
170+ < ErrDetailToggle
171+ ghost
172+ borderless
173+ compact
174+ type = "button"
175+ onClick = { ( ) => {
176+ setErrorDetailVisible ( ! errorDetailVisible ) ;
177+ } }
178+ >
179+ { ! errorDetailVisible ? < ChevronDown /> : < ChevronUp /> }
180+ { ! errorDetailVisible ? l ( 'showDetail' ) : l ( 'hideDetail' ) }
181+ </ ErrDetailToggle >
182+ ) : (
183+ ''
184+ ) }
185+ </ >
98186 ) : (
99187 < Label htmlFor = "auth" > { l ( 'passLabel' ) } </ Label >
100188 ) }
0 commit comments