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

Improve dashboard title #228

Merged
merged 11 commits into from
Dec 19, 2023
Merged

Improve dashboard title #228

merged 11 commits into from
Dec 19, 2023

Conversation

antonymilne
Copy link
Contributor

@antonymilne antonymilne commented Dec 19, 2023

Description

Small precursor to #185, mentioned as part of #176.

When Dashboard.title is specified we now include it in the page title in the dash registry. This makes no difference to anything on the screen other than the <title> tag and a meta tag. These are useful to get right because it means that the title of the page is much more meaningful in your browser window, when you try to bookmark a dashboard, and if you share a link of a Vizro dashboard that gets previewed e.g. on social media.

Screenshot

image

Checklist

  • I have not referenced individuals, products or companies in any commits, directly or indirectly
  • I have not added data or restricted code in any commits, directly or indirectly
  • I have updated the docstring of any public function/class/model changed
  • I have added tests to cover my changes (if applicable)

Types of changes

  • Docs/refactoring (non-breaking change which improves codebase)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Notice

  • I acknowledge and agree that, by checking this box and clicking "Submit Pull Request":

    • I submit this contribution under the Apache 2.0 license and represent that I am entitled to do so on behalf of myself, my employer, or relevant third parties, as applicable.
    • I certify that (a) this contribution is my original creation and / or (b) to the extent it is not my original creation, I am authorized to submit this contribution on behalf of the original creator(s) or their licensees.
    • I certify that the use of this contribution as authorized by the Apache 2.0 license does not violate the intellectual property rights of anyone else.

vizro-core/examples/default/app.py Outdated Show resolved Hide resolved
module=page.id, name=page.title, path=path, order=order, layout=partial(self._make_page_layout, page)
module=page.id,
name=page.title,
title=f"{self.title}: {page.title}" if self.title else page.title,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one line is the only functional change in the PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess if people do want to overwrite it, they would overwrite the pre-build of the model here?

I was actually wondering how this works compared to the dash.app.title. If you set the dash.app.title, I noticed that it appears for a second and then it gets overwritten by anything defined in dash.register_page.

This might be worth mentioning in the docs if people try to overwrite it via the dash.app.title. This wouldn't actually work, because in the end it gets overwritten by the code here again. But I think this is also how it works in a pure Dash app?

app = Vizro(assets_folder="../assets").build(dashboard)
app.title = "My title"
app.run()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is indeed how it works in a pure Dash app also:

  1. Dash(title="X") corresponds to the property dash.app.title and sets the initial value of <title>X</title>
  2. but this only appears very briefly when you're using Dash pages, because it gets overwritten straight away by dash.page_registry[page.id]["title"]
  3. after this, the original app title=X has no effect on anything

So for Vizro users where Dash pages is always used, the title argument basically has no effect. @AnnMarieW please do correct me if I've missed something here.

We have possibly added to the confusion here because we have our own Dashboard.title property, and it's not obvious to a user what effect that has on anything. I considered before whether we should do dash.app.title = dashboard.title in Vizro.build() but decided it was basically pointless because, like you say, it just gets overwritten straight away. I think it would be a very small improvement though, since that way you wouldn't see the "Dash" title at all, so let me add it in here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change made in c00fe4e.

vizro-core/tests/unit/vizro/conftest.py Show resolved Hide resolved
antonymilne and others added 2 commits December 19, 2023 00:45
Signed-off-by: Antony Milne <49395058+antonymilne@users.noreply.github.com>
@antonymilne
Copy link
Contributor Author

@AnnMarieW: I wanted to add you as a reviewer for this but for some reason can't do so - maybe some limitation of our github org settings I guess 🤔

Are you able to add yourself as reviewer?

There's two reasons I wanted to add you anyway:

  1. so you can check I haven't done anything stupid
  2. I was thinking about the tests in your PR and decided our current tests weren't quite right so rewrote them

I think we should aim to get this merged ASAP before #185 so you can base your tests on the "new" style.

@antonymilne antonymilne mentioned this pull request Dec 19, 2023
9 tasks
@AnnMarieW
Copy link
Contributor

AnnMarieW commented Dec 19, 2023

@antonymilne I might have to be invited as a collaborator or a member before I can be added as a reviewer, but I think tagging me here works too :-)

I like the new style of the tests and will wait until this is merged before writing the tests in my PR. Thanks for the help!

I also like the new format for the title for the browser and the meta tags. Are you planning on updating the docs in a different PR?

Copy link
Contributor

@nadijagraca nadijagraca left a comment

Choose a reason for hiding this comment

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

I love the new title format. 🚀

Copy link
Contributor

@huong-li-nguyen huong-li-nguyen left a comment

Choose a reason for hiding this comment

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

Looks great to me 👍

If we can just mention in the docs how the dash.app.title and dashboard.title/page.title overwriting works - I think that would help. I wasn't e.g. sure how it would actually work until I tested it out and saw that the dash.app.title is always overwritten by the title defined in the dash.page_registry. I guess that's the default behaviour coming from dash?

@@ -545,6 +545,7 @@ def create_home_page():


dashboard = vm.Dashboard(
title="Vizro demo",
Copy link
Contributor

Choose a reason for hiding this comment

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

You probably just left this in for demo purposes, but I would remove it if this is close to being merged. It's not optimal in terms of design if there are controls/navigation on the page, as we still have this open discussion of where this might go.

Looking at this, I prefer the upper header container we discussed the other day even more 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I left it here so that we would hopefully apply the same change to vizro.mckinsey.com next time we update the demo, but let me remove it if we're not yet happy about the visual design.

The reason I think it would be nice to include sooner rather than later is because every time someone shares a link to vizro.mckinsey.com the social media preview will have a slightly strange label (like just "Homepage") - it would be nicer if it instead said "Vizro demo: Homepage" or similar, to make it clear what the link being shared actually is.

If we don't work out the page layout/visual design soon then possible alternatives might be:

  • we remove the title from the dashboard layout altogether from _make_page_layout for now
  • we remove the title from the dashboard layout just by customising our demo app

So I'll revert the change here and leave it up to you to decide out what's the best solution here depending on how long the reworking of the page layout takes 🙂 It's not a huge thing but I don't think we should wait too long (say > 1 month) to get an improved shareable link to our demo app just because we're blocked on where to put the title on screen.

Copy link
Contributor

@huong-li-nguyen huong-li-nguyen Dec 19, 2023

Choose a reason for hiding this comment

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

we remove the title from the dashboard layout altogether from _make_page_layout for now
I think this would be a breaking change right? Or are we still fine saying that any visual changes are not considered breaking changes? 😄 I would be fine with this one to be honest - if people reach out, then we at least know people have been using a dashboard title and need it 😅

we remove the title from the dashboard layout just by customising our demo app
As a quick-fix, this one seems safer. The demo app would be a bit out of sync for a while with the example app here, but I think it's fine as we manage it.

What do you prefer? 1) I could embed in my current PR on layout arrangements and 2) I can create in another PR in the demo-app repository

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted in 5cef34a.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wouldn't consider removing the title from the layout a breaking change since it's just something visual and no one's code will break in any way. Admittedly it's kind of a drastic one rather than just tweaking styling, but I'm completely fine with it and, like you say, if people ask where their title went then it's a good signal they want it there.

Which solution we go for depends to me on how close we are to resolving the question of where the title goes and how upsetting people find the current placement:

  1. if we're really not happy with how the dashboard title appears at the moment and it feels a long way off resolving let's go for option 1
  2. if we think it's ok currently but still don't want it on our demo app then let's go for 2
  3. if we think the current dashboard title is already completely fine then let's just leave it as it is and add a title to the example app

Personally I'm completely fine with the current visual appearance, which is why I just went for option 3 to begin with in this PR. But you have a better idea of how upsetting people with more design sensibilities find that and where future changes to layout might take us here, so completely up to you which option to choose 🙂

Copy link
Contributor

Choose a reason for hiding this comment

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

That makes a lot of sense!

I think the position of the dashboard title will likely change given that it's taking too much horizontal space if there are no controls/navigations. Given that J. is also out, I'll go for 2) as I think it's the one he would feel less reluctant to implement 😄

I add it to my tickets and will update the demo accordingly after we've done release 0.1.8 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool, thank you! Sounds good to me.

I didn't actually realise how weird it looks like when there's no controls/navigation until I just looked again now. You're right that doesn't look good at all, so I take back my statement above that option 3 was ok by me. Just in case you thought I had no design sensibilities at all 😀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

P.S. hopefully the demo update would be as simple as dash.layout["dashboard_title_outer"].hidden = True or similar rather than needing any customisation of _make_page_layout with a custom Dashboard model.

module=page.id, name=page.title, path=path, order=order, layout=partial(self._make_page_layout, page)
module=page.id,
name=page.title,
title=f"{self.title}: {page.title}" if self.title else page.title,
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess if people do want to overwrite it, they would overwrite the pre-build of the model here?

I was actually wondering how this works compared to the dash.app.title. If you set the dash.app.title, I noticed that it appears for a second and then it gets overwritten by anything defined in dash.register_page.

This might be worth mentioning in the docs if people try to overwrite it via the dash.app.title. This wouldn't actually work, because in the end it gets overwritten by the code here again. But I think this is also how it works in a pure Dash app?

app = Vizro(assets_folder="../assets").build(dashboard)
app.title = "My title"
app.run()

@antonymilne
Copy link
Contributor Author

@antonymilne I might have to be invited as a collaborator or a member before I can be added as a reviewer, but I think tagging me here works too :-)

I like the new style of the tests and will wait until this is merged before writing the tests in my PR. Thanks for the help!

I also like the new format for the title for the browser and the meta tags. Are you planning on updating the docs in a different PR?

I've just updated the docs in 7f981fb.

When we write docs for your meta tag image and description pieces, I think it would belong in pages.md and then let's link to it from my text that mentions meta elements here in dashboard.md.

I've changed a github setting that should mean that all users can now review PRs, but I still don't seem to be able to add you here. Maybe it will work in future PRs though, let's see.

@antonymilne antonymilne enabled auto-merge (squash) December 19, 2023 10:55
Signed-off-by: Antony Milne <49395058+antonymilne@users.noreply.github.com>
@antonymilne antonymilne merged commit 2212992 into main Dec 19, 2023
37 checks passed
@antonymilne antonymilne deleted the feature/improve-dashboard-title branch December 19, 2023 13:00
@antonymilne antonymilne mentioned this pull request May 21, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants