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

[Joy UI] Add Modal component #34043

Merged
merged 37 commits into from Sep 8, 2022
Merged

[Joy UI] Add Modal component #34043

merged 37 commits into from Sep 8, 2022

Conversation

siriwatknp
Copy link
Member

@siriwatknp siriwatknp commented Aug 23, 2022

Preview: https://deploy-preview-34043--material-ui.netlify.app/joy-ui/react-modal/

Joy provides 3 modal components (I decided not to create a Dialog component yet):

  • Modal (similar to Material UI)
  • ModalClose (new): a handy close button that fits nicely with the Modal, ModalDialog
  • ModalDialog (new): for rendering a role="dialog" modal
  • ModalDialogTitle (similar to Material UI's DialogTitle) bind with ModalDialog's aria-labelledby attribute. (continue in a separate PR)
  • ModalDialogDescription (new): this component handles the binding logic with the ModalDialog similar to ModalDialogTitle but with aria-describedby attribute. (continue in a separate PR)

According to WAI ARIA, dialog can be modal or non-modal.

It is more explicit to render a modal dialog with ModalDialog component. The good part is that it produces a single DOM which is easier to customize compare to the Material UI's Dialog. To display an alert dialog, just switch to role="alertdialog".

Note: Material UI's Dialog is specific to Material Design's Dialog which is not the same as WAI ARIA.


@siriwatknp siriwatknp added docs Improvements or additions to the documentation package: joy-ui Specific to @mui/joy labels Aug 23, 2022
@mui-bot
Copy link

mui-bot commented Aug 23, 2022

Details of bundle changes

@mui/joy: parsed: +4.91% , gzip: +5.15%

Generated by 🚫 dangerJS against 3063797

@siriwatknp siriwatknp changed the title [Moda][Joy] Implement Modal component [Modal][Joy] Implement Modal component Aug 23, 2022
@siriwatknp siriwatknp marked this pull request as ready for review August 23, 2022 09:28
@siriwatknp siriwatknp added the component: modal This is the name of the generic UI component, not the React module! label Aug 23, 2022
@Sandeep06Dev
Copy link
Contributor

I think we should have consider on these two :

1. In the demo of Full-screen Modal, it will be good to have a exit button.
2. No Transition effect example? Previously we have this https://mui.com/material-ui/react-dialog/#transitions

@siriwatknp
Copy link
Member Author

  1. In the demo of Full-screen Modal, it will be good to have a exit button.

Good call, will add it to the demo.

  1. No Transition effect example? Previously we have this https://mui.com/material-ui/react-dialog/#transitions

In the first stage of Joy, I won't add built-in transition props to keep the component lean as much as possible. However, I do understand that the transition is quite important from the UX perspective, so I will add a demo on how to integrate other transition/animation libraries with Joy UI.

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

@danilo-leal danilo-leal left a comment

Choose a reason for hiding this comment

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

This is looking great so far! A few considerations that popped up while reviewing it:

  • We probably could make this clearer but are the ModalDialogTitle and ModalDialogDescription able to receive the same props as the Typography component? I see how that wouldn't make sense_but_ I also see how that would be intuitive to expect (I did, in fact, while doing the small doc demos tweaks).
  • Directly related to that, should we say something about using a Typography element inside any of these two? Is this ok to do or to avoid? What are the use cases I'd want to do that?
  • Are we missing a ModalOverlay component? How do I customize that?
  • Should we add a prop for easily centering the modal both horizontally and vertically? That would be handy.
  • Should we add the capacity control whether or not clicking on the overlay closes the modal/dialog?

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 24, 2022
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 31, 2022
@siriwatknp
Copy link
Member Author

@danilo-leal Hey, I decided to remove the ModalDialogTitle and ModalDialogDescription to make this PR smaller. I think we can continue the title and description in a separate PR to try out other alternatives. What do you think?

@danilo-leal
Copy link
Contributor

Sweet, ok! Two quick questions before we wrap this up:

  1. I know that in Material UI we place the Modal component within the Utils category, but should we keep doing that? It sounds intuitive to me to have it in a Feedback/Overlay category of sorts.
  2. Should we add an introduction/playgrund demo to it?

@siriwatknp
Copy link
Member Author

siriwatknp commented Sep 6, 2022

Sweet, ok! Two quick questions before we wrap this up:

  1. I know that in Material UI we place the Modal component within the Utils category, but should we keep doing that? It sounds intuitive to me to have it in a Feedback/Overlay category of sorts.

Agreed!

  1. Should we add an introduction/playgrund demo to it?

Added!

@danilo-leal
Copy link
Contributor

Awesome, this is looking great! One last thing I'm seeing is a discrepancy on the layout prop - on the docs, we say the Modal only supports center and fullScreen but the playground shows a possible top value 🤔

@siriwatknp
Copy link
Member Author

Awesome, this is looking great! One last thing I'm seeing is a discrepancy on the layout prop - on the docs, we say the Modal only supports center and fullScreen but the playground shows a possible top value 🤔

The top (the default value) has been added recently (it was null before which does not sound right when building the playground).

@danilo-leal
Copy link
Contributor

Should we make center the default, then? I'm struggling to find justification for the top value 🤔 It feels like something uncommon.

@siriwatknp
Copy link
Member Author

siriwatknp commented Sep 7, 2022

Should we make center the default, then? I'm struggling to find justification for the top value 🤔 It feels like something uncommon.

So, only center (default) and fullscreen, is that what you mean? Only 2 values look good enough to me, developers can extend it anyway.

@danilo-leal
Copy link
Contributor

Yup, that's it!

@siriwatknp
Copy link
Member Author

Yup, that's it!

Done!

Copy link
Contributor

@danilo-leal danilo-leal left a comment

Choose a reason for hiding this comment

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

Amazing, nice work Jun! 🎉

@danilo-leal danilo-leal changed the title [Modal][Joy] Implement Modal component [Joy UI] Add Modal component Sep 8, 2022
@siriwatknp siriwatknp merged commit c0424a5 into mui:master Sep 8, 2022
daniel-rabe pushed a commit to daniel-rabe/material-ui that referenced this pull request Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: modal This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation package: joy-ui Specific to @mui/joy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants