Skip to content

Commit 59e9add

Browse files
authored
Merge branch 'dev' into fix_lint_black
2 parents 958ea3d + b7b3c5c commit 59e9add

File tree

7 files changed

+414
-238
lines changed

7 files changed

+414
-238
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ build/
33
dist/
44
lib/
55
lib/bundle.js*
6+
Project.toml
67
coverage/
78
node_modules/
89
.npm
@@ -18,8 +19,10 @@ venv/
1819
/build
1920
/dash_core_components
2021
dash_core_components_base/plotly.min.js
22+
/deps
2123
/inst
2224
/man
2325
/R
26+
/src/*.jl
2427
DESCRIPTION
2528
NAMESPACE

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [1.11.0] - 2020-08-25
6+
### Added
7+
- [#851](https://github.com/plotly/dash-core-components/pull/851) Add support for Dash.jl Julia built components
8+
- [#840](https://github.com/plotly/dash-core-components/pull/840) Add styling properties to `dcc.Loading` component
9+
+ `parent_className`: Add CSS class for the outermost `dcc.Loading` parent div DOM node
10+
+ `parent_style`: Add CSS style property for the outermost `dcc.Loading` parent div DOM node
11+
+ provides a workaround for the previous behaviour the of `className` property, which changed in [#740](https://github.com/plotly/dash-core-components/pull/740). `parent_className` (or inline styles in `parent_style`) now allow CSS rules to be applied to the outermost `dcc.Loading` div, which is no longer covered by `className` on loading completion as of Dash Core Components `>= 1.9.1` (Dash `>= 1.11.0`).
12+
513
## [1.10.2] - 2020-07-27
614
- [#835](https://github.com/plotly/dash-core-components/pull/835)
715
- Upgraded Plotly.js to [1.54.7](https://github.com/plotly/plotly.js/releases/tag/v1.54.7)

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dash-core-components",
3-
"version": "1.10.2",
3+
"version": "1.11.0",
44
"description": "Core component suite for Dash",
55
"repository": {
66
"type": "git",
@@ -21,16 +21,16 @@
2121
"private::lint.prettier": "prettier --config .prettierrc src/**/*.js tests/unit/*.js --list-different",
2222
"prepublishOnly": "rm -rf lib && babel src --out-dir lib --copy-files",
2323
"start": "webpack-serve ./webpack.serve.config.js --open",
24-
"test": "run-s -c lint lint:py format:test test-unit test:legacy test:intg test:pyimport",
24+
"test": "run-s -c lint test-unit test:legacy test:intg test:pyimport",
2525
"test:legacy": "pytest tests/test_integration*.py",
2626
"test:intg": "pytest --nopercyfinalize --headless tests/integration",
2727
"test:pyimport": "python -m unittest tests/test_dash_import.py",
2828
"test-unit": "jest",
2929
"uninstall-local": "pip uninstall dash-core-components -y",
3030
"prebuild:js": "cp node_modules/plotly.js/dist/plotly.min.js dash_core_components_base/plotly.min.js",
3131
"build:js": "webpack --mode production",
32-
"build:py_and_r": "dash-generate-components ./src/components dash_core_components -p package-info.json && cp dash_core_components_base/** dash_core_components/ && dash-generate-components ./src/components dash_core_components -p package-info.json --r-prefix 'dcc' --r-suggests 'dash,dashHtmlComponents,jsonlite,plotly'",
33-
"build": "run-s prepublishOnly build:js build:py_and_r",
32+
"build:backends": "dash-generate-components ./src/components dash_core_components -p package-info.json && cp dash_core_components_base/** dash_core_components/ && dash-generate-components ./src/components dash_core_components -p package-info.json --r-prefix 'dcc' --r-suggests 'dash,dashHtmlComponents,jsonlite,plotly' --jl-prefix 'dcc'",
33+
"build": "run-s prepublishOnly build:js build:backends",
3434
"postbuild": "es-check es5 dash_core_components/*.js",
3535
"build:watch": "watch 'npm run build' src",
3636
"format": "run-s private::format.*",

src/components/Loading.react.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import DefaultSpinner from '../fragments/Loading/spinners/DefaultSpinner.jsx';
55
import CubeSpinner from '../fragments/Loading/spinners/CubeSpinner.jsx';
66
import CircleSpinner from '../fragments/Loading/spinners/CircleSpinner.jsx';
77
import DotSpinner from '../fragments/Loading/spinners/DotSpinner.jsx';
8+
import {mergeRight} from 'ramda';
89

910
function getSpinner(spinnerType) {
1011
switch (spinnerType) {
@@ -44,6 +45,8 @@ export default class Loading extends Component {
4445
color,
4546
className,
4647
style,
48+
parent_className,
49+
parent_style,
4750
fullscreen,
4851
debug,
4952
type: spinnerType,
@@ -53,7 +56,14 @@ export default class Loading extends Component {
5356
const Spinner = isLoading && getSpinner(spinnerType);
5457

5558
return (
56-
<div style={isLoading ? hiddenContainer : {}}>
59+
<div
60+
className={parent_className}
61+
style={
62+
isLoading
63+
? mergeRight(hiddenContainer, parent_style)
64+
: parent_style
65+
}
66+
>
5767
{this.props.children}
5868
<div style={isLoading ? coveringSpinner : {}}>
5969
{isLoading && (
@@ -117,11 +127,21 @@ Loading.propTypes = {
117127
*/
118128
className: PropTypes.string,
119129

130+
/**
131+
* Additional CSS class for the outermost dcc.Loading parent div DOM node
132+
*/
133+
parent_className: PropTypes.string,
134+
120135
/**
121136
* Additional CSS styling for the spinner root DOM node
122137
*/
123138
style: PropTypes.object,
124139

140+
/**
141+
* Additional CSS styling for the outermost dcc.Loading parent div DOM node
142+
*/
143+
parent_style: PropTypes.object,
144+
125145
/**
126146
* Primary colour used for the loading spinners
127147
*/

tests/integration/loading/test_loading_component.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,88 @@ def get_graph_visibility():
278278
assert len(dash_dcc.find_elements(".js-plotly-plot .bars path")) == 4
279279
assert dash_dcc.driver.execute_script(test_identity)
280280
assert get_graph_visibility() == "visible"
281+
282+
283+
def test_ldcp007_class_and_style_props(dash_dcc):
284+
lock = Lock()
285+
286+
app = dash.Dash(__name__)
287+
288+
app.layout = html.Div(
289+
[
290+
html.Button("click", id="btn"),
291+
dcc.Loading(
292+
id="loading",
293+
className="spinner-class",
294+
parent_className="parent-class",
295+
style={"background-color": "rgb(255,192,203)"},
296+
# rgb(240, 248, 255) = aliceblue
297+
parent_style={"border": "3px solid rgb(240, 248, 255)"},
298+
children=html.Div(id="loading-child"),
299+
),
300+
]
301+
)
302+
303+
@app.callback(Output("loading-child", "children"), [Input("btn", "n_clicks")])
304+
def updateDiv(n_clicks):
305+
if n_clicks is None:
306+
return
307+
308+
with lock:
309+
return "sample text content"
310+
311+
dash_dcc.start_server(app)
312+
313+
dash_dcc.wait_for_style_to_equal(
314+
".parent-class", "border-color", "rgb(240, 248, 255)"
315+
)
316+
317+
with lock:
318+
button = dash_dcc.find_element("#btn")
319+
button.click()
320+
dash_dcc.wait_for_style_to_equal(
321+
".spinner-class", "background-color", "rgba(255, 192, 203, 1)"
322+
)
323+
324+
assert not dash_dcc.get_logs()
325+
326+
327+
def test_ldcp008_graph_in_loading_fits_container_height(dash_dcc):
328+
lock = Lock()
329+
330+
app = dash.Dash(__name__)
331+
332+
app.layout = html.Div(
333+
className="outer-container",
334+
children=[
335+
html.Div(
336+
dcc.Loading(
337+
parent_style={"height": "100%"},
338+
children=dcc.Graph(
339+
style={"height": "100%"},
340+
figure={
341+
"data": [
342+
{
343+
"x": [1, 2, 3, 4],
344+
"y": [4, 1, 6, 9],
345+
"line": {"shape": "spline"},
346+
}
347+
]
348+
},
349+
),
350+
),
351+
)
352+
],
353+
style={"display": "flex", "height": "300px"},
354+
)
355+
356+
dash_dcc.start_server(app)
357+
358+
with lock:
359+
dash_dcc.wait_for_style_to_equal(".js-plotly-plot", "height", "300px")
360+
361+
assert dash_dcc.wait_for_element(".js-plotly-plot").size.get(
362+
"height"
363+
) == dash_dcc.wait_for_element(".outer-container").size.get("height")
364+
365+
assert not dash_dcc.get_logs()

0 commit comments

Comments
 (0)