Closed lpatiny closed 2 years ago
Menu
, Menu.Items
from https://headlessui.com/ for keyboard navigation supportI weighed between adopting an API similar to what Ant does and our API in zakodium/components and I favor the latter.
I would change the options to be a simple array, not array of array, as this can be confusing. A divider within the options can be defined with a special option type: 'divider'
instead, like in Ant.
The new trigger
prop allows to use it either on the click of a button or when right-clicking a zone.
when trigger='click'
, the user should set children to be the element which both acts as the element to be clicked and the reference for react-popper.
when trigger='contextMenu'
, the children act as the zone which respond to the context menu event. It will be probably required to setup a virtual element at the position where the mouse is (see docs and to use a boundary modifier to constrain the positioning of the contextual menu to be within the children.
export interface MenuOption<T> {
type: 'option';
label: ReactNode;
icon?: ReactNode;
disabled?: boolean;
data?: T;
}
export interface MenuDivider {
type: 'divider';
}
type MenuOptions<T> = Array<MenuOption<T> | MenuDivider>;
export interface DropdownMenuProps<T> {
children: ReactNode; // The button contents
options: MenuOptions<T>;
onSelect: (selected: DropdownOption<T>) => void;
placement?: Placement;
trigger: 'click' | 'contextMenu'
}
div
, span
etc...)~Translation
because based on class names.~emotion also creates classes, I don't see any issues with using it with headless ui
@Sebastien-Ahkrin first step is:
MenuOption
rendered with Menu.Items
). <MenuItems options={options} onSelect={onSelect} />
The menu could be a grid with 2 columns:
The idea is that later (not in this PR) we will want to add 2 other column:
As an example of the full grid, here's the Edge menu:
@stropitek @targos Do you want to keep the old styles from nmrium ?
Not at all. You can take inspiration from my screenshot if you want.
No you shouldn't, you can get inspired by the example in Ant (see link in my proposal)