1
- import { FC , PropsWithChildren , cloneElement , isValidElement , useState } from 'react' ;
1
+ import { FC , Fragment , PropsWithChildren , cloneElement , isValidElement , useState } from 'react' ;
2
2
import { Render , Provider , Container , useStore } from 'react-login-page' ;
3
3
import { Email } from './control/login/Email' ;
4
4
import { Password } from './control/login/Password' ;
5
5
import { Submit } from './control/login/Submit' ;
6
6
import { Footer } from './control/Footer' ;
7
7
import { Logo } from './control/Logo' ;
8
8
import { Title } from './control/Title' ;
9
+ import { InnerBox } from './control/InnerBox' ;
9
10
import { TitleLogin } from './control/TitleLogin' ;
10
11
import { TitleSignup } from './control/TitleSignup' ;
11
12
import { IconUser } from './icons/user' ;
@@ -17,6 +18,7 @@ export * from 'react-login-page';
17
18
export * from './control/login/Email' ;
18
19
export * from './control/login/Password' ;
19
20
export * from './control/login/Submit' ;
21
+ export * from './control/InnerBox' ;
20
22
export * from './control/Title' ;
21
23
export * from './control/TitleLogin' ;
22
24
export * from './control/TitleSignup' ;
@@ -32,6 +34,10 @@ const RenderLogin = () => {
32
34
const signupButtons = buttons . filter ( ( m ) => m . name . indexOf ( `$$signup` ) > - 1 ) . sort ( ( a , b ) => a . index - b . index ) ;
33
35
const signupFields = fields . filter ( ( m ) => m . name . indexOf ( `$$signup` ) > - 1 ) . sort ( ( a , b ) => a . index - b . index ) ;
34
36
const switchButton = ( ) => setPanel ( panel === 'login' ? 'signup' : 'login' ) ;
37
+ const loginarticle = blocks [ `$$loginarticle` ] ;
38
+ const loginArticleProps = loginarticle ?. props || { } ;
39
+ const signuparticle = blocks [ `$$signuparticle` ] ;
40
+ const signupArticleProps = signuparticle ?. props || { } ;
35
41
return (
36
42
< Render >
37
43
< section className = { `login-page10-toggle ${ panel === 'login' ? 'active-login' : 'active-signup' } ` } >
@@ -49,78 +55,84 @@ const RenderLogin = () => {
49
55
</ header >
50
56
) }
51
57
< main className = { panel === 'login' ? 'active-login' : 'active-signup' } >
52
- < article className = { panel === 'login' ? 'active' : '' } >
53
- < section className = "login-page10-fields login-page10-login" >
54
- < h4 > { blocks [ 'title-login' ] } </ h4 >
55
- { loginFields . map ( ( item , idx ) => {
56
- const extraLabel = extra [ item . name as keyof typeof extra ] ;
57
- if ( ! item . children && ! extraLabel ) return null ;
58
- if ( ! item . children && extraLabel ) return < div key = { idx } > { extraLabel } </ div > ;
59
- if ( ! item . children ) return null ;
60
- const htmlFor = item . name . replace ( '$$login' , '' ) ;
61
- const { name, ...props } = item . children . props ;
62
- const labelElement = label [ item . name ] ;
63
- return (
64
- < label htmlFor = { htmlFor } key = { item . name + idx } >
65
- { cloneElement ( item . children , {
66
- ...props ,
67
- name : panel === 'login' ? name : '' ,
68
- key : item . name + idx ,
69
- } ) }
70
- { extraLabel && < div > { extraLabel } </ div > }
71
- { labelElement && < span className = { `login-page10-label` } > { labelElement } </ span > }
72
- </ label >
73
- ) ;
74
- } ) }
75
- < section className = "login-page10-button" >
76
- { loginButtons . map ( ( item , idx ) => {
77
- const child = item . children ;
78
- if ( ! isValidElement ( child ) ) return null ;
79
- return cloneElement ( child , {
80
- ...child . props ,
81
- key : item . name + idx ,
82
- } ) ;
58
+ { loginarticle &&
59
+ cloneElement (
60
+ loginarticle ,
61
+ Object . assign ( { ...loginArticleProps , className : panel === 'login' ? 'active' : '' } ) ,
62
+ < section className = "login-page10-fields login-page10-login" >
63
+ < h4 > { blocks [ 'title-login' ] } </ h4 >
64
+ { loginFields . map ( ( item , idx ) => {
65
+ const extraLabel = extra [ item . name as keyof typeof extra ] ;
66
+ if ( ! item . children && ! extraLabel ) return null ;
67
+ if ( ! item . children && extraLabel ) return < div key = { idx } > { extraLabel } </ div > ;
68
+ if ( ! item . children ) return null ;
69
+ const htmlFor = item . name . replace ( '$$login' , '' ) ;
70
+ const { name, ...props } = item . children . props ;
71
+ const labelElement = label [ item . name ] ;
72
+ return (
73
+ < label htmlFor = { htmlFor } key = { item . name + idx } >
74
+ { cloneElement ( item . children , {
75
+ ...props ,
76
+ name : panel === 'login' ? name : '' ,
77
+ key : item . name + idx ,
78
+ } ) }
79
+ { extraLabel && < div > { extraLabel } </ div > }
80
+ { labelElement && < span className = { `login-page10-label` } > { labelElement } </ span > }
81
+ </ label >
82
+ ) ;
83
83
} ) }
84
- </ section >
85
- { blocks [ `$$loginfooter` ] }
86
- </ section >
87
- </ article >
88
- < article className = { panel === 'signup' ? 'active' : '' } >
89
- < section className = "login-page10-fields login-page10-signup" >
90
- < h4 > { blocks [ 'title-signup' ] } </ h4 >
91
- { signupFields . map ( ( item , idx ) => {
92
- const extraLabel = extra [ item . name as keyof typeof extra ] ;
93
- if ( ! item . children && ! extraLabel ) return null ;
94
- if ( ! item . children && extraLabel ) return < div key = { idx } > { extraLabel } </ div > ;
95
- if ( ! item . children ) return null ;
96
- const htmlFor = item . name . replace ( '$$signup' , '' ) ;
97
- const { name, ...props } = item . children . props ;
98
- const labelElement = label [ item . name ] ;
99
- return (
100
- < label htmlFor = { htmlFor } key = { item . name + idx } >
101
- { cloneElement ( item . children , {
102
- ...props ,
103
- name : panel === 'signup' ? name : '' ,
84
+ < section className = "login-page10-button" >
85
+ { loginButtons . map ( ( item , idx ) => {
86
+ const child = item . children ;
87
+ if ( ! isValidElement ( child ) ) return null ;
88
+ return cloneElement ( child , {
89
+ ...child . props ,
104
90
key : item . name + idx ,
105
- } ) }
106
- { extraLabel && < div > { extraLabel } </ div > }
107
- { labelElement && < span className = { `login-page10-label` } > { labelElement } </ span > }
108
- </ label >
109
- ) ;
110
- } ) }
111
- < section className = "login-page10-button" >
112
- { signupButtons . map ( ( item , idx ) => {
113
- const child = item . children ;
114
- if ( ! isValidElement ( child ) ) return null ;
115
- return cloneElement ( child , {
116
- ...child . props ,
117
- key : item . name + idx ,
118
- } ) ;
91
+ } ) ;
92
+ } ) }
93
+ </ section >
94
+ { blocks [ `$$loginfooter` ] }
95
+ </ section > ,
96
+ ) }
97
+ { signuparticle &&
98
+ cloneElement (
99
+ signuparticle ,
100
+ Object . assign ( { ...signupArticleProps , className : panel === 'signup' ? 'active' : '' } ) ,
101
+ < section className = "login-page10-fields login-page10-signup" >
102
+ < h4 > { blocks [ 'title-signup' ] } </ h4 >
103
+ { signupFields . map ( ( item , idx ) => {
104
+ const extraLabel = extra [ item . name as keyof typeof extra ] ;
105
+ if ( ! item . children && ! extraLabel ) return null ;
106
+ if ( ! item . children && extraLabel ) return < div key = { idx } > { extraLabel } </ div > ;
107
+ if ( ! item . children ) return null ;
108
+ const htmlFor = item . name . replace ( '$$signup' , '' ) ;
109
+ const { name, ...props } = item . children . props ;
110
+ const labelElement = label [ item . name ] ;
111
+ return (
112
+ < label htmlFor = { htmlFor } key = { item . name + idx } >
113
+ { cloneElement ( item . children , {
114
+ ...props ,
115
+ name : panel === 'signup' ? name : '' ,
116
+ key : item . name + idx ,
117
+ } ) }
118
+ { extraLabel && < div > { extraLabel } </ div > }
119
+ { labelElement && < span className = { `login-page10-label` } > { labelElement } </ span > }
120
+ </ label >
121
+ ) ;
119
122
} ) }
120
- </ section >
121
- { blocks [ `$$signupfooter` ] }
122
- </ section >
123
- </ article >
123
+ < section className = "login-page10-button" >
124
+ { signupButtons . map ( ( item , idx ) => {
125
+ const child = item . children ;
126
+ if ( ! isValidElement ( child ) ) return null ;
127
+ return cloneElement ( child , {
128
+ ...child . props ,
129
+ key : item . name + idx ,
130
+ } ) ;
131
+ } ) }
132
+ </ section >
133
+ { blocks [ `$$signupfooter` ] }
134
+ </ section > ,
135
+ ) }
124
136
</ main >
125
137
</ div >
126
138
</ Render >
@@ -134,6 +146,8 @@ const LoginPage: FC<PropsWithChildren<React.HTMLAttributes<HTMLDivElement>>> = (
134
146
} ) => {
135
147
return (
136
148
< Provider >
149
+ < InnerBox />
150
+ < InnerBox panel = "signup" />
137
151
< TitleSignup />
138
152
< TitleLogin />
139
153
< Email />
@@ -163,6 +177,7 @@ type LoginComponent = FC<PropsWithChildren<React.HTMLAttributes<HTMLDivElement>>
163
177
Submit : typeof Submit ;
164
178
Footer : typeof Footer ;
165
179
Logo : typeof Logo ;
180
+ InnerBox : typeof InnerBox ;
166
181
Title : typeof Title ;
167
182
TitleLogin : typeof TitleLogin ;
168
183
TitleSignup : typeof TitleSignup ;
@@ -175,6 +190,7 @@ Login.Password = Password;
175
190
Login . Submit = Submit ;
176
191
Login . Footer = Footer ;
177
192
Login . Logo = Logo ;
193
+ Login . InnerBox = InnerBox ;
178
194
Login . Title = Title ;
179
195
Login . TitleLogin = TitleLogin ;
180
196
Login . TitleSignup = TitleSignup ;
0 commit comments