-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
feat: add menu component #28583
feat: add menu component #28583
Conversation
const labelAndContextualHelp = ( | ||
<div data-field-label-wrapper=""> | ||
{Boolean(label) && ( | ||
const labelAndContextualHelp = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsartisan Changes in order not to add excessive div.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have refactored some of the code in the field in the currency input widget PR.
|
||
<Canvas> | ||
<Story name="Menu example"> | ||
<Menu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dhruvikn @jsartisan Pay attention to how the API is implemented here. This may be somewhat unexpected. Inheriting the implementation from Spectrum.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API looks good to me. But we can't make nested menu right with this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do something like this (see pict.) Taras said that this is enough for now. Spectrum also developing such functionality.
Anyway, we can redo the implementation for floating-ui. But I have concerns about how they work with touch devices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok cool then.
}); | ||
|
||
return cloneElement(children, { | ||
onPress: () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far we can only work with buttons. I'll think about how to make the correct implementation for other components.
|
||
import type { PopoverProps } from "./types"; | ||
|
||
const DEFAULT_POPOVER_OFFSET = 10; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsartisan We have to add tokens here. In the tooltip too.
> | ||
{cloneChildren(children)} | ||
</div> | ||
<ButtonGroupContext.Provider value={{ color, variant }}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the implementation since now ButtonGroupItem
may not be a direct children since we can, for example, use the Menu
inside ButtonGroup
now.
@@ -57,6 +57,8 @@ module.exports = { | |||
typescript: { | |||
reactDocgen: "react-docgen-typescript", | |||
reactDocgenTypescriptOptions: { | |||
propFilter: (prop) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix for ArgsTable
.
e0ef1bf
to
d25e990
Compare
/ok-to-test |
Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/6738003497. |
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/6738003497.
|
const labelAndContextualHelp = ( | ||
<div data-field-label-wrapper=""> | ||
{Boolean(label) && ( | ||
const labelAndContextualHelp = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have refactored some of the code in the field in the currency input widget PR.
const { className, item, state } = props; | ||
const ref = React.useRef(null); | ||
const { isDisabled, isFocused, isPressed, isSelected, menuItemProps } = | ||
useMenuItem({ key: item.key }, state, ref); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with spectrum menu hook is we can't make nested menus :/ That might be a requirement for ADS ( if ADS ever plans to use our headless component )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Answered here
|
||
<Canvas> | ||
<Story name="Menu example"> | ||
<Menu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API looks good to me. But we can't make nested menu right with this?
import type { ReactNode } from "react"; | ||
import type { Dispatch, SetStateAction } from "react"; | ||
import type { usePopover } from "./usePopover"; | ||
import type { Placement } from "@floating-ui/react"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel weird about mix of spectrum and floating-ui 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does hook spectrum's menu do? do they just add aria props or do they also add some functionality/events on the components.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They provide accessibility support, handle keyboard events, control focus, and provide support for touch devices. Because of the last point, the choice fell on spectrum instead of floating-ui.
<Menu {...args} disabledKeys={["cut"]} onAction={(key) => console.log(key)}> | ||
<Button>My trigger</Button> | ||
<MenuList> | ||
<Item key="copy">Copy</Item> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we might need a way to add startIcon and endIcon to the Menu Item
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add it as part of another ticket.
@@ -377,6 +377,7 @@ | |||
"@blueprintjs/core@^3.47.0": "patch:@blueprintjs/core@npm%3A3.47.0#./.yarn/patches/@blueprintjs-core-npm-3.47.0-a5bc1ea927.patch", | |||
"@blueprintjs/icons": "3.22.0", | |||
"@types/react": "^17.0.2", | |||
"postcss": "8.4.31" | |||
"postcss": "8.4.31", | |||
"@react-types/shared": "3.19.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/6738003497. |
d25e990
to
d8c1dba
Compare
Description
Add WDS menu component
PR fixes following issue(s)
Fixes #28392
Media
2023-11-02.22.26.28_compressed.mp4
Type of change
Testing
How Has This Been Tested?
Checklist:
Dev activity