-
Notifications
You must be signed in to change notification settings - Fork 65
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
Menu widget #52
Comments
Here's what I was thinking: A NavBar would go across the top of a page and can contain a logo or header text. It can also contain a list of MenuItems, Menus that contains MenuItems, or both (think Bootstrap NavBars with links and dropdowns to other links). The parent NavBar should collapse its child MenuItems and Menus to use a SlidePanel to show them when screen width goes below a designated breakpoint. |
Do we want to build the static/fixed position into this, though? I think that might be good for a separate container widget, since it's pretty common to want all sorts of random things in a scrolling header (or footer). |
I think a MenuItem should be able to be whatever you want (such as a search input). I also think the NavBar should be fixed (and thus collapse its children into a SlidePane) based on a property. If that property is false, the menu isn't fixed and doesn't collapse. |
Rather than limiting a |
@bitpshr I'm not sure the fixed positioning should be tied to collapsing into a SlidePane. What if someone wants a desktop-width uncollapsed fixed nav bar? I like allowing MenuItems to be anything, that solves the flexible scrolling header issue. |
Maybe we could use separate properties to determine menu collapsing and fixed positioning? @mwistrand: I'm not sure I follow. When I say "MenuItem", I just mean a container to put a link or input or any other component in, that handles styling in an inline-block manner to stay consistent. I also don't think any MenuItem should be within a Menu. Think Bootstrap. Some menu items are within a dropdown menu, some aren't. |
Depending on the number of items within the nav bar, perhaps a breakpoint property could be used to determine the point at which the menu is expanded from the |
Sounds good! So, let me know if I have this right... we have a |
@bitpshr When I talk about "menu items being contained in a separate w(NavBar, [
v('img', { src: 'path/to/logo.png' }),
w(Menu, [ /* "login" and "join" links */ ]),
w(Menu, [ /* app navigation */ ])
]); |
If "login" and "join" are individual links, it's confusing to me to consider them as part of the same Menu. Why? How is that more flexible? This is clearer to me: w(NavBar, [
v('img', { src: 'path/to/logo.png' }),
w(MenuItem, [ /* "login" link */ ]),
w(MenuItem, [ /* "join" link */ ]),
w(Menu, [ /* app navigation */ ])
]); |
@bitpshr Disregard. I think I just misunderstood your original statement about the possible contents of |
Just to clarify, I think that a |
? One thing we would have to do, would be to decide how to vertically align items (for a horizontal nav). Thats a piece of cake with flexbox right? |
MenuItem in my mind was purely a convenience because it could handle alignment, but maybe that's not necessary. @rishson's example above seems fine. And yes, that's easy enough with flexbox. |
I guess the one other question is about accessibility. A nav bar should be @mwistrand's going to have a fun time figuring out how to handle focus, though. Tabbing should probably move you into the menu or out of the menu, with arrow keys handling navigation through it. Allowing any widgets into it is going to be a pile of fun I hadn't thought about until just now |
Should we look to rename this issue |
Putting this here for a11y reference: https://www.w3.org/TR/wai-aria-practices-1.1/#menu And this as an example: https://www.w3.org/TR/wai-aria-practices-1.1/examples/menubar/menubar-1/menubar-1.html |
@bitpshr we should probably start noting down all the places a focus manager could be useful. I was just thinking of it as a way to trap focus within a certain element (like a dialog or flyout menu), but I imagine it would be useful for something like this too. I'm just not entirely sure how that would work or what it would do. |
Before I get any deeper into this, it would be wise to get some feedback regarding the A menu is basically a list of children with predefined layout properties. By default, a
The properties used to control the menu would resemble the following: interface MenuProperties {
/**
* If `true` then all menu items will be disabled. If a `label` is specified,
* then the menu will not be displayed when disabled.
*/
disabled?: boolean;
/**
* Indicates whether the menu is rendered as a drop down or accordion-style menu
* (the default). Only relevant if a `label` is specified.
*/
dropDown?: boolean;
/**
* Defaults to `false` if no `label` is specified, but defaults to `true` if a
* `label` widget is provided.
*/
hidden?: boolean;
/**
* Determines whether the menu is rendered as a horizontal list or a vertical list.
* Defaults to `false`.
*/
horizontal?: boolean;
/**
* An optional widget used to toggle the menu into view.
*/
label?: string | DNode;
/**
* An optional function to control how the menu is hidden.
*/
onHide?: (menu) => void;
/**
* An optional function to control how the menu transitions from hidden to displayed.
*/
onShow?: (menu) => void;
/**
* Determines whether the menu is displayed when `label` is clicked, or via
* mouse hover. Defaults to `true`.
*/
triggerOnClick?: boolean;
} Question: does the optional |
As per the conversation around |
This might be nitpicky, but could we only use |
Current status of Menu: We now have the ability to type children, so it is more feasible to just create Menu with type-enforced MenuItem children. TabController currently does this, and overrides certain child properties with: .map((tab, i) => {
assign(tab.properties, {...});
return tab;
}) It doesn't really solve the problem of creating public properties on MenuItem that are effectively private, since they will always be reset in Menu. However, I'm comfortable with continuing this pattern for now so we can at least create a working widget, then refining it later. |
Fixed by #104 |
#104 was closed and was never merged. I think we need to leave this issue open to track the new Menu implementation. |
Some comments on the potential usage of Listbox within the Menu widget: On the surface, it seems like a good fit, since in both you are presented with a list of things to interact with, and choose one (or more). Under that though, Listbox is fundamentally a selection widget, and Menu is a list of actionable items with a potentially more complex structure. First, the semantic things that would need to be changed from Listbox:
There are also some potential interactive and semantic issues related to dropdown/flyout menus. Keyboard interaction is a little more complex, with left/right arrow keys needed on individual menu items to open sub-menus (or up/down, depending on orientation). Any links that open sub-menus would need Right now I think the best possibility would be to pull out the keyboard logic into a utility, since that has potentially broad applicability. Listbox isn’t much more than that logic, some render functions, and scrolling (which Menu wouldn't need). |
This is most likely going to be post 2.0. |
What's the status of the Menu widget? It appears that it died on the vine. My use case is for a context menu, which looks like it may be supported according to @mwistrand's comment, but it isn't entirely clear. Perhaps there would need to be a ContextMenu widget that could also contain MenuItems, or a Menu even? |
@schontz I'm not sure how this never made it into either the issue or PR threads, but at the time the menu widget I had worked on was much closer "to the metal" than anyone on the core team was comfortable with (I don't think we had a |
Sounds good. Is there any kind of widget roadmap/wishlist out there? It may be good to see general interest. |
@schontz We hope to work on an implementation of |
I believe this can be closed now as we have implemented the Menu / List / Select / TypeAhead |
Create a
menu
widget.Initial thoughts: menu as in 'full width page header that contains links to other pages | dropdowns | logos | searchbox etc.
Spec:
list of callback funcs that can be passed in props
some kind of 'onHide' or 'onPageScroll' that indicates when the menu would be scrolled off screen (so controlling component can reduce hight etc)
mouse/keyboard interactions (if any)
as per individual controls passed to menu
mandatory/valid/empty/wait states (if any)
as per individual controls passed to menu
value-add of the widget (e.g. why use rather than just use VDom directly)
ability to easily style to make sticky, align to top, bottom, left, right..
responsive on mobile
ability to vertically align items of different heights (for a horizontal menu)
is the widget controlled/uncontrolled
I am imagining that you would pass the menu child widgets, therefore it is controlled.
list of any icons needed
none
is the widget responsive
yes, on mobile, this widget should shrink to a hamburger menu
The text was updated successfully, but these errors were encountered: