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

[core] Migrate nprogress to emotion #36181

Merged
merged 5 commits into from Feb 17, 2023
Merged

Conversation

siriwatknp
Copy link
Member

@siriwatknp siriwatknp commented Feb 14, 2023

My goal is to remove nprogress from the theme.


Related to #22486

@siriwatknp siriwatknp added core Infrastructure work going on behind the scenes scope: docs-infra Specific to the docs-infra product and removed core Infrastructure work going on behind the scenes labels Feb 14, 2023
Comment on lines -20 to -24
if (!theme.nprogress.color) {
throw new Error(
'MUI: You need to provide a `theme.nprogress.color` property' +
' for using the `NProgressBar` component.',
);
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 think there is no need to throw error if we use palette.primary.main from the theme.

@mui-bot
Copy link

mui-bot commented Feb 14, 2023

Netlify deploy preview

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

Bundle size report

No bundle size changes

Generated by 🚫 dangerJS against b555c4d

@@ -1,10 +1,10 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import NProgress from 'nprogress';
import { withStyles } from '@mui/styles';
Copy link
Member

Choose a reason for hiding this comment

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

Nice 👌

}),
'& .nprogress-bar': {
position: 'fixed',
backgroundColor: (theme.vars || theme).palette.primary.main,
Copy link
Member

Choose a reason for hiding this comment

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

The store uses a different value. https://github.com/mui/mui-store/blob/3933fb75c13040c53dc16f4ea4286f39e03b63ca/web/src/utils/theme.js#L125

How can developers configure it?

For the backstory, the component was created with the objective to expose it like https://mantine.dev/others/nprogress/. I think that it would be great to have it in the lab.

Copy link
Member Author

Choose a reason for hiding this comment

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

The store uses a different value. https://github.com/mui/mui-store/blob/3933fb75c13040c53dc16f4ea4286f39e03b63ca/web/src/utils/theme.js#L125

It was theme.palette.primary.main before migrating to emotion. I think it should be the same.

How can developers configure it?
For the backstory, the component was created with the objective to expose it like https://mantine.dev/others/nprogress/. I think that it would be great to have it in the lab.

I think this is out of the scope of this PR but I do agree that it'd be useful to have it in the lab. I suggest to create a separate issue to keep track of it.

Copy link
Member

Choose a reason for hiding this comment

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

@siriwatknp Actually, the store doesn't use NProgress.

I think this is out of the scope of this PR

Agree, but I think that we should get clarity on the path forward, so we can align the current solution with it. In this case, maybe the right approach would be:

  1. Migrate from @mui/styles to @mui/system (this PR)
  2. Expose the component in the lab
  3. Remove the dependency on nprogress
  4. Use styles rather than GlobalStyles so that developers can more easily use the sx prop to customize the component (unlocked by removing the dependency on nprogress).

Copy link
Member

Choose a reason for hiding this comment

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

So, I think that we are good for the customization, we can delay it until later.

Another issue I can notice is the contrast: Is there enough between light <-> main to see movement? It feels like no

Before:

Screen.Recording.2023-02-15.at.12.04.45.mov

After:

Screen.Recording.2023-02-15.at.12.06.25.mov

Copy link
Member Author

Choose a reason for hiding this comment

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

@oliviertassinari Fixed by using the same color as before.

Copy link
Member

@oliviertassinari oliviertassinari 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 great, happy to see us continue the migration to v5 and closer to make #22486 happen 👍

@oliviertassinari oliviertassinari added the component: nprogress This is the name of the generic UI component, not the React module! label Feb 16, 2023
@siriwatknp siriwatknp merged commit 6435d36 into mui:master Feb 17, 2023
left: 0,
right: 0,
height: 2,
zIndex: (theme.vars || theme).zIndex.tooltip,
Copy link
Member

Choose a reason for hiding this comment

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

Could this be (theme.vars || theme).zIndex?.tooltip ? theme.vars.zIndex is undefined @siriwatknp
Screenshot 2023-02-17 at 9 05 02 PM

Also on the deploy preview of this PR: https://deploy-preview-36181--material-ui.netlify.app/joy-ui/getting-started/overview/

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahhh, you are right. On the other hand, I think we could add zIndex to Joy UI as well. Will open a fix now.

Copy link
Member

Choose a reason for hiding this comment

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

The root cause seems to be that we have a theming isolation problem: Joy UI theme shouldn't be a parent of NProgress.

@siriwatknp siriwatknp mentioned this pull request Feb 17, 2023
1 task
borderRadius: '100%',
animation: `${muiNProgressPulse} 2s ease-out 0s infinite`,
},
'& .nprogress-bar > div:first-child': {
Copy link
Member

Choose a reason for hiding this comment

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

This warns on all the pages of the docs & website:

Screenshot 2023-02-20 at 00 34 38

Could we fix it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops! here is the fix => #36263

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: nprogress This is the name of the generic UI component, not the React module! scope: docs-infra Specific to the docs-infra product v5.x migration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants