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

[Alert][joy] Add Alert component #33859

Merged
merged 32 commits into from Aug 30, 2022
Merged

[Alert][joy] Add Alert component #33859

merged 32 commits into from Aug 30, 2022

Conversation

hbjORbj
Copy link
Member

@hbjORbj hbjORbj commented Aug 8, 2022

Done:

  • Initial implementation
  • Initial demos
  • Props: color, variant, onClose, closeText, etc; To be more discussed with Jun and Danilo

UPDATE:

  • Iterations on demos / props based on Jun / Danilo's feedback
  • Unit tests
  • Typescript tests

Preview: https://deploy-preview-33859--material-ui.netlify.app/joy-ui/react-alert/

@hbjORbj hbjORbj requested a review from siriwatknp August 8, 2022 12:57
@hbjORbj hbjORbj added new feature New feature or request component: alert This is the name of the generic UI component, not the React module! package: joy-ui Specific to @mui/joy labels Aug 8, 2022
@mui-bot
Copy link

mui-bot commented Aug 8, 2022

Details of bundle changes

@mui/joy: parsed: +1.13% , gzip: +0.61%

Generated by 🚫 dangerJS against 54f150b

@hbjORbj hbjORbj self-assigned this Aug 8, 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.

Looking great, Benny! Thanks for kick-starting this out!
Refined the component a bit and added a couple of other sections there to the docs. Looking forward to knowing what you two think about it!

Lastly, a quick question: will we support something similar to the AlertTitle component?

@hbjORbj
Copy link
Member Author

hbjORbj commented Aug 9, 2022

@danilo-leal

It looks much much nicer! I see that you've changed the default variant to soft in the playground. I will do the same in the implementation.

Lastly, a quick question: will we support something similar to the AlertTitle component?

I will let @siriwatknp answer this.

@siriwatknp
Copy link
Member

siriwatknp commented Aug 16, 2022

@hbjORbj Thanks for the hard work

Here are things I think can be improved:

HTML structure

Let's keep the rendered HTML simple. I am not sure why Material UI produces many div but I think this is simpler:

<Alert>...</Alert>

// The result should be just 1 div
<div role="alert" class="JoyAlert-root">...</div>

// not this
<div role="alert" class="JoyAlert-root">
  <div class="JoyAlert-message">...</div>
</div>

Size

It should have size prop which controls the icon and text font size. (similar to other components, e.g. Button)

Decorator

The alert should accept startDecorator and endDecorator similar to other components, e.g. Input.

You can remove the icon and action props.

The usage should be like this:

<Alert startDecorator={<Icon />} endDecorator={<IconButton><Close /></IconButton>}>
  <Typography fontWeight="lg" mb={1}>Alert title</Typography>
  <Typography level="body2">Description</Typography>
</Alert>

CSS variables

It should have:

  • --Alert-radius
  • --Alert-gap
  • --Alert-padding

You can take a look at the Input component. It is quite similar.

AlertTitle

I don't see a need for the AlertTitle at this point. Let's try to create demos using Typography first.

Common examples

Can you add some of these to the common examples section:

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 22, 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 25, 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.

Looks great, Benny! Nice work 👌

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 28, 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 28, 2022
@siriwatknp
Copy link
Member

@hbjORbj The implementation looks good to me. What's left are:

  • component tests (also add the testCustomVariant: true to the describeConformance, it ensures that the component does not break when a custom variant is provided.)
  • add the AlertOwnerState to components.d.ts
  • add to extendTheme.spec.ts

@hbjORbj
Copy link
Member Author

hbjORbj commented Aug 29, 2022

Done:

  • ✅ component tests (also add the testCustomVariant: true to the describeConformance, it ensures that the component does not break when a custom variant is provided.)
  • ✅ add the AlertOwnerState to components.d.ts
  • ✅ add to extendTheme.spec.ts

Copy link
Member

@siriwatknp siriwatknp left a comment

Choose a reason for hiding this comment

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

👍 Awesome @hbjORbj

@hbjORbj hbjORbj changed the title [Joy] Add Alert component [Alert][joy] Add Alert component Aug 30, 2022
@hbjORbj hbjORbj merged commit 2fdf868 into mui:master Aug 30, 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: alert This is the name of the generic UI component, not the React module! new feature New feature or request package: joy-ui Specific to @mui/joy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants