Skip to content

Commit

Permalink
Add collapsible option to
Browse files Browse the repository at this point in the history
  • Loading branch information
HansKallekleiv committed Oct 21, 2021
1 parent 8f2df22 commit 93214d9
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions webviz_core_components/wrapped_components/select_with_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ class SelectWithLabel(html.Div):
- label (string; optional):
The text of the label
- collapsible (bool; optional):
Wraps the select in a collapsible box
- open_details (bool; default True):
Used to set initial opened/closed state if the collapsible box is used
- wrapper_id (string; optional):
Id of the wrapping div
Expand All @@ -33,6 +39,8 @@ class SelectWithLabel(html.Div):
def __init__(
self,
label: str = None,
collapsible: bool = False,
open_details: bool = True,
wrapper_id: str = None,
persistence: bool = True,
persistence_type: str = "session",
Expand All @@ -41,12 +49,21 @@ def __init__(
super().__init__()
if wrapper_id is not None:
self.id = wrapper_id
children = [html.Label(label)] if label else []
if collapsible:
children = [html.Summary(label)] if label else []
else:
children = [html.Label(label)] if label else []
children.append(
BaseSelect(
persistence=persistence,
persistence_type=persistence_type,
**kwargs,
)
)
self.children = html.Div(style={"fontSize": "15px"}, children=children)
if collapsible:
self.children = html.Div(
style={"fontSize": "15px"},
children=html.Details(open=open_details, children=children),
)
else:
self.children = html.Div(style={"fontSize": "15px"}, children=children)

0 comments on commit 93214d9

Please sign in to comment.