8
8
import { observable } from 'mobx' ;
9
9
import { observer } from 'mobx-react-lite' ;
10
10
import { Suspense , useContext , useEffect , useRef , useState } from 'react' ;
11
- import styled , { use } from 'reshadow' ;
12
11
13
- import type { ComponentStyle } from '@cloudbeaver/core-theming' ;
14
12
import { ILoadableState , uuid } from '@cloudbeaver/core-utils' ;
15
13
16
14
import { Button } from '../Button' ;
17
15
import { ErrorBoundary } from '../ErrorBoundary' ;
18
16
import { ExceptionMessage } from '../ExceptionMessage' ;
19
17
import { Translate } from '../localization/Translate' ;
18
+ import { s } from '../s' ;
20
19
import { StaticImage } from '../StaticImage' ;
21
- import { useStyles } from '../useStyles' ;
20
+ import { useS } from '../useS' ;
21
+ import styles from './Loader.m.css' ;
22
22
import { ILoaderContext , LoaderContext } from './LoaderContext' ;
23
- import { loaderStyles , overlayStyles } from './loaderStyles' ;
24
23
25
24
type LoaderState =
26
25
| ILoadableState
@@ -52,7 +51,6 @@ interface Props {
52
51
className ?: string ;
53
52
fullSize ?: boolean ;
54
53
state ?: LoaderState | LoaderState [ ] ;
55
- style ?: ComponentStyle ;
56
54
children ?: ( ( ) => React . ReactNode ) | React . ReactNode ;
57
55
onCancel ?: ( ) => void ;
58
56
}
@@ -80,7 +78,6 @@ export const Loader = observer<Props>(function Loader({
80
78
loading,
81
79
inlineException,
82
80
state,
83
- style,
84
81
children,
85
82
onCancel,
86
83
} ) {
@@ -171,7 +168,7 @@ export const Loader = observer<Props>(function Loader({
171
168
loading = false ;
172
169
}
173
170
174
- style = useStyles ( loaderStyles , style , overlay && overlayStyles ) ;
171
+ const style = useS ( styles ) ;
175
172
const [ isVisible , setVisible ] = useState ( loading ) ;
176
173
177
174
const refLoaderDisplayed = { state : false } ;
@@ -232,7 +229,6 @@ export const Loader = observer<Props>(function Loader({
232
229
fullSize = { fullSize }
233
230
className = { className }
234
231
inlineException = { inlineException }
235
- style = { style }
236
232
/>
237
233
}
238
234
>
@@ -251,7 +247,7 @@ export const Loader = observer<Props>(function Loader({
251
247
if ( hideException ) {
252
248
return null ;
253
249
}
254
- return styled ( style ) ( < ExceptionMessage exception = { exception } inline = { inline || inlineException } className = { className } onRetry = { reload } /> ) ;
250
+ return < ExceptionMessage exception = { exception } inline = { inline || inlineException } className = { className } onRetry = { reload } /> ;
255
251
}
256
252
257
253
if ( children && ( ! loader || ! loading ) && ! overlay ) {
@@ -274,31 +270,31 @@ export const Loader = observer<Props>(function Loader({
274
270
275
271
refLoaderDisplayed . state = true ;
276
272
277
- return styled ( style ) (
273
+ return (
278
274
< LoaderContext . Provider value = { contextState } >
279
275
< >
280
276
{ overlay && renderWrappedChildren ( ) }
281
- < loader ref = { loaderRef } className = { className } { ... use ( { small, fullSize, inline, secondary, overlay } ) } >
282
- < icon >
283
- < StaticImage icon = { spinnerType . primary } { ... use ( { primaryIcon : true } ) } />
284
- < StaticImage icon = { spinnerType . primarySmall } { ... use ( { primarySmallIcon : true } ) } />
285
- < StaticImage icon = { spinnerType . secondary } { ... use ( { secondaryIcon : true } ) } />
286
- < StaticImage icon = { spinnerType . secondarySmall } { ... use ( { secondarySmallIcon : true } ) } />
287
- </ icon >
277
+ < div ref = { loaderRef } className = { s ( style , { loader : true , loaderOverlay : overlay , small, fullSize, inline, secondary, overlay } , className ) } >
278
+ < div className = { s ( style , { icon : true } ) } >
279
+ < StaticImage icon = { spinnerType . primary } className = { s ( style , { staticImage : true , primaryIcon : true } ) } />
280
+ < StaticImage icon = { spinnerType . primarySmall } className = { s ( style , { staticImage : true , primarySmallIcon : true } ) } />
281
+ < StaticImage icon = { spinnerType . secondary } className = { s ( style , { staticImage : true , secondaryIcon : true } ) } />
282
+ < StaticImage icon = { spinnerType . secondarySmall } className = { s ( style , { staticImage : true , secondarySmallIcon : true } ) } />
283
+ </ div >
288
284
{ ! hideMessage && (
289
- < message >
285
+ < div className = { s ( style , { message : true } ) } >
290
286
< Translate token = { message || 'ui_processing_loading' } />
291
- </ message >
287
+ </ div >
292
288
) }
293
289
{ onCancel && (
294
- < actions >
290
+ < div className = { s ( style , { actions : true } ) } >
295
291
< Button type = "button" mod = { [ 'unelevated' ] } disabled = { cancelDisabled } onClick = { onCancel } >
296
292
< Translate token = "ui_processing_cancel" />
297
293
</ Button >
298
- </ actions >
294
+ </ div >
299
295
) }
300
- </ loader >
296
+ </ div >
301
297
</ >
302
- </ LoaderContext . Provider > ,
298
+ </ LoaderContext . Provider >
303
299
) ;
304
300
} ) ;
0 commit comments