Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Card to ControlType and enable horizontal rulers #85

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!--
A new scriv changelog fragment.

Uncomment the section that is right (remove the HTML comment wrapper).
-->

<!--
### Removed

- A bullet item for the Removed category.

-->
<!--
### Added

- A bullet item for the Added category.

-->
<!--
### Changed

- A bullet item for the Changed category.

-->
<!--
### Deprecated

- A bullet item for the Deprecated category.

-->
<!--
### Fixed

- A bullet item for the Fixed category.

-->
<!--
### Security

- A bullet item for the Security category.

-->
4 changes: 4 additions & 0 deletions vizro-core/examples/assets/css/card.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
div.left_side .card_container {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes will be reverted here - just for demo purposes on how control group headers can be styled

background-color: var(--surfaces-bg-02);
padding: 0;
}
24 changes: 24 additions & 0 deletions vizro-core/examples/default/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,18 +299,42 @@ def create_relation_analysis():
),
],
controls=[
vm.Card(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes will be reverted here - just for demo purposes on how control group headers could be created

text="""
#### Group A

***

""",
),
vm.Parameter(
targets=["scatter_relation_2007.x", "scatter_relation.x"],
selector=vm.Dropdown(
options=["lifeExp", "gdpPercap", "pop"], multi=False, value="gdpPercap", title="Choose x-axis"
),
),
vm.Card(
text="""
#### Group B

___

""",
),
vm.Parameter(
targets=["scatter_relation_2007.y", "scatter_relation.y", "bar_relation_2007.y"],
selector=vm.Dropdown(
options=["lifeExp", "gdpPercap", "pop"], multi=False, value="lifeExp", title="Choose y-axis"
),
),
vm.Card(
text="""
#### Group C

---

""",
),
vm.Parameter(
targets=["scatter_relation_2007.size", "scatter_relation.size"],
selector=vm.Dropdown(
Expand Down
4 changes: 2 additions & 2 deletions vizro-core/src/vizro/models/_navigation/_accordion.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _create_default_accordion(self):
persistence=True,
persistence_type="session",
),
html.Div(className="keyline"),
html.Hr(),
],
className="nav_panel",
id=f"{self.id}_outer",
Expand Down Expand Up @@ -108,7 +108,7 @@ def _create_accordion(self):
persistence=True,
persistence_type="session",
),
html.Div(className="keyline"),
html.Hr(),
],
className="nav_panel",
id=f"{self.id}_outer",
Expand Down
7 changes: 2 additions & 5 deletions vizro-core/src/vizro/models/_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,8 @@ def _create_theme_switch():

@staticmethod
def _create_control_panel(controls_content):
keyline = html.Div(className="keyline")
control_panel = html.Div(
children=[*controls_content, keyline],
children=[*controls_content, html.Hr()],
className="control_panel",
)
return control_panel if controls_content else None
Expand Down Expand Up @@ -202,9 +201,7 @@ def _arrange_containers(page_title, theme_switch, nav_panel, control_panel, comp
"""
_, dashboard = next(model_manager._items_with_type(Dashboard))
dashboard_title = (
html.Div(
children=[html.H2(dashboard.title), html.Div(className="keyline")], className="dashboard_title_outer"
)
html.Div(children=[html.H2(dashboard.title), html.Hr()], className="dashboard_title_outer")
if dashboard.title
else None
)
Expand Down
2 changes: 1 addition & 1 deletion vizro-core/src/vizro/models/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ class OptionsDictType(TypedDict):
]

ControlType = Annotated[
Union["Filter", "Parameter"],
Union["Card", "Filter", "Parameter"],
Field(
discriminator="type",
description="Control that affects components on the page.",
Expand Down
2 changes: 1 addition & 1 deletion vizro-core/src/vizro/static/css/layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
width: 336px;
}

.keyline {
hr {
border-bottom: 1px solid var(--border-subtle-alpha-01);
width: 100%;
}
Expand Down
4 changes: 2 additions & 2 deletions vizro-core/tests/unit/vizro/models/_navigation/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def accordion_from_page_as_list():
persistence=True,
persistence_type="session",
),
html.Div(className="keyline"),
html.Hr(),
],
className="nav_panel",
id="accordion_list_outer",
Expand Down Expand Up @@ -86,7 +86,7 @@ def accordion_from_pages_as_dict():
persistence=True,
persistence_type="session",
),
html.Div(className="keyline"),
html.Hr(),
],
className="nav_panel",
id="accordion_dict_outer",
Expand Down
Loading