From 12f0b0e5d4ade2b570d507acc4af70a566f590ba Mon Sep 17 00:00:00 2001 From: huong-li-nguyen Date: Wed, 27 Sep 2023 16:39:29 +0200 Subject: [PATCH 01/10] Add Button ControlType --- ...63719_huong_li_nguyen_button_as_control.md | 41 +++++++++++++++++++ vizro-core/schemas/0.1.3.dev0.json | 4 ++ vizro-core/src/vizro/models/types.py | 2 +- 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 vizro-core/changelog.d/20230927_163719_huong_li_nguyen_button_as_control.md diff --git a/vizro-core/changelog.d/20230927_163719_huong_li_nguyen_button_as_control.md b/vizro-core/changelog.d/20230927_163719_huong_li_nguyen_button_as_control.md new file mode 100644 index 000000000..7ed6c5e65 --- /dev/null +++ b/vizro-core/changelog.d/20230927_163719_huong_li_nguyen_button_as_control.md @@ -0,0 +1,41 @@ + + + + +### Changed + +- Add `Button` to `ControlType` + + + + \ No newline at end of file diff --git a/vizro-core/schemas/0.1.3.dev0.json b/vizro-core/schemas/0.1.3.dev0.json index ad89ca9e6..29b1d1516 100644 --- a/vizro-core/schemas/0.1.3.dev0.json +++ b/vizro-core/schemas/0.1.3.dev0.json @@ -826,11 +826,15 @@ "discriminator": { "propertyName": "type", "mapping": { + "button": "#/definitions/Button", "filter": "#/definitions/Filter", "parameter": "#/definitions/Parameter" } }, "oneOf": [ + { + "$ref": "#/definitions/Button" + }, { "$ref": "#/definitions/Filter" }, diff --git a/vizro-core/src/vizro/models/types.py b/vizro-core/src/vizro/models/types.py index 6ba038e05..257c9a6bb 100644 --- a/vizro-core/src/vizro/models/types.py +++ b/vizro-core/src/vizro/models/types.py @@ -255,7 +255,7 @@ class OptionsDictType(TypedDict): ] ControlType = Annotated[ - Union["Filter", "Parameter"], + Union["Button", "Filter", "Parameter"], Field( discriminator="type", description="Control that affects components on the page.", From 4df13c6be71ac51c416c4240163e9e3e48490b9a Mon Sep 17 00:00:00 2001 From: huong-li-nguyen Date: Wed, 27 Sep 2023 16:40:27 +0200 Subject: [PATCH 02/10] Fix authors file --- vizro-core/docs/pages/development/authors.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vizro-core/docs/pages/development/authors.md b/vizro-core/docs/pages/development/authors.md index 5af936c38..1e1b1c670 100644 --- a/vizro-core/docs/pages/development/authors.md +++ b/vizro-core/docs/pages/development/authors.md @@ -10,12 +10,12 @@ [Maximilian Schulz](https://github.com/maxschulz-COL), [Huong Li Nguyen](https://github.com/huong-li-nguyen), [Dan Dumitriu](https://github.com/dandumitriu1), -[Joseph Perkins](https://github.com/Joseph-Perkins), +[Joseph Perkins](https://github.com/Joseph-Perkins) ## Previous team members and code contributors -[Jo Stichbury](https://github.com/stichbury) -[Juan Luis Cano Rodríguez](https://github.com/astrojuanlu) +[Jo Stichbury](https://github.com/stichbury), +[Juan Luis Cano Rodríguez](https://github.com/astrojuanlu), [Denis Lebedev](https://github.com/DenisLebedevMcK), [Qiuyi Chen](https://github.com/Qiuyi-Chen), [Elena Fridman](https://github.com/EllenWie), From c13791168887c2463ad81de313c3034e3f137294 Mon Sep 17 00:00:00 2001 From: huong-li-nguyen Date: Wed, 27 Sep 2023 16:59:25 +0200 Subject: [PATCH 03/10] Add tests for ComponentType and ControlType --- ..._163719_huong_li_nguyen_button_as_control.md | 3 ++- vizro-core/tests/unit/vizro/models/test_page.py | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/vizro-core/changelog.d/20230927_163719_huong_li_nguyen_button_as_control.md b/vizro-core/changelog.d/20230927_163719_huong_li_nguyen_button_as_control.md index 7ed6c5e65..784b4c7f3 100644 --- a/vizro-core/changelog.d/20230927_163719_huong_li_nguyen_button_as_control.md +++ b/vizro-core/changelog.d/20230927_163719_huong_li_nguyen_button_as_control.md @@ -17,6 +17,7 @@ Uncomment the section that is right (remove the HTML comment wrapper). --> + ### Changed - Add `Button` to `ControlType` @@ -38,4 +39,4 @@ Uncomment the section that is right (remove the HTML comment wrapper). - A bullet item for the Security category. ---> \ No newline at end of file +--> diff --git a/vizro-core/tests/unit/vizro/models/test_page.py b/vizro-core/tests/unit/vizro/models/test_page.py index bbc9ef5a5..5b3f054c5 100644 --- a/vizro-core/tests/unit/vizro/models/test_page.py +++ b/vizro-core/tests/unit/vizro/models/test_page.py @@ -86,6 +86,23 @@ def test_set_layout_invalid(self): with pytest.raises(ValidationError, match="Number of page and grid components need to be the same."): vm.Page(title="Page 4", components=[vm.Button()], layout=vm.Layout(grid=[[0, 1]])) + def test_valid_component_types(self, standard_px_chart): + vm.Page( + title="Page Title", + components=[vm.Graph(figure=standard_px_chart), vm.Card(text="""# Header 1"""), vm.Button()], + ) + + def test_valid_control_types(self, standard_px_chart): + vm.Page( + title="Page Title", + components=[vm.Graph(id="scatter", figure=standard_px_chart)], + controls=[ + vm.Filter(column="continent"), + vm.Parameter(targets=["scatter.x"], selector=vm.RadioItems(options=["lifeExp", "pop", "gdpPercap"])), + vm.Button(text="Click me!"), + ], + ) + # TODO: Remove this if we can get rid of on-page-load action class TestPagePreBuildMethod: From 4349425a9c8795d36d2508a29e1ce7cc1ce353ee Mon Sep 17 00:00:00 2001 From: huong-li-nguyen Date: Wed, 27 Sep 2023 17:00:47 +0200 Subject: [PATCH 04/10] Clean tests --- vizro-core/tests/unit/vizro/models/test_page.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vizro-core/tests/unit/vizro/models/test_page.py b/vizro-core/tests/unit/vizro/models/test_page.py index 5b3f054c5..3cf696ce2 100644 --- a/vizro-core/tests/unit/vizro/models/test_page.py +++ b/vizro-core/tests/unit/vizro/models/test_page.py @@ -99,7 +99,7 @@ def test_valid_control_types(self, standard_px_chart): controls=[ vm.Filter(column="continent"), vm.Parameter(targets=["scatter.x"], selector=vm.RadioItems(options=["lifeExp", "pop", "gdpPercap"])), - vm.Button(text="Click me!"), + vm.Button(), ], ) From b3ed2dae8249b65cb6b87416a67f3068aae1a491 Mon Sep 17 00:00:00 2001 From: huong-li-nguyen Date: Mon, 2 Oct 2023 18:20:57 +0200 Subject: [PATCH 05/10] Make horizontal rulers visible --- vizro-core/src/vizro/models/_navigation/_accordion.py | 2 +- vizro-core/src/vizro/models/_page.py | 7 ++----- vizro-core/src/vizro/static/css/layout.css | 2 +- vizro-core/tests/unit/vizro/models/_navigation/conftest.py | 4 ++-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/vizro-core/src/vizro/models/_navigation/_accordion.py b/vizro-core/src/vizro/models/_navigation/_accordion.py index 256069d4a..bbca9cce2 100644 --- a/vizro-core/src/vizro/models/_navigation/_accordion.py +++ b/vizro-core/src/vizro/models/_navigation/_accordion.py @@ -67,7 +67,7 @@ def _get_accordion_container(self, accordion_items, accordion_buttons): persistence=True, persistence_type="session", ), - html.Div(className="keyline"), + html.Hr(), ], className="nav_panel", id=f"{self.id}_outer", diff --git a/vizro-core/src/vizro/models/_page.py b/vizro-core/src/vizro/models/_page.py index 5906a26f9..192a4f0b8 100644 --- a/vizro-core/src/vizro/models/_page.py +++ b/vizro-core/src/vizro/models/_page.py @@ -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 @@ -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 ) diff --git a/vizro-core/src/vizro/static/css/layout.css b/vizro-core/src/vizro/static/css/layout.css index 334a96349..4edf9f029 100644 --- a/vizro-core/src/vizro/static/css/layout.css +++ b/vizro-core/src/vizro/static/css/layout.css @@ -87,7 +87,7 @@ width: 336px; } -.keyline { +hr { border-bottom: 1px solid var(--border-subtle-alpha-01); width: 100%; } diff --git a/vizro-core/tests/unit/vizro/models/_navigation/conftest.py b/vizro-core/tests/unit/vizro/models/_navigation/conftest.py index f0869309e..754fe8eff 100644 --- a/vizro-core/tests/unit/vizro/models/_navigation/conftest.py +++ b/vizro-core/tests/unit/vizro/models/_navigation/conftest.py @@ -49,7 +49,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", @@ -82,7 +82,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", From 7056999415f35d4e288a4e1173a9765bc9ef00a8 Mon Sep 17 00:00:00 2001 From: huong-li-nguyen Date: Mon, 2 Oct 2023 18:54:13 +0200 Subject: [PATCH 06/10] Update CODEOWNERS --- CODEOWNERS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index 8c5f3b8f0..ffac41478 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1 +1,2 @@ -* @huong-li-nguyen @maxschulz-COL +* @antonymilne @huong-li-nguyen @maxschulz-COL +*.md @Joseph-Perkins From ad650bc9702844cb360f40cb4bc5e026f12898f3 Mon Sep 17 00:00:00 2001 From: huong-li-nguyen Date: Mon, 2 Oct 2023 19:00:44 +0200 Subject: [PATCH 07/10] Update changelog with PR number --- CODEOWNERS | 4 ++-- .../20230927_163719_huong_li_nguyen_button_as_control.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CODEOWNERS b/CODEOWNERS index ffac41478..3cb0f8e8d 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1,2 +1,2 @@ -* @antonymilne @huong-li-nguyen @maxschulz-COL -*.md @Joseph-Perkins +* @antonymilne @huong-li-nguyen @maxschulz-COL +vizro-core/docs/ @Joseph-Perkins diff --git a/vizro-core/changelog.d/20230927_163719_huong_li_nguyen_button_as_control.md b/vizro-core/changelog.d/20230927_163719_huong_li_nguyen_button_as_control.md index 784b4c7f3..2dee7359a 100644 --- a/vizro-core/changelog.d/20230927_163719_huong_li_nguyen_button_as_control.md +++ b/vizro-core/changelog.d/20230927_163719_huong_li_nguyen_button_as_control.md @@ -20,7 +20,7 @@ Uncomment the section that is right (remove the HTML comment wrapper). ### Changed -- Add `Button` to `ControlType` +- Add `Button` to `ControlType` ([#88](https://github.com/mckinsey/vizro/pull/88)) -