Skip to content

Commit

Permalink
Rename _all_hidden function
Browse files Browse the repository at this point in the history
  • Loading branch information
huong-li-nguyen committed Dec 21, 2023
1 parent 6fac9d7 commit 5bc310d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions vizro-core/src/vizro/models/_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import logging
from functools import partial
from typing import TYPE_CHECKING, List, Literal, TypedDict
from typing import TYPE_CHECKING, List, Literal, TypedDict, Any

import dash
import dash_bootstrap_components as dbc
Expand All @@ -28,9 +28,9 @@
logger = logging.getLogger(__name__)


def _is_hidden(components: List[html.Div]):
def _all_hidden(components: List[Any]):
"""Returns True if all components are either None and/or have hidden=True."""
return all(div is None or getattr(div, "hidden", False) for div in components)
return all(component is None or getattr(component, "hidden", False) for component in components)


# This is just used for type checking. Ideally it would inherit from some dash.development.base_component.Component
Expand Down Expand Up @@ -152,13 +152,13 @@ def _arrange_page_divs(self, page_divs: _PageDivsType):
left_header_divs = [page_divs["dashboard-title"]]
left_sidebar_divs = [page_divs["nav-bar"]]
left_main_divs = [
html.Div(left_header_divs, id="left-header", hidden=_is_hidden(left_header_divs)),
html.Div(left_header_divs, id="left-header", hidden=_all_hidden(left_header_divs)),
page_divs["nav-panel"],
page_divs["control-panel"],
]

left_sidebar = html.Div(left_sidebar_divs, id="left-sidebar", hidden=_is_hidden(left_sidebar_divs))
left_main = html.Div(left_main_divs, id="left-main", hidden=_is_hidden(left_main_divs))
left_sidebar = html.Div(left_sidebar_divs, id="left-sidebar", hidden=_all_hidden(left_sidebar_divs))
left_main = html.Div(left_main_divs, id="left-main", hidden=_all_hidden(left_main_divs))
left_side = html.Div([left_sidebar, left_main], id="left-side")

right_header = html.Div([page_divs["page-title"], page_divs["settings"]], id="right-header")
Expand Down
4 changes: 2 additions & 2 deletions vizro-core/tests/unit/vizro/models/test_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import vizro
import vizro.models as vm
from vizro.actions._action_loop._action_loop import ActionLoop
from vizro.models._dashboard import _is_hidden
from vizro.models._dashboard import _all_hidden


class TestDashboardInstantiation:
Expand Down Expand Up @@ -169,4 +169,4 @@ def test_dashboard_build(self, vizro_app, page_1, page_2):
],
)
def test_get_hideable_parent_div_visible(components, expected):
assert _is_hidden(components) == expected
assert _all_hidden(components) == expected

0 comments on commit 5bc310d

Please sign in to comment.