Skip to content

Commit

Permalink
Make layout children a list
Browse files Browse the repository at this point in the history
  • Loading branch information
antonymilne committed Jan 20, 2025
1 parent 7205e85 commit 0e5c86b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 18 deletions.
1 change: 1 addition & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
**/static/css/vizro-bootstrap.min.css
**/static/css/vizro-bootstrap.min.css.map
**/static/css/mantine_dates.css
2 changes: 1 addition & 1 deletion vizro-core/examples/dev/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,6 @@ def multiple_cards(data_frame: pd.DataFrame, n_rows: Optional[int] = 1) -> html.
target="_blank",
className="anchor-container",
)
app.dash.layout.children = [app.dash.layout.children, banner]
app.dash.layout.children.append(banner)
server = app.dash.server
app.run()
1 change: 0 additions & 1 deletion vizro-core/src/vizro/_vizro.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from typing import TYPE_CHECKING, TypedDict, cast

import dash
import dash_mantine_components as dmc
import plotly.io as pio
from dash.development.base_component import ComponentRegistry
from flask_caching import SimpleCache
Expand Down
6 changes: 5 additions & 1 deletion vizro-core/src/vizro/models/_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,12 @@ def build(self):
dash.page_container,
],
)

# children=[layout] as a list rather than children=layout, so that app.dash.layout.children.append works to
# easily add things to the Dash layout. In future we might have a neater function for patching components into
# the Dash layout in which case this could change.
return dmc.MantineProvider(
layout,
children=[layout],
# Use the `theme` to style all Mantine components with a Vizro theme. For more info see https://www.dash-mantine-components.com/components/mantineprovider
theme={"primaryColor": "gray"},
)
Expand Down
32 changes: 17 additions & 15 deletions vizro-core/tests/unit/vizro/models/test_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,21 +277,23 @@ def test_dashboard_build(self, vizro_app, page_1, page_2):
)

expected_dashboard_container = dmc.MantineProvider(
html.Div(
id="dashboard-container",
children=[
html.Div(id="vizro_version", children=vizro.__version__, hidden=True),
dcc.Store(
id="vizro_themes",
data={
"vizro_dark": dashboard_vizro_dark,
"vizro_light": dashboard_vizro_light,
},
),
ActionLoop._create_app_callbacks(),
dash.page_container,
],
),
children=[
html.Div(
id="dashboard-container",
children=[
html.Div(id="vizro_version", children=vizro.__version__, hidden=True),
dcc.Store(
id="vizro_themes",
data={
"vizro_dark": dashboard_vizro_dark,
"vizro_light": dashboard_vizro_light,
},
),
ActionLoop._create_app_callbacks(),
dash.page_container,
],
)
],
theme={"primaryColor": "gray"},
)
assert_component_equal(dashboard.build(), expected_dashboard_container)
Expand Down

0 comments on commit 0e5c86b

Please sign in to comment.