Open navin-moorthy opened 4 years ago
Can we have all the props as in https://ant.design/components/menu/ ?
Items can be a dropdown
, I think that is must. Dropdown shouldn't be a children. That is it shouldn't be something like
<NavItem>
<Dropdown />
</NavItem>
Instead it should be
<NavItem type="dropdown>
render all <NavItemOptions />
</NavItem>
Reason is that, if it is a children the composition would change for dropdown in smaller screens. You might have to use ul li to manage the list.
Whereas in the second option when type="dropdown"
is passed in as a context, the NavItemOptions should automatically get converted to a collapsible list. Agree ?
Chakra MenuList is always being rendered in Popover so
Our menu is different from their menu. Ours is a kind of nav component that creates a list of navitems. Our nav item can be a Chakra Menu (or) a simple navigatable ul li's. For now we can use their chakra menu to be our nav item in case if our submenu is of type dropdown.
in case if our submenu is of type dropdown.
modification is required. have to put a condition whether the return will be popover MenuList or Collapsable MenuList
Collapsible is not a case for desktop screen. Lets make a desktop version where there can be just two types.
By nav item I mean once clicked can navigate you through a route. It will have onActionProp.
NavItem is just a container that can receive children like Link, string, button, icon, menu or any other composition. so type is not required I think for NavItem
ok, for desktop it is not needed. But for mobile it will be needed. Ignore for it now.
Desktop version can also have a collapsible menu type. We should think about the use case like this:
<Nav>
<NavItem>
<SubNavItem>Any children components can be rendered here</SubNavItem>
</NavItem>
<NavItem>
</NavItem>
</Nav>
@sandeepprabhakaran In that case we would be having to write two different children, one for responsive and another for desktop ?
Can you explain why that's required? Pretty much every Navitem will be collapsed on responsive, only that there can be two levels.
Collapsed nav ... <NavItem> ... <SubNavItem>
So in that sense we know which Menus will go one level deep or two level deep. Right?
I will explain the case clearly.
The ideal way that we are looking is to have a desktop version something like this
The Code would look like
<Nav>
<NavItem type="link" action={navigateTo}>Navigation one</SubNavItem>
<NavItem type="link" action={navigateTo} disabled>Navigation two</SubNavItem>
<NavItem type="submenu">
<SubNavItem type="link" action={navigateTo}>Option 1</SubNavItem>
<SubNavItem type="link" action={navigateTo}>Option 2</SubNavItem>
</NavItem>
</Nav>
To achieve the same thing with chakra Menu as a NavItem, the code would be looking like
<Nav>
// Don't use chakra menu for the next line since it is just a normal link
<NavItem type="link" action={navigateTo}>Navigation one</SubNavItem>
// Don't use chakra menu for the next line since it is just a normal link
<NavItem type="link" action={navigateTo} disabled>Navigation two</SubNavItem>
// Use Chakra menu that uses Popover JS
<NavItem type="submenu">
<SubNavItem type="link" action={navigateTo}>Option 1</SubNavItem>
<SubNavItem type="link" action={navigateTo}>Option 2</SubNavItem>
</NavItem>
</Nav>
On Desktop screen [Works fine]
On Mobile screen (Issue: Cannot collapse since it is always a dropdown using popover)
So to avoid this issue either
NavItem should be rendering Chakra's menu at desktop screen and a simple collapsible list at mobile screen.
(or)
Compose with two different components when using it in the app.
<Nav> // Don't use chakra menu for the next line since it is just a normal link <NavItem type="link" action={navigateTo}>Navigation one</SubNavItem> // Don't use chakra menu for the next line since it is just a normal link <NavItem type="link" action={navigateTo} disabled>Navigation two</SubNavItem> // Use Chakra menu that uses Popover JS <NavItem type="submenu"> <SubNavItem type="link" action={navigateTo}>Option 1</SubNavItem> <SubNavItem type="link" action={navigateTo}>Option 2</SubNavItem> </NavItem> </Nav>
Just like this
We can have our Link component with NavItem since it will be a Box Components right?
Do we need type
props?
I think it's best to compose our own submenu component to tackle the responsiveness.
Note- Updated the Description
Pending Features
Base Component to build an application Navbar, sidebar and Mobile Menu
The Goal:
Create a MenuBar as a navigation component that is composable, extensible and accessible using Chakra UI.
Key Resources:
Key Features:
Import
MenuBar
: The wrapper component that provides context, state, and focus management.MenuBarItem
: Items of the MenuBar which are the direct children ofMenuBar
SubMenu
: The wrapper component that provides context, state, and focus management forSubMenu
components.SubMenuTitle
: The trigger for theSubMenuList
. Must be a direct child ofSubMenu
.SubMenuList
: The wrapper for theSubMenu
items. Must be a direct child ofSubMenu
.SubMenuListArrow
: A visual arrow that points to the reference (or trigger).SubMenuItem
: The trigger that handles submenu selection. Must be a direct child of aSubMenuList
.SubMenuGroup
: A wrapper to group related submenu items.SubMenuDivider
: A visual separator for submenu items and groups.SubMenuOptionGroup
: A wrapper for checkable menu items (radio and checkbox)SubMenuItemOption
: The checkable menu item, to be used with MenuOptionGroupUsage