Skip to content

Commit b5b9710

Browse files
committed
Added overlay_style prop removed opacity and backgroundColor props
1 parent 27c3498 commit b5b9710

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

components/dash-core-components/src/components/Loading.react.js

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@ import CircleSpinner from '../fragments/Loading/spinners/CircleSpinner.jsx';
77
import DotSpinner from '../fragments/Loading/spinners/DotSpinner.jsx';
88
import {mergeRight} from 'ramda';
99

10-
const spinnerComponents = {
10+
const spinnerComponentOptions = {
1111
graph: GraphSpinner,
1212
cube: CubeSpinner,
1313
circle: CircleSpinner,
1414
dot: DotSpinner,
1515
};
1616

1717
const getSpinner = spinnerType =>
18-
spinnerComponents[spinnerType] || DefaultSpinner;
19-
20-
const hiddenContainer = {position: 'relative'};
18+
spinnerComponentOptions[spinnerType] || DefaultSpinner;
2119

2220
/**
2321
* A Loading component that wraps any other component and displays a spinner until the wrapped component has rendered.
@@ -30,14 +28,13 @@ const Loading = ({
3028
style,
3129
parent_className,
3230
parent_style,
31+
overlay_style,
3332
fullscreen,
3433
debug,
3534
show_initially,
3635
type: spinnerType,
3736
delay_hide,
3837
delay_show,
39-
opacity,
40-
backgroundColor,
4138
target_components,
4239
custom_spinner,
4340
}) => {
@@ -50,10 +47,16 @@ const Loading = ({
5047
display: 'flex',
5148
justifyContent: 'center',
5249
alignItems: 'center',
53-
backgroundColor: backgroundColor,
54-
opacity: opacity,
5550
};
51+
const hiddenContainer = mergeRight(
52+
{visibility: 'hidden', position: 'relative'},
53+
overlay_style
54+
);
5655

56+
/* Overrides default Loading behavior if target_components is set. By default,
57+
* Loading fires when any recursive child enters loading state. This makes loading
58+
* opt-in: Loading animation only enabled when one of target components enters loading state.
59+
*/
5760
const isTarget = () => {
5861
if (!target_components) {
5962
return true;
@@ -144,8 +147,6 @@ Loading.defaultProps = {
144147
delay_show: 0,
145148
delay_hide: 0,
146149
show_initially: true,
147-
opacity: 0.5,
148-
backgroundColor: 'white',
149150
};
150151

151152
Loading.propTypes = {
@@ -200,22 +201,16 @@ Loading.propTypes = {
200201
* Additional CSS styling for the outermost dcc.Loading parent div DOM node
201202
*/
202203
parent_style: PropTypes.object,
203-
204204
/**
205-
* Primary color used for the loading spinners
205+
* Additional CSS styling for the spinner overlay. This is applied to the
206+
* dcc.Loading children while the spinner is active. The default is {'visibility': 'hidden'}
206207
*/
207-
color: PropTypes.string,
208+
overlay_style: PropTypes.object,
208209

209210
/**
210-
* Opacity of loading Spinner div. Can take a value from 0.0 - 1.0. The lower
211-
* the value, the more transparent:
212-
*/
213-
opacity: PropTypes.number,
214-
215-
/**
216-
* Background color of the loading Spinner div
211+
* Primary color used for the loading spinners
217212
*/
218-
backgroundColor: PropTypes.string,
213+
color: PropTypes.string,
219214

220215
/**
221216
* Object that holds the loading state object coming from dash-renderer

0 commit comments

Comments
 (0)