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

[SideNav] Use MenuConfiguration directly #6885

Open
MarcinVaadin opened this issue Dec 4, 2024 · 4 comments
Open

[SideNav] Use MenuConfiguration directly #6885

MarcinVaadin opened this issue Dec 4, 2024 · 4 comments
Assignees
Labels
enhancement New feature or request vaadin-side-nav

Comments

@MarcinVaadin
Copy link
Member

MarcinVaadin commented Dec 4, 2024

Describe your motivation

While using @Menu on Flow project I would like to put all items in SideNav automatically as easy as possible.

Describe the solution you'd like

I've expected something short and handy like:

List<MenuEntry> menuEntries = MenuConfiguration.getMenuEntries();
SideNav sideNav = SideNav.from(menuEntries);

or

SideNav sideNav = new SideNav();
List<MenuEntry> menuEntries = MenuConfiguration.getMenuEntries();
menuEntries.forEach(sideNav::add);

would work.

Describe alternatives you've considered

Current working approach requires:

SideNav sideNav = new SideNav();
List<MenuEntry> menuEntries = MenuConfiguration.getMenuEntries();
menuEntries.stream().map(menuEntry -> new SideNavItem(menuEntry.title(), menuEntry.path())).forEach(sideNav::addItem);

which looks like a boilerplate.

@MarcinVaadin MarcinVaadin added the enhancement New feature or request label Dec 4, 2024
@mcollovati mcollovati transferred this issue from vaadin/flow Dec 4, 2024
@MarcinVaadin
Copy link
Member Author

Also, icon defined as a String in @Menu cannot be used directly in SideNavItem. Prefix component is required.

@yuriy-fix
Copy link
Contributor

Would you expect it to work on the client side as well?

@MarcinVaadin
Copy link
Member Author

Would you expect it to work on the client side as well?

I'm writing pure Java demo, didn't consider client side.

@sissbruecker
Copy link
Contributor

This isn't trivial to implement currently. Creating items with label and path from the menu configuration is straightforward. However you would also expect it to create an icon if one is specified in @Menu. When using iconsets, this would require importing Icon in SideNav. This has the side effect that the Vaadin iconset would be included in the frontend bundle for everyone using side nav, even if no icons are used.

This may become feasible at some point if Icon wouldn't automatically include the Vaadin iconset, and if there would be some way for Flow users to explicitly specify which iconsets to include in the bundle.

@sissbruecker sissbruecker removed the good first issue Good for newcomers label Dec 20, 2024
@sissbruecker sissbruecker changed the title [FEATURE] Use MenuConfiguration directly on SideNav [SideNav] Use MenuConfiguration directly Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request vaadin-side-nav
Projects
None yet
Development

No branches or pull requests

3 participants