@@ -41,13 +41,6 @@ const Spinner = props => {
4141
4242 const isSpinnerColor = spinnerColors . has ( color ) ;
4343
44- // this spacing is consistent with the behaviour of dcc.Loading
45- // it can be overridden with spinnerStyle
46- const defaultSpinnerStyle = children
47- ? { display : 'block' , margin : '1rem auto' }
48- : { } ;
49- const spinnerStyle = { ...defaultSpinnerStyle , ...spinner_style } ;
50-
5144 const fullscreenStyle = {
5245 position : 'fixed' ,
5346 width : '100vw' ,
@@ -63,52 +56,66 @@ const Spinner = props => {
6356 ...fullscreen_style
6457 } ;
6558
66- const coveringStyle = {
67- visibility : 'visible'
68- } ;
69-
70- const hiddenStyle = {
71- visibility : 'hidden' ,
72- position : 'relative' ,
73- display : 'inline-block'
74- } ;
75-
59+ const SpinnerDiv = style => (
60+ < RSSpinner
61+ color = { isSpinnerColor ? color : null }
62+ style = { { color : ! isSpinnerColor && color , ...style } }
63+ className = { spinnerClassName }
64+ { ...omit ( [ 'setProps' ] , otherProps ) }
65+ />
66+ ) ;
7667 // Defaulted styles above to the situation where spinner has no children
7768 // now include properties if spinner has children
7869 if ( children ) {
7970 // include covering style additions
80- coveringStyle . position = 'absolute' ;
81- coveringStyle . top = 0 ;
82- coveringStyle . height = '100%' ;
83- coveringStyle . width = '100%' ;
84- coveringStyle . display = 'flex' ;
85- coveringStyle . justifyContent = 'center' ;
86- coveringStyle . alignItems = 'center' ;
87-
88- // remove hidden style additions
89- delete hiddenStyle . display ;
71+ const coveringStyle = {
72+ visibility : 'visible' ,
73+ position : 'absolute' ,
74+ top : 0 ,
75+ height : '100%' ,
76+ width : '100%' ,
77+ display : 'flex' ,
78+ justifyContent : 'center' ,
79+ alignItems : 'center'
80+ } ;
81+
82+ const hiddenStyle = {
83+ visibility : 'hidden' ,
84+ position : 'relative'
85+ } ;
86+
87+ const spinnerStyle = {
88+ display : 'block' ,
89+ margin : '1rem auto' ,
90+ ...spinner_style
91+ } ;
92+
93+ const showSpinner = loading_state && loading_state . is_loading ;
94+
95+ return (
96+ < div style = { showSpinner ? hiddenStyle : { } } >
97+ { children }
98+ { showSpinner && (
99+ < div
100+ style = { fullscreen ? fullscreenStyle : coveringStyle }
101+ className = { fullscreen && fullscreenClassName }
102+ >
103+ < SpinnerDiv style = { spinnerStyle } />
104+ </ div >
105+ ) }
106+ </ div >
107+ ) ;
90108 }
91109
92- const showSpinner = ! children || ( loading_state && loading_state . is_loading ) ;
93-
94- return (
95- < div style = { showSpinner ? hiddenStyle : { } } >
96- { children }
97- { showSpinner && (
98- < div
99- style = { fullscreen ? fullscreenStyle : coveringStyle }
100- className = { fullscreen && fullscreenClassName }
101- >
102- < RSSpinner
103- color = { isSpinnerColor ? color : null }
104- style = { { color : ! isSpinnerColor && color , ...spinnerStyle } }
105- className = { spinnerClassName }
106- { ...omit ( [ 'setProps' ] , otherProps ) }
107- />
108- </ div >
109- ) }
110- </ div >
111- ) ;
110+ if ( fullscreen ) {
111+ return (
112+ < div className = { fullscreenClassName } style = { fullscreenStyle } >
113+ < SpinnerDiv style = { spinner_style } />
114+ </ div >
115+ ) ;
116+ }
117+
118+ return < SpinnerDiv style = { spinner_style } /> ;
112119} ;
113120
114121Spinner . _dashprivate_isLoadingComponent = true ;
0 commit comments