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

[Skeleton][material-ui] Add new props to the Skeleton component #38483

Merged
merged 14 commits into from
Sep 22, 2023
Merged

[Skeleton][material-ui] Add new props to the Skeleton component #38483

merged 14 commits into from
Sep 22, 2023

Conversation

gitstart
Copy link
Contributor

Description

Added new props to the Skeleton component. The props added are

  • shape: determines the shape of the skeleton, whether circular, rectangular or rounded.
  • size: set the adaptation of the skeleton component.

Also deprecated variant in favor of the two new props.

Closes #38190


This code was written and reviewed by GitStart Community. Growing great engineers, one PR at a time.

Co-authored-by: seunexplicit <48022904+seunexplicit@users.noreply.github.com>
@danilo-leal danilo-leal changed the title MUI-38190 - [Skeleton][material] inferring dimensions only works for "text" variant [Skeleton][material-ui] Add new props to the Skeleton component Aug 15, 2023
@danilo-leal danilo-leal added package: material-ui Specific to @mui/material component: skeleton This is the name of the generic UI component, not the React module! labels Aug 15, 2023
@gitstart gitstart marked this pull request as ready for review August 15, 2023 12:28
@gitstart
Copy link
Contributor Author

@DiegoAndai this PR is ready for review

@DiegoAndai DiegoAndai self-requested a review August 15, 2023 13:12
Copy link
Member

@DiegoAndai DiegoAndai left a comment

Choose a reason for hiding this comment

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

Hey @gitstart, thanks for working on this!

I left some comments for review. Also, we need to add tests:

  • Tests for the current variant behavior, so we're sure we're not breaking current behavior
  • Test for the new size and shape props

packages/mui-material/src/Skeleton/skeletonClasses.ts Outdated Show resolved Hide resolved
packages/mui-material/src/Skeleton/skeletonClasses.ts Outdated Show resolved Hide resolved
packages/mui-material/src/Skeleton/Skeleton.d.ts Outdated Show resolved Hide resolved
packages/mui-material/src/Skeleton/Skeleton.js Outdated Show resolved Hide resolved
gitstart and others added 2 commits August 23, 2023 14:28
Co-authored-by: seunexplicit <48022904+seunexplicit@users.noreply.github.com>
@gitstart
Copy link
Contributor Author

@DiegoAndai your feedback has been implemented.

@gitstart gitstart requested a review from DiegoAndai August 23, 2023 14:53
@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, 2023
@DiegoAndai
Copy link
Member

@gitstart the code looks ready to me 🎉

Can you update the Skeleton documentation page? It should reflect that users should use size and shape instead of variant:

  • Replace the Variants sections with separate Size and Shape sections
  • Replace any use of variant in the examples, as well as the explanations related to it, with the size or shape props

We also need to merge the master branch into this branch to remove the merge conflict 😊

Co-authored-by: seunexplicit <48022904+seunexplicit@users.noreply.github.com>
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Sep 4, 2023
Copy link
Member

@DiegoAndai DiegoAndai left a comment

Choose a reason for hiding this comment

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

Hey @gitstart, here's a couple fixes that I found reviewing the new documentation

Comment on lines 66 to 67
styles[ownerState.shape],
styles[ownerState.size],
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
styles[ownerState.shape],
styles[ownerState.size],
ownerState.shape && styles[ownerState.shape],
ownerState.size && styles[ownerState.size],

@@ -82,7 +83,7 @@ const SkeletonRoot = styled('span', {
? theme.vars.palette.Skeleton.bg
: alpha(theme.palette.text.primary, theme.palette.mode === 'light' ? 0.11 : 0.13),
height: '1.2em',
...(ownerState.variant === 'text' && {
...(ownerState.size === 'text' && {
Copy link
Member

Choose a reason for hiding this comment

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

We should remove the borderRadius style on line 92, as the shape, not the size, should control it.

gitstart and others added 4 commits September 6, 2023 09:55
Co-authored-by: seunexplicit <48022904+seunexplicit@users.noreply.github.com>
Co-authored-by: seunexplicit <48022904+seunexplicit@users.noreply.github.com>
@gitstart
Copy link
Contributor Author

gitstart commented Sep 6, 2023

@DiegoAndai your feedback has been implemented, thanks for the review.

@gitstart gitstart requested a review from DiegoAndai September 6, 2023 18:33
Copy link
Member

@DiegoAndai DiegoAndai left a comment

Choose a reason for hiding this comment

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

Hey @gitstart, so sorry for the delayed review

Here's one last fix (I think) we should do. Let me know if it makes sense to you.

Comment on lines 95 to 97
...(ownerState.shape === 'rounded' && {
borderRadius: (theme.vars || theme).shape.borderRadius,
}),
Copy link
Member

Choose a reason for hiding this comment

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

The "text" variant was the default, and it had rounded borders. We removed that style from the "text" styles above, which is correct, but we should keep the being rounded as before.

To achieve this, we should take borderRadius: (theme.vars || theme).shape.borderRadius out of this conditional, and add it to the base styles. We should add a ownerState.shape === 'rectangular' conditional style that would set borderRadius: 0

gitstart and others added 3 commits September 22, 2023 05:49
Co-authored-by: seunexplicit <48022904+seunexplicit@users.noreply.github.com>
Co-authored-by: seunexplicit <48022904+seunexplicit@users.noreply.github.com>
@gitstart
Copy link
Contributor Author

@DiegoAndai your feedback has been implemented.

Signed-off-by: Diego Andai <diego@mui.com>
Signed-off-by: Diego Andai <diego@mui.com>
Signed-off-by: Diego Andai <diego@mui.com>
Copy link
Member

@DiegoAndai DiegoAndai left a comment

Choose a reason for hiding this comment

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

Great work @gitstart 👏🏼
I'm very happy to be merging this one 🎉

@DiegoAndai DiegoAndai merged commit cab11f2 into mui:master Sep 22, 2023
@oliviertassinari
Copy link
Member

oliviertassinari commented Sep 24, 2023

In terms of behavior, I think it would be great to update the docs to still encourage the use of the variant.

This seems to be the same case as in https://mui.com/material-ui/react-alert/ with the severity = color + icon. In the large majority of the cases, the variant should be enough but here might be cases where developers want to unbundle the prop variant = shape + size.

Personally, it would be more intuitive for me to use the sx prop over the shape prop, but I can also understand why some people would use it.

However, I also think that we should drop the variant=rounded prop. This is a purely stylistics prop, it's not about describing the app structure. It's what Joy UI is doing https://mui.com/joy-ui/react-skeleton/#geometry, it makes more sense IMHO. Which I think illustrate why we should move Joy UI and Material UI at the same time, it helps either pick the best option, or to be mindful about going with a different tradeoff to cater for different personas.

In any cases, #38190 feels like an issue that is for the <10% of the users, so I think we should only slightly change the product for it.

mnajdova pushed a commit to mnajdova/material-ui that referenced this pull request Sep 25, 2023
DiegoAndai added a commit to DiegoAndai/material-ui that referenced this pull request Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: skeleton This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Skeleton][material][joy] inferring dimensions only works for "text" variant
5 participants