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

[docs][material-ui] Fixed incorrectly spread shadows in templates #43369

Closed
wants to merge 3 commits into from

Conversation

Andarist
Copy link
Contributor

All of those were spreading strings into arrays, resulting in many 1-character strings in the target array.

@ZeeshanTamboli ZeeshanTamboli changed the title Fixed incorrectly spread shadows in templates [docs][material-ui] Fixed incorrectly spread shadows in templates Aug 20, 2024
@ZeeshanTamboli ZeeshanTamboli requested a review from zanivan August 20, 2024 07:46
@ZeeshanTamboli ZeeshanTamboli added bug 🐛 Something doesn't work docs Improvements or additions to the documentation package: material-ui Specific to @mui/material design This is about UI or UX design, please involve a designer labels Aug 20, 2024
@mui-bot
Copy link

mui-bot commented Aug 20, 2024

Netlify deploy preview

https://deploy-preview-43369--material-ui.netlify.app/

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against c409963

@zanivan
Copy link
Contributor

zanivan commented Aug 20, 2024

Thanks for tackling this @Andarist! This was actually a workaround added in dc92ade to address the test_types check—that is currently failing :(

It'd be good If you could fix the reason why it is failing as well, otherwise we'll have to find another solution. Any suggestions? cc @siriwatknp

@Andarist
Copy link
Contributor Author

I can fix that issue but I need a little bit more context on it. What is this Shadows type even supposed to represent here? Why it's typed like this? 😅 Is "none" as the first item in that tuple a strong requirement? Does it always have to be a 25-item tuple? :D

@zanivan
Copy link
Contributor

zanivan commented Aug 20, 2024

I’ll provide a bit more context—this shadow is based on the levels defined in Material UI's default theme. There are 25 shadow levels in total, starting from 0: "none". You can see all the default shadow levels here.

The goal behind these changes was to use either the custom shadow or "none," with distinct shadows for both light and dark modes. cc @noraleonte

@Andarist
Copy link
Contributor Author

Andarist commented Aug 20, 2024

is the user required to configure all 25 levels? I understand they shouldn't configure more than 25 but is the system OK with less than 25?

@zanivan
Copy link
Contributor

zanivan commented Aug 20, 2024

is the user required to configure all 25 levels? I understand they shouldn't configure more than 25 but is the system OK with less than 25?

I think so—I believe the issue comes up when we set different shadows for light and dark modes. For more details, I’ll probably need input from @siriwatknp

@Andarist
Copy link
Contributor Author

Ok, so I made all of those shadows optional - this should address the issue (if I understand your constraints correctly)

@DiegoAndai
Copy link
Member

DiegoAndai commented Aug 27, 2024

The 25 shadows are expected if the user wants to override the theme. Otherwise, they could run into this:

Screenshot 2024-08-27 at 16 03 25

AFAIK this is the only place that would cause an error.

I think the proper fix here would be generating the 25 values for the templates theme, would that be possible @zanivan?

If not possible, then we can bypass it casting to Shadows (as Shadows), but people using the templates might run into the issue.

@zanivan
Copy link
Contributor

zanivan commented Aug 28, 2024

I think the proper fix here would be generating the 25 values for the templates theme, would that be possible @zanivan?

That’s possible, but I don’t see why someone would need 25 tokens for shadows, to be honest. I’m not even sure why Material UI has 25 values for it—I couldn’t find any resources about Material Design 2 that support this choice. While it does have elevation levels from 00dp to 24dp, there aren’t tokens for every single dp level.

All in all, I think the best approach is indeed to come up with shadows for all the 25 levels. I'll add this to the issue #41469 where we track the improvements for the templates (item 24).

@zanivan
Copy link
Contributor

zanivan commented Aug 28, 2024

Since this isn't the right fix for the issue, I’ll close this PR for now.

@zanivan zanivan closed this Aug 28, 2024
@DiegoAndai
Copy link
Member

@zanivan by the way, the approach used here is the correct one, besides the type change in Shadows, this seems incorrect:

...(mode === 'dark'
      ? 'hsla(220, 30%, 5%, 0.7) 0px 4px 16px 0px, hsla(220, 25%, 10%, 0.8) 0px 8px 16px -5px'
      : 'hsla(220, 30%, 5%, 0.07) 0px 4px 16px 0px, hsla(220, 25%, 10%, 0.07) 0px 8px 16px -5px'),

And I'm not sure why it's working 😅

If you think the 25 values are not required, we can warn users that they can't use up to certain elevations.

@Andarist
Copy link
Contributor Author

Yep, the runtime change here is 100% better than what you had before. Maybe it could be improved further - if the user has always to provide all 25 levels but I'm not sure. Anyway, I'll leave this for you to fix as you have better context on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work design This is about UI or UX design, please involve a designer docs Improvements or additions to the documentation package: material-ui Specific to @mui/material
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants