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

[core] Refactor <Account /> #3992

Merged
merged 35 commits into from
Sep 12, 2024
Merged

Conversation

bharatkashyap
Copy link
Member

@bharatkashyap bharatkashyap commented Aug 23, 2024

https://deploy-preview-3992--mui-toolpad-docs.netlify.app/toolpad/core/react-account/

@bharatkashyap bharatkashyap added the enhancement This is not a bug, nor a new feature label Aug 23, 2024
@Janpot
Copy link
Member

Janpot commented Aug 27, 2024

This component could be much more than a simple menu. It feels like a regression to me.

Screenshot 2024-08-27 at 10 32 24
to
Screenshot 2024-08-27 at 10 32 29

@bharatkashyap
Copy link
Member Author

This component could be much more than a simple menu. It feels like a regression to me.

Screenshot 2024-08-27 at 10 32 24 to Screenshot 2024-08-27 at 10 32 29

I'll explore continuing to use the Popover, but I feel like the account/user button component is almost always going to be a list of options and text visually separated by dividers and icons on a temporary surface. Seems apt to be a Menu.

@prakhargupta1
Copy link
Member

prakhargupta1 commented Aug 29, 2024

I found three instances of it being a menu (my best guess) component. Since, it's already done I would suggest that we keep it. In the future, we can revisit if needed.

Zendesk:
Screenshot 2024-08-29 at 1 21 13 PM

Figma:
Screenshot 2024-08-29 at 1 34 45 PM

HiBob:
Screenshot 2024-08-29 at 1 20 54 PM

@Janpot
Copy link
Member

Janpot commented Aug 29, 2024

Nothing should prevent you from just rendering a MenuList in the slot. Why would we restrict every usage of this component to be this one?

Screenshot 2024-08-28 at 15 18 31

@prakhargupta1
Copy link
Member

Nothing should prevent you from just rendering a MenuList in the slot. Why would we restrict every usage of this component to be this one?

Ah ok, so I guess it's about whether to give the option of a slot as menu item versus changing it to a popover component that can show any UI (like the Google UI you shared) through a slot.
I still think, it could be done in the next iteration, based on user demand.

@Janpot
Copy link
Member

Janpot commented Aug 29, 2024

Ah ok, so I guess it's about whether to give the option of a slot as menu item versus changing it to a popover component that can show any UI (like the Google UI you shared) through a slot.

No, it's already a popover, this PR is changing it to a menu

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 29, 2024
@prakhargupta1
Copy link
Member

No, it's already a popover, this PR is changing it to a menu

Oh ok, in that case, I agree, a popover would be a more versatile choice.

@bharatkashyap
Copy link
Member Author

Updated to use Popover instead of Menu by default

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 29, 2024
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 30, 2024
@bharatkashyap bharatkashyap requested review from Janpot and removed request for Janpot August 30, 2024 10:40
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Sep 1, 2024
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Sep 2, 2024
Copy link
Member

@apedroferreira apedroferreira left a comment

Choose a reason for hiding this comment

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

Looks cool! Got some feedback mostly on docs/design, nothing major except generating the slots documentation automatically by exporting a type interface!

Some design feedback on this demo:

Screenshot 2024-09-06 at 18 51 14
  • The items aligned to the center don't look very good, it's better if they're aligned to the left.
  • There's too much space between the picture and the title and description, I think you can decrease the margin a bit! Not that important though if this is a default.
  • A Popover that opens another popover doesn't seem great, I guess a single list should work and be simpler too.

Some feedback on the new slots:

On a first read I'm not exactly sure what the menuItems slot replaces. Is it everything inside the Popover? Just the middle area? Maybe we could make it a bit clearer, even if just with the text in the docs.

Also, we're using localeText to customize labels, right? The current version of the preview docs seems not to be updated with that.

* @example { signInButton: { color: 'primary' }, signOutButton: { color: 'secondary' } }
* The components used for each slot inside.
*/
slots?: {
Copy link
Member

Choose a reason for hiding this comment

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

You need to export the Slots in their own interface to automatically generate the documentation for them.
Take a look at https://github.com/mui/mui-toolpad/blob/master/packages/toolpad-core/src/DashboardLayout/DashboardLayout.tsx, line 253, should be a simple change!

"signOutLabel": { "type": { "name": "string" }, "default": "'Sign Out'" },
"localeText": {
"type": { "name": "shape", "description": "{ signInLabel: string, signOutLabel: string }" },
"default": "DEFAULT_LABELS"
Copy link
Member

Choose a reason for hiding this comment

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

Does MUI X also list constants as defaults like this, even if they're not accessible for users?
Just curious, as not sure if there's a better way, but if it's following an existing pattern I guess it's fine!

Copy link
Member Author

Choose a reason for hiding this comment

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

@bharatkashyap
Copy link
Member Author

Looks cool! Got some feedback mostly on docs/design, nothing major except generating the slots documentation automatically by exporting a type interface!

Agree with almost everything here and addressed it!

A Popover that opens another popover doesn't seem great, I guess a single list should work and be simpler too.

Added this to demonstrate how one would be able to create such a menu if they want to. It's not an uncommon UX pattern, and I feel it should be okay to include as an example in the docs? Let me know what you think about that.

@apedroferreira
Copy link
Member

apedroferreira commented Sep 11, 2024

Added this to demonstrate how one would be able to create such a menu if they want to. It's not an uncommon UX pattern, and I feel it should be okay to include as an example in the docs? Let me know what you think about that.

Sounds good, it was a nit I wasn't too sure about anyway. (and I rechecked and it looks good now!)

Copy link
Member

@apedroferreira apedroferreira left a comment

Choose a reason for hiding this comment

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

Nice! The demo for the slots looks really good now!

`Account` can take different labels for the sign in and sign out buttons through the `signInLabel` and `signOutLabel` props. Deeper changes can be made by passing in `slotProps` to the underlying components.
The underlying `signInButton`, `signOutButton` and `iconButton` components can be customized by passing in `slotProps` to the `Account` component.

Labels for the sign in and sign out buttons through the `localeText` prop.
Copy link
Member

@apedroferreira apedroferreira Sep 11, 2024

Choose a reason for hiding this comment

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

I think this sentence about the labels is missing something ("can be customized"?).

@bharatkashyap bharatkashyap merged commit ae9bb1c into mui:master Sep 12, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This is not a bug, nor a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[core] Polish <Account /> component and docs
4 participants