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

Drafts: Composable DropdownMenu v2 #1735

Merged
merged 44 commits into from
Jan 25, 2022
Merged

Conversation

siddharthkp
Copy link
Member

@siddharthkp siddharthkp commented Dec 14, 2021

@changeset-bot
Copy link

changeset-bot bot commented Dec 14, 2021

🦋 Changeset detected

Latest commit: d0da4db

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@siddharthkp siddharthkp changed the title Wip: Composable DropdownMenu wip: Composable DropdownMenu Dec 14, 2021
@siddharthkp siddharthkp self-assigned this Dec 15, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Dec 15, 2021

size-limit report 📦

Path Size
dist/browser.esm.js 61.25 KB (0%)
dist/browser.umd.js 61.63 KB (0%)


<br />

<State default={1}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example appears at the top of docs, but with more recent updates we've been moving them under examples heading and keeping import statements at the top. Can we do the same here for consistency?

Copy link
Member Author

@siddharthkp siddharthkp Jan 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to vote for keeping it 🤔

I've done this for ActionList and ActionMenu as well to quickly see what this component is. Meanwhile, the examples slowly build up starting from an easy example to more complex ones.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks quite nice actually, almost like a preview / hero.

👍 .. we'll need to comm this to others so we can consider doing same elsewhere.


### With External Anchor

To create an anchor outside of the menu, you need to switch to controlled mode for the menu and pass it as `anchorRef` to `DropdownMenu`:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we elaborate on this? And should it be uncontrolled mode instead? Or maybe neither as it appears to run in controlled mode by default? and we're not really mutating ref state either?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And should it be uncontrolled mode instead?

When you pull the open/close out, that's controlled mode. By default, you don't have to control that. Changed the text a little to make that clear.

render(<Example />)
```

### With a custom anchor
Copy link
Contributor

@rezrah rezrah Jan 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could anchor in this title be confusing for readers as it's used in a different context further up?

Suggested change
### With a custom anchor
### With a custom trigger

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We call this anchor because the menu still anchors on DropdownMenu.Anchor.


<Note variant="warning">

Use `DropdownMenu` to select an option from a small list. If you’re looking for filters or multiple selection, use [SelectPanel](/SelectPanel) instead.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels quite important, shall we hoist it near the top of page so it has better visibility? We've done this for other components before.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This came up before with ActionMenu. What we decided was that interface guidelines is the first place where you learn which component to use, and this is the second note near props just in case you missed that.

}

Menu.displayName = 'ActionMenu'
export const DropdownMenu = Object.assign(Menu, {Button: MenuButton, Anchor, Overlay, Divider})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire file is awesome 😍 ✨

Co-authored-by: Rez <rezrah@github.com>
@siddharthkp siddharthkp merged commit 8ff114b into main Jan 25, 2022
@siddharthkp siddharthkp deleted the siddharth/composable-dropdownmenu branch January 25, 2022 13:54
@primer-css primer-css mentioned this pull request Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants