Skip to content

Commit

Permalink
Consolidate approach of hidden containers
Browse files Browse the repository at this point in the history
  • Loading branch information
huong-li-nguyen committed Nov 1, 2023
1 parent 3c96779 commit f8fb5d7
Show file tree
Hide file tree
Showing 18 changed files with 18 additions and 22 deletions.
2 changes: 1 addition & 1 deletion vizro-core/docs/pages/user_guides/custom_components.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ vm.Parameter.add_type("selector", TooltipNonCrossRangeSlider)

return html.Div(
[
html.P(self.title, id="range_slider_title") if self.title else None,
html.P(self.title, id="range_slider_title") if self.title else html.Div(hidden=True),
html.Div(
[
dcc.RangeSlider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _get_action_loop_components() -> html.Div:
components = [
dcc.Store(id="action_finished"),
dcc.Store(id="remaining_actions", data=[]),
html.Div(id="cycle_breaker_div", style={"display": "hidden"}),
html.Div(id="cycle_breaker_div", hidden=True),
dcc.Store(id="cycle_breaker_empty_output_store"),
]

Expand Down
2 changes: 1 addition & 1 deletion vizro-core/src/vizro/models/_components/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def build(self):
className="button_container",
)
if self.href
else None
else html.Div(hidden=True)
)
card_container = "nav_card_container" if self.href else "card_container"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class UserInput(VizroBaseModel):
def build(self):
return html.Div(
[
html.P(self.title) if self.title else None,
html.P(self.title) if self.title else html.Div(hidden=True),
dbc.Input(
id=self.id,
placeholder=self.placeholder,
Expand Down
2 changes: 1 addition & 1 deletion vizro-core/src/vizro/models/_components/form/checklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def build(self):

return html.Div(
[
html.P(self.title) if self.title else None,
html.P(self.title) if self.title else html.Div(hidden=True),
dcc.Checklist(
id=self.id,
options=full_options,
Expand Down
2 changes: 1 addition & 1 deletion vizro-core/src/vizro/models/_components/form/dropdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def build(self):
full_options, default_value = get_options_and_default(options=self.options, multi=self.multi)
return html.Div(
[
html.P(self.title) if self.title else None,
html.P(self.title) if self.title else html.Div(hidden=True),
dcc.Dropdown(
id=self.id,
options=full_options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def build(self):

return html.Div(
[
html.P(self.title) if self.title else None,
html.P(self.title) if self.title else html.Div(hidden=True),
dcc.RadioItems(
id=self.id,
options=full_options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def build(self):
"max": self.max,
},
),
html.P(self.title) if self.title else None,
html.P(self.title) if self.title else html.Div(hidden=True),
html.Div(
[
dcc.RangeSlider(
Expand Down
2 changes: 1 addition & 1 deletion vizro-core/src/vizro/models/_components/form/slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def build(self):
"max": self.max,
},
),
html.P(self.title) if self.title else None,
html.P(self.title) if self.title else html.Div(hidden=True),
html.Div(
[
dcc.Slider(
Expand Down
2 changes: 1 addition & 1 deletion vizro-core/src/vizro/models/_components/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def build(self):
return dcc.Loading(
html.Div(
[
html.H3(self.title, className="table-title") if self.title else None,
html.H3(self.title, className="table-title") if self.title else html.Div(hidden=True),
html.Div(dash_table.DataTable(), id=self.id),
],
className="table-container",
Expand Down
4 changes: 2 additions & 2 deletions vizro-core/src/vizro/models/_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def _make_page_layout(self, page: Page):
dashboard_title = (
html.Div(children=[html.H2(self.title), html.Hr()], className="dashboard_title", id="dashboard_title_outer")
if self.title
else html.Div(className="hidden", id="dashboard_title_outer")
else html.Div(hidden=True, id="dashboard_title_outer")
)
theme_switch = daq.BooleanSwitch(
id="theme_selector", on=True if self.theme == "vizro_dark" else False, persistence=True
Expand All @@ -122,7 +122,7 @@ def _make_page_layout(self, page: Page):
left_side = (
html.Div(children=left_side_elements, className="left_side", id="left_side_outer")
if any(left_side_elements)
else html.Div(className="hidden", id="left_side_outer")
else html.Div(hidden=True, id="left_side_outer")
)
right_side = html.Div(children=[header, component_container], className="right_side", id="right_side_outer")
return html.Div([left_side, right_side], className="page_container", id="page_container_outer")
Expand Down
2 changes: 1 addition & 1 deletion vizro-core/src/vizro/models/_navigation/_accordion.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def coerce_pages_type(cls, pages):
def build(self, *, active_page_id=None):
# Hide navigation panel if there is only one page
if len(list(itertools.chain(*self.pages.values()))) == 1:
return html.Div(className="hidden")
return html.Div(hidden=True)

accordion_items = []
for page_group, page_members in self.pages.items():
Expand Down
2 changes: 1 addition & 1 deletion vizro-core/src/vizro/models/_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def build(self):
control_panel = (
html.Div(children=[*controls_content, html.Hr()], className="control_panel", id="control_panel_outer")
if controls_content
else html.Div(className="hidden", id="control_panel_outer")
else html.Div(hidden=True, id="control_panel_outer")
)
components_content = [
html.Div(
Expand Down
4 changes: 0 additions & 4 deletions vizro-core/src/vizro/static/css/layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@
width: 100%;
}

.hidden {
display: none;
}

.loading-container {
height: 100%;
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def fundamental_components():
return [
dcc.Store(id="action_finished"),
dcc.Store(id="remaining_actions", data=[]),
html.Div(id="cycle_breaker_div", style={"display": "hidden"}),
html.Div(id="cycle_breaker_div", hidden=True),
dcc.Store(id="cycle_breaker_empty_output_store"),
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def expected_range_slider_default():
"max": None,
},
),
None,
html.Div(hidden=True),
html.Div(
[
dcc.RangeSlider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def expected_table():
return dcc.Loading(
html.Div(
[
None,
html.Div(hidden=True),
html.Div(dash_table.DataTable(), id="text_table"),
],
className="table-container",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ def test_accordion_build_pages_as_dict(self, pages_as_dict, accordion_from_pages
def test_single_page_and_hidden_div(self):
accordion = Accordion(pages=["Page 1"]).build()
result = json.loads(json.dumps(accordion, cls=plotly.utils.PlotlyJSONEncoder))
expected = json.loads(json.dumps(html.Div(className="hidden"), cls=plotly.utils.PlotlyJSONEncoder))
expected = json.loads(json.dumps(html.Div(hidden=True), cls=plotly.utils.PlotlyJSONEncoder))
assert result == expected

0 comments on commit f8fb5d7

Please sign in to comment.