@@ -4,7 +4,7 @@ import styled from '@emotion/styled';
4
4
import { ReactComponent as LogoImage } from 'assets/images/logo.svg' ;
5
5
import { usePrefixedTranslation } from 'hooks' ;
6
6
import { useStore } from 'store' ;
7
- import { Background , Button , HeaderOne , Input } from 'components/base' ;
7
+ import { Background , Button , ChevronDown , ChevronUp , HeaderOne } from 'components/base' ;
8
8
9
9
const Styled = {
10
10
Wrapper : styled . div `
@@ -33,22 +33,57 @@ const Styled = {
33
33
text-align: center;
34
34
` ,
35
35
Form : styled . form `
36
+ max-width: 550px;
36
37
display: flex;
37
38
flex-direction: column;
38
39
align-items: center;
39
40
` ,
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
+ }
42
63
` ,
64
+ Label : styled . label `` ,
43
65
ErrMessage : styled . div `
44
66
width: 100%;
45
- margin: 0 0 80px ;
67
+ display: inline-block ;
46
68
padding: 5px 0;
47
69
background-color: ${ props => props . theme . colors . pink } ;
48
70
color: ${ props => props . theme . colors . offWhite } ;
49
71
text-align: center;
50
72
` ,
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
+ ` ,
51
85
Submit : styled ( Button ) `
86
+ margin-top: 80px;
52
87
background-color: transparent;
53
88
` ,
54
89
} ;
@@ -58,10 +93,17 @@ const AuthPage: React.FC = () => {
58
93
const store = useStore ( ) ;
59
94
const [ pass , setPass ] = useState ( '' ) ;
60
95
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 ) ;
61
100
62
101
const handleChange = ( e : React . ChangeEvent < HTMLInputElement > ) => {
63
102
setPass ( e . target . value ) ;
64
103
setError ( '' ) ;
104
+ setErrorDetailLit ( '' ) ;
105
+ setErrorDetailLnd ( '' ) ;
106
+ setShowDetailButton ( false ) ;
65
107
} ;
66
108
67
109
const handleSubmit = async ( e : React . FormEvent < HTMLFormElement > ) => {
@@ -70,14 +112,32 @@ const AuthPage: React.FC = () => {
70
112
await store . authStore . login ( pass ) ;
71
113
} catch ( err ) {
72
114
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 ) ;
73
121
}
74
122
} ;
75
123
76
124
// don't display the login UI until the app is fully initialized this prevents
77
125
// a UI flicker while validating credentials stored in session storage
78
126
if ( ! store . initialized ) return null ;
79
127
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 ;
81
141
return (
82
142
< Background gradient >
83
143
< Wrapper >
@@ -86,15 +146,43 @@ const AuthPage: React.FC = () => {
86
146
< Title > { l ( 'terminal' ) } </ Title >
87
147
< Subtitle > { l ( 'subtitle' ) } </ Subtitle >
88
148
< Form onSubmit = { handleSubmit } >
89
- < Input
149
+ < Password
90
150
id = "auth"
91
151
type = "password"
92
152
autoFocus
93
153
value = { pass }
94
154
onChange = { handleChange }
95
155
/>
96
156
{ 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
+ </ >
98
186
) : (
99
187
< Label htmlFor = "auth" > { l ( 'passLabel' ) } </ Label >
100
188
) }
0 commit comments