-
Notifications
You must be signed in to change notification settings - Fork 155
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
[Feat] Add info icon to dashboard title #1053
base: main
Are you sure you want to change the base?
Conversation
I just looked at the design for now as you asked :) I think overall it looks good, I would just ensure:
See this article: https://hanjing.medium.com/best-practice-of-i-icon-ab6713e3aac9
Overall question: I am not sure if I like the position of this icon, but this is personal preference 😬 I think in general it makes sense to have them close to the title, so for any other title I would agree it should be right next to it. However, for this specific case, you have (icon on dashboard-level) I'd prefer it next to the toggle-switch. |
title: str = Field(default="", description="Dashboard title to appear on every page on top left-side.") | ||
icon: bool = False | ||
tooltip_text: str = Field(description="Markdown string to create card text that appears on icon hover.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
title: str = Field(default="", description="Dashboard title to appear on every page on top left-side.") | |
icon: bool = False | |
tooltip_text: str = Field(description="Markdown string to create card text that appears on icon hover.") | |
text: str = Field(description="Dashboard title to appear on every page on top left-side.") # mandatory | |
icon: str = "info-mark" # optional, can take any Material icon and defaults to info | |
tooltip: str = Field(description="Markdown string to create card text that appears on icon hover.") # mandatory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI @nadijagraca: @huong-li-nguyen, @maxschulz-COL, @Joseph-Perkins, @lingyielia and I just had a chat about this and think this would be the best API. Let me know if it makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I agree, avoiding the double title
is good 👍
55f408d
to
93ee441
Compare
View the example dashboards of the current commit live on PyCafe ☕ 🚀Updated on: 2025-03-10 16:37:08 UTC Compare the examples using the commit's wheel file vs the latest released version: vizro-core/examples/scratch_devView with commit's wheel vs View with latest release vizro-core/examples/dev/View with commit's wheel vs View with latest release vizro-core/examples/visual-vocabulary/View with commit's wheel vs View with latest release vizro-core/examples/tutorial/View with commit's wheel vs View with latest release vizro-ai/examples/dashboard_ui/ |
Currently,
@antonymilne @Joseph-Perkins I would like to hear your thoughts. These changes can be implemented in this PR, or in one of the following PRs, or not implemented at all. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @nadijagraca!! If we don't change the configuration API, this will be merged very soon 🚀
return html.Div( | ||
id="dashboard-title", | ||
children=[ | ||
html.H2(id="dashboard-title-text", children=self.text), | ||
html.Span(self.icon, className="material-symbols-outlined", id=f"{self.id}-icon"), | ||
dbc.Tooltip( | ||
id=f"{self.id}-tooltip", | ||
children=dcc.Markdown(self.tooltip, dangerously_allow_html=True, id="dashboard-title-markdown"), | ||
placement="left", | ||
target=f"{self.id}-icon", | ||
), | ||
], | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we enable using vm.Title
in other components (like vm.Page, vm.Container, vm.Checklist...), we won't be able to hardcode any of those IDs returned from the vm.Title.build
method (due to duplication ID error). Starting from that point of thinking I guess that we should adjust this code section to something like:
return html.Div( | |
id="dashboard-title", | |
children=[ | |
html.H2(id="dashboard-title-text", children=self.text), | |
html.Span(self.icon, className="material-symbols-outlined", id=f"{self.id}-icon"), | |
dbc.Tooltip( | |
id=f"{self.id}-tooltip", | |
children=dcc.Markdown(self.tooltip, dangerously_allow_html=True, id="dashboard-title-markdown"), | |
placement="left", | |
target=f"{self.id}-icon", | |
), | |
], | |
) | |
return html.Div( | |
id=self.id, | |
children=[ | |
html.H2(id=f"{self.id}-title", children=self.text), | |
html.Span(self.icon, className="material-symbols-outlined", id=f"{self.id}-title-icon"), | |
dbc.Tooltip( | |
id=f"{self.id}-title-tooltip", | |
children=dcc.Markdown(self.tooltip, dangerously_allow_html=True, id="dashboard-title-markdown"), | |
placement="left", | |
target=f"{self.id}-title-icon", | |
), | |
], | |
) |
There are many ID format variations we can use here instead and I'm okay with all of them as soon as we ensure that the vm.Title
(from the duplication ID point of view) can already be used within other components. Also, let's have variants
and extra
arguments on our minds while redesigning this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The id
is one of the issues we need to address if we want to reuse this within other components.
I agree that "dashboard-title"
cannot be hardcoded in that case. However, when vm.Title
is used specifically as the dashboard title, the id of the returned html.Div must be "dashboard-title"
, as it is referenced by ID in _dashboard.py
.
def _arrange_page_divs(self, page_divs: _PageDivsType):
logo_title = [page_divs["logo"], page_divs["logo-dark"], page_divs["logo-light"], page_divs["dashboard-title"]]
One possible solution is to explicitly pass vm.Title(id='dashboard-title' ...)
when used as a dashboard title, and while keeping self.id
when used within other components.
@@ -110,13 +112,17 @@ def pre_build(self): | |||
self.pages[0].path = "/" | |||
meta_img = self._infer_image("app") or self._infer_image("logo") or self._infer_image("logo_dark") | |||
|
|||
from vizro.models import Title | |||
|
|||
dashboard_title = self.title.text if isinstance(self.title, Title) else self.title |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have the if isinstance(dashboard.title, Title)
check three times in the code (twice in _dashboard.py
and once in _vizro.py
). Is this a good sign that we should implicitly convert title: str
-> title: vm.Title
using the Pydantic validator? I know it's not the easiest change, but it's at least worth considering.
I think it would make sense to go with the option where the design choices are applied implicitly, in order to remain opinionated about the design so the private argument would seem to be preferable, instead of the user explicitly specifying size/position via the config or CSS? |
Description
POC implementation
API needs to be agreed
Screenshot
Notice
I acknowledge and agree that, by checking this box and clicking "Submit Pull Request":