11import { useCallback , useEffect } from 'react' ;
2- import { Box , Header , Scroll , Spinner , Text , color } from 'folds' ;
2+ import { Box , Spinner , Text , color } from 'folds' ;
33import {
44 Outlet ,
55 generatePath ,
@@ -9,12 +9,9 @@ import {
99 useParams ,
1010 useSearchParams ,
1111} from 'react-router-dom' ;
12- import classNames from 'classnames' ;
1312
14- import * as PatternsCss from '$styles/Patterns.css' ;
1513import { clientAllowedServer , clientDefaultServer , useClientConfig } from '$hooks/useClientConfig' ;
1614import { AsyncStatus , useAsyncCallback } from '$hooks/useAsyncCallback' ;
17- import CinnySVG from '$public/favicon.png' ;
1815import { SpecVersionsLoader } from '$components/SpecVersionsLoader' ;
1916import { SpecVersionsProvider } from '$hooks/useSpecVersions' ;
2017import { AutoDiscoveryInfoProvider } from '$hooks/useAutoDiscoveryInfo' ;
@@ -24,8 +21,7 @@ import { AuthServerProvider } from '$hooks/useAuthServer';
2421import { LOGIN_PATH , REGISTER_PATH , RESET_PASSWORD_PATH } from '$pages/paths' ;
2522import { AutoDiscoveryAction , autoDiscovery } from '../../cs-api' ;
2623import { ServerPicker } from './ServerPicker' ;
27- import * as css from './styles.css' ;
28- import { AuthFooter } from './AuthFooter' ;
24+ import { AuthShell } from './AuthShell' ;
2925
3026const currentAuthPath = ( pathname : string ) : string => {
3127 if ( matchPath ( LOGIN_PATH , pathname ) ) {
@@ -124,92 +120,66 @@ export function AuthLayout() {
124120 discoveryState . status === AsyncStatus . Success ? discoveryState . data . response : [ ] ;
125121
126122 return (
127- < Scroll variant = "Background" visibility = "Hover" size = "300" hideTrack >
128- < Box
129- className = { classNames ( css . AuthLayout , PatternsCss . BackgroundDotPattern ) }
130- direction = "Column"
131- alignItems = "Center"
132- justifyContent = "SpaceBetween"
133- gap = "400"
134- >
135- < Box direction = "Column" className = { css . AuthCard } >
136- < Header className = { css . AuthHeader } size = "600" variant = "Surface" >
137- < Box grow = "Yes" direction = "Row" gap = "300" alignItems = "Center" >
138- < img className = { css . AuthLogo } src = { CinnySVG } alt = "Cinny Logo" />
139- < Text size = "H3" > Sable</ Text >
140- </ Box >
141- { isAddingAccount && (
142- < Text size = "T200" priority = "300" style = { { marginLeft : 'auto' , marginRight : 4 } } >
143- Adding account
144- </ Text >
145- ) }
146- </ Header >
147- < Box className = { css . AuthCardContent } direction = "Column" >
148- < Box direction = "Column" gap = "100" >
149- < Text as = "label" size = "L400" priority = "300" >
150- Homeserver
151- </ Text >
152- < ServerPicker
153- server = { server }
154- serverList = { clientConfig . homeserverList ?? [ ] }
155- allowCustomServer = { clientConfig . allowCustomHomeservers }
156- onServerChange = { selectServer }
157- />
158- </ Box >
159- { discoveryState . status === AsyncStatus . Loading && (
160- < AuthLayoutLoading message = "Looking for homeserver..." />
161- ) }
162- { discoveryState . status === AsyncStatus . Error && (
163- < AuthLayoutError message = "Failed to find homeserver." />
164- ) }
165- { autoDiscoveryError ?. action === AutoDiscoveryAction . FAIL_PROMPT && (
166- < AuthLayoutError
167- message = { `Failed to connect. Homeserver configuration found with ${ autoDiscoveryError . host } appears unusable.` }
168- />
169- ) }
170- { autoDiscoveryError ?. action === AutoDiscoveryAction . FAIL_ERROR && (
171- < AuthLayoutError message = "Failed to connect. Homeserver configuration base_url appears invalid." />
172- ) }
173- { discoveryState . status === AsyncStatus . Success && autoDiscoveryInfo && (
174- < AuthServerProvider value = { discoveryState . data . serverName } >
175- < AutoDiscoveryInfoProvider value = { autoDiscoveryInfo } >
176- < SpecVersionsLoader
177- baseUrl = { autoDiscoveryInfo [ 'm.homeserver' ] . base_url }
178- fallback = { ( ) => (
179- < AuthLayoutLoading
180- message = { `Connecting to ${ autoDiscoveryInfo [ 'm.homeserver' ] . base_url } ` }
181- />
182- ) }
123+ < AuthShell isAddingAccount = { isAddingAccount } >
124+ < Box direction = "Column" gap = "100" >
125+ < Text as = "label" size = "L400" priority = "300" >
126+ Homeserver
127+ </ Text >
128+ < ServerPicker
129+ server = { server }
130+ serverList = { clientConfig . homeserverList ?? [ ] }
131+ allowCustomServer = { clientConfig . allowCustomHomeservers }
132+ onServerChange = { selectServer }
133+ />
134+ </ Box >
135+ { discoveryState . status === AsyncStatus . Loading && (
136+ < AuthLayoutLoading message = "Looking for homeserver..." />
137+ ) }
138+ { discoveryState . status === AsyncStatus . Error && (
139+ < AuthLayoutError message = "Failed to find homeserver." />
140+ ) }
141+ { autoDiscoveryError ?. action === AutoDiscoveryAction . FAIL_PROMPT && (
142+ < AuthLayoutError
143+ message = { `Failed to connect. Homeserver configuration found with ${ autoDiscoveryError . host } appears unusable.` }
144+ />
145+ ) }
146+ { autoDiscoveryError ?. action === AutoDiscoveryAction . FAIL_ERROR && (
147+ < AuthLayoutError message = "Failed to connect. Homeserver configuration base_url appears invalid." />
148+ ) }
149+ { discoveryState . status === AsyncStatus . Success && autoDiscoveryInfo && (
150+ < AuthServerProvider value = { discoveryState . data . serverName } >
151+ < AutoDiscoveryInfoProvider value = { autoDiscoveryInfo } >
152+ < SpecVersionsLoader
153+ baseUrl = { autoDiscoveryInfo [ 'm.homeserver' ] . base_url }
154+ fallback = { ( ) => (
155+ < AuthLayoutLoading
156+ message = { `Connecting to ${ autoDiscoveryInfo [ 'm.homeserver' ] . base_url } ` }
157+ />
158+ ) }
159+ error = { ( ) => (
160+ < AuthLayoutError message = "Failed to connect. Either homeserver is unavailable at this moment or does not exist." />
161+ ) }
162+ >
163+ { ( specVersions ) => (
164+ < SpecVersionsProvider value = { specVersions } >
165+ < AuthFlowsLoader
166+ fallback = { ( ) => < AuthLayoutLoading message = "Loading authentication flow..." /> }
183167 error = { ( ) => (
184- < AuthLayoutError message = "Failed to connect. Either homeserver is unavailable at this moment or does not exist ." />
168+ < AuthLayoutError message = "Failed to get authentication flow information ." />
185169 ) }
186170 >
187- { ( specVersions ) => (
188- < SpecVersionsProvider value = { specVersions } >
189- < AuthFlowsLoader
190- fallback = { ( ) => (
191- < AuthLayoutLoading message = "Loading authentication flow..." />
192- ) }
193- error = { ( ) => (
194- < AuthLayoutError message = "Failed to get authentication flow information." />
195- ) }
196- >
197- { ( authFlows ) => (
198- < AuthFlowsProvider value = { authFlows } >
199- < Outlet />
200- </ AuthFlowsProvider >
201- ) }
202- </ AuthFlowsLoader >
203- </ SpecVersionsProvider >
171+ { ( authFlows ) => (
172+ < AuthFlowsProvider value = { authFlows } >
173+ < Outlet />
174+ </ AuthFlowsProvider >
204175 ) }
205- </ SpecVersionsLoader >
206- </ AutoDiscoveryInfoProvider >
207- </ AuthServerProvider >
208- ) }
209- </ Box >
210- </ Box >
211- < AuthFooter />
212- </ Box >
213- </ Scroll >
176+ </ AuthFlowsLoader >
177+ </ SpecVersionsProvider >
178+ ) }
179+ </ SpecVersionsLoader >
180+ </ AutoDiscoveryInfoProvider >
181+ </ AuthServerProvider >
182+ ) }
183+ </ AuthShell >
214184 ) ;
215185}
0 commit comments