-
Notifications
You must be signed in to change notification settings - Fork 151
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
Enable NavBar
as selector for Navigation
#70
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… accordion title with page title
- Rename to active_page_id - Compare with page["module"] - Optimise for loop
…igation-navbar # Conflicts: # vizro-core/src/vizro/_vizro.py
antonymilne
dismissed
lingyielia’s stale review
November 28, 2023 17:15
Changes all incorporate in newly written docs :)
antonymilne
reviewed
Nov 29, 2023
Signed-off-by: Antony Milne <[email protected]>
antonymilne
approved these changes
Nov 29, 2023
9 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
@antonymilne comment: Some of the below description is out of date. The best place to look for what this PR does is the user guide on navigation.
As well as navigation, this PR adds an important new testing functionality with
assert_component_equals
. I will write about this separately in another PR.The main idea is that the
Navigation
model is responsible for delivering navigation components, nav_bar and nav_panel and Page model is responsible for arranging components.Models added:
1. NavBar model
NavBar model is responsible for building nav_bar_div. It takes
items
andpages
as arguments.items
are list of NavItem models, andpages
are list of page ids or page titles.pages
: list or dict mapping of page ids or page titles.items
: list ofNavItem
models2. NavItem model
NavItem model is responsible for building individual icons inside the nav_bar div. Click on the icon leads you to the first page defined inside NavItem.pages.
pages
: list or dict mapping of page ids or page titles.icon
: If None provide default image (home icon from Google icons)(but only on vertical), if a user sets icon = "" they can turn off our defaultstext
: If text goes above our max_text_length, it will be truncated to length defined inmax_text_length
which defaults to 8. If not already provided, tooltip is automatically populated with the full text lengthtooltip
: No special logic except for automatic population based on text lengthmax_text_length
: Defaults to 8 characters. If a user wants to exceed the max text length, they can set it here in which case the text should wrap automatically (vertical alignment). For the horizontal alignment, we might just set a different max_text_length as default or None?selector
: exposed, but can only takeAccordion
modelPossible configuration options for dashboard navigation:
Option 1
Configuration:
navigation=Navigation()
-> gives ->navigation=Navigation(selector=Accordion(pages=[])
wherepages
is list of all registered pages in the dashboard.Outcome: navigation panel with accordion and 'SELECT PAGE' default accordion title
Option 2
Configuration:
navigation=Navigation(pages=['Page_1', 'Page_2', 'Page_3'])
-> gives ->navigation=Navigation(selector=Accordion(pages=['Page_1', 'Page_2', 'Page_3'])
the same is true whenpages
is provided as adict
Outcome: navigation panel with accordion and 'SELECT PAGE' default accordion title if pages provided as list or custom title with pages provided as dicc
Option 3
Configuration:
navigation=Navigation(selector=Accordion(pages=['Page_1', 'Page_2', 'Page_3']))
Outcome: gives the same outcome as configuration 1 and 2.
Option 4
Configuration:
navigation=Navigation(pages=['Page_1', 'Page_2', 'Page_3'], selector=Accordion())
Outcome: gives the same outcome as configuration 1, 2 and 3.
Option 5
Configuration:
navigation=Navigation(pages=['Page_1', 'Page_2', 'Page_3'], selector=NavBar())
-> gives ->navigation=Navigation(selector=NavBar(items=[NavItem(pages=['Page_1']), NavItem(pages=['Page_2']), NavItem(pages=['Page_3'])]))
Outcome: NavBar with 3 icons (icon for each page in pages list), and no navigation panel.
Option 6
Configuration:
navigation=Navigation(selector=NavBar(pages=['Page_1', 'Page_2', 'Page_3']}))
-> gives ->navigation=Navigation(selector=NavBar(items=[NavItem(pages=['Page_1']), NavItem(pages=['Page_2']), NavItem(pages=['Page_3'])])
Outcome: NavBar with 3 icons, and no navigation panel. The same outcome as configuration 5.
Option 7
Configuration:
navigation=Navigation(pages={'title_1': ['Page_1', 'Page_2'], 'title_2': ['Page_3', 'Page_4']}, selector=NavBar())
-> gives ->navigation=Navigation(selector=NavBar(items=[NavItem(pages=['Page_1', 'Page_2']), NavItem(pages=['Page_3', 'Page_4'])]))
Outcome: NavBar with 2 icons (icon for each key in a pages dictionary), and accordion navigation panel
Option 8
Configuration:
navigation=Navigation(selector=NavBar(pages={'title_1': ['Page_1', 'Page_2'], 'title_2': ['Page_3', 'Page_4']}))
-> gives ->navigation=Navigation(selector=NavBar(items=[NavItem(pages=['Page_1', 'Page_2']), NavItem(pages=['Page_3', 'Page_4'])]))
Outcome: NavBar with 2 icons, and accordion navigation panel. The same outcome as configuration 7
Option 9
Configuration:
navigation=Navigation(selector=NavBar(items=[NavItem(pages=['Page_1', 'Page_2']), NavItem(pages=['Page_3', 'Page_4'])]))
Outcome: NavBar with 2 icons, and accordion navigation panel. The same outcome as configuration 7 and 8
Open questions:
We could possibly do it thorough re validation or os.path.isfile().
Open TO-DOS:
Screenshot
Checklist
Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))
(if applicable)Types of changes
Notice
I acknowledge and agree that, by checking this box and clicking "Submit Pull Request":