Doist / reactist

Open source React components made with ❤️ by Doist
http://doist.github.io/reactist
MIT License
247 stars 21 forks source link

feat: Structured menu items #788

Closed gnapse closed 1 year ago

gnapse commented 1 year ago

Short description

This PR enhances the MenuItem component to have props targeted at generating a more structured content inside it, rather than leaving it to the consumer of the component to build the menu item's content by using children.

BeforeAfter
```jsx Click me to learn more… ``` ```jsx } label="Click me to learn more…" /> ```

The ability to use the component children instead of this new props is kept. It may prove useful in the future, so it is likely a feature we won't remove. It will give the freedom to consumers of the menu components to carve out custom menu items when they need it.

Still, this is a breaking change. The inner layout of a menu item changes in ways that would break the layout in the Todoist app if we adopt this without migrating most MenuItem elements to use the new props.

Why?

A few reasons:

PR Checklist

Versioning

Note This PR's base branch is not main. So approving this does not yet mean it will be released. I'm planning a series of improvements to the menu component, that I'll gather in this base branch before I make a single release (or a handful of releases). This will allow me to test the changes with Todoist before comitting Reactist to the new features.

Demo

CleanShot 2023-07-04 at 11 49 48@2x