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

[website] Fix design kits showcase throwing an error #35093

Merged
merged 4 commits into from Nov 14, 2022

Conversation

cherniavskii
Copy link
Member

@cherniavskii cherniavskii added the website Pages that are not documentation-related, marketing-focused. label Nov 10, 2022
@mui-bot
Copy link

mui-bot commented Nov 10, 2022

Messages
📖 Netlify deploy preview: https://deploy-preview-35093--material-ui.netlify.app/

No bundle size changes

Generated by 🚫 dangerJS against dfc1b0d

@@ -259,10 +259,11 @@ export default function DesignKits() {
...theme.applyDarkStyles({
background: `linear-gradient(to bottom, ${
(theme.vars || theme).palette.primaryDark[900]
} 0%, ${alpha((theme.vars || theme).palette.primaryDark[900], 0)} 30%, ${alpha(
Copy link
Member Author

Choose a reason for hiding this comment

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

Alpha channel was set to 0 anyway, so I just used transparent color instead.

Copy link
Member

Choose a reason for hiding this comment

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

Good point.

} 0%, ${alpha((theme.vars || theme).palette.primaryDark[900], 0)} 30%, ${alpha(
(theme.vars || theme).palette.primaryDark[900],
0,
)} 70%, ${(theme.vars || theme).palette.primaryDark[900]} 100%)`,
Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder what is the alternative for alpha/lighten/darken utility functions when using CSS variables?
For alpha, something like this should work, right?

'rgba(${theme.vars.palette.primary.mainChannel} / 0.5'

But then, not every color in the palette has a xxxChannel representation.

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe we observed a similar problem in mui/mui-x#6784

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

'rgba(${theme.vars.palette.primary.mainChannel} / 0.5' this is correct, and yes, we are generating channels for some colors not all.

Copy link
Member Author

Choose a reason for hiding this comment

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

What about this case?

'rgba(${theme.vars.palette.primaryDark[900]} / 0.5)'

The above won't work, and there's no channel for primaryDark[900] color.

Copy link
Member

Choose a reason for hiding this comment

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

rgba(${theme.vars.palette.primaryDark[900]} / 0.5)

Where is it? The gradient looks fine to me.

0,
)} 70%, ${(theme.vars || theme).palette.primaryDark[900]} 100%)`,
} 0%, ${
'rgba(255,255,255,0)' // transparent does not work in Safari & Mobile device
Copy link
Member

Choose a reason for hiding this comment

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

Is this intended to be"Safari on iOS", or "Safari and mobile device(s)", in which case, which?

Copy link
Member Author

Choose a reason for hiding this comment

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

Initially, I wanted to use 'transparent', but then I noticed this comment and copied it:

'rgba(255,255,255,0)' // transparent does not work in Safari & Mobile device

In https://css-tricks.com/thing-know-gradients-transparent-black/ it says it's Safari - both desktop and mobile.
But it's an article from 2017 and using 'transparent' doesn't seem to make any difference in Safari 16:

Screen.Recording.2022-11-10.at.19.47.41.mov

I'll update the comments to only mention Safari and also link to the article above.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, using rgba(255,255,255,0) everywhere didn't look good in Safari. I'll push a fix

Signed-off-by: Olivier Tassinari <olivier.tassinari@gmail.com>
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.

👍 Thanks! @cherniavskii

@cherniavskii cherniavskii marked this pull request as ready for review November 11, 2022 10:35
Copy link

@acrodemocide acrodemocide left a comment

Choose a reason for hiding this comment

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

It looks like this pull request indicates that the rgba settings do with for safari. If that's right then I think this is good to go. Does rgba still not work for mobile devices?

I like the choice to define the transparent setting above and reuse it. Helped clean things up.

@cherniavskii
Copy link
Member Author

cherniavskii commented Nov 14, 2022

Does rgba still not work for mobile devices?

It's not about rgba not working, it's about Safari treating transparent black and transparent white colors differently - see https://css-tricks.com/thing-know-gradients-transparent-black/

@michaldudak michaldudak merged commit fb4bafc into mui:master Nov 14, 2022
@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work regression A bug, but worse labels Nov 14, 2022
@cherniavskii cherniavskii deleted the fix-design-kits-showcase branch November 14, 2022 13:40
the-mgi pushed a commit to the-mgi/material-ui that referenced this pull request Nov 17, 2022
Signed-off-by: Olivier Tassinari <olivier.tassinari@gmail.com>
Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
Co-authored-by: Michał Dudak <michal@dudak.me>
daniel-rabe pushed a commit to daniel-rabe/material-ui that referenced this pull request Nov 29, 2022
Signed-off-by: Olivier Tassinari <olivier.tassinari@gmail.com>
Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
Co-authored-by: Michał Dudak <michal@dudak.me>
feliperli pushed a commit to jesrodri/material-ui that referenced this pull request Dec 6, 2022
Signed-off-by: Olivier Tassinari <olivier.tassinari@gmail.com>
Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
Co-authored-by: Michał Dudak <michal@dudak.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work regression A bug, but worse website Pages that are not documentation-related, marketing-focused.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants