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

[CardOverflow][joy-ui] Remove conditional CSS to support Next.js App dir #39101

Merged
merged 4 commits into from
Oct 20, 2023

Conversation

siriwatknp
Copy link
Member

closes #38791

Replace conditional CSS with CSS variables to keep CSS specificity to (0,1,0).

@siriwatknp siriwatknp requested a review from sai6855 September 22, 2023 05:33
Comment on lines +50 to +52
margin: 'var(--_CardOverflow-margin)',
borderRadius: 'var(--_CardOverflow-radius)',
padding: 'var(--_CardOverflow-padding)',
Copy link
Member Author

Choose a reason for hiding this comment

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

Without using internal CSS variables, the developer will need to override these properties with a selector to beat the [.${cardClasses.horizontal} > &] and [data-first-child][data-last-child].

@siriwatknp siriwatknp added bug 🐛 Something doesn't work component: card This is the name of the generic UI component, not the React module! package: joy-ui Specific to @mui/joy labels Sep 22, 2023
@mui-bot
Copy link

mui-bot commented Sep 22, 2023

Netlify deploy preview

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

Bundle size report

Details of bundle changes (Toolpad)
Details of bundle changes

Generated by 🚫 dangerJS against ab70229

@sai6855
Copy link
Contributor

sai6855 commented Sep 22, 2023

I believe issue arises from muiName being not available for server components, But for server components, muiName is avaiable in different path. It's react specific change and not a nextjs change. So instead of fixing individual components, do you think it's better to add generalized fix? This PR just added fix to Grid but we could add that to isMuiElement util

@siriwatknp
Copy link
Member Author

I believe issue arises from muiName being not available for server components, But for server components, muiName is avaiable in different path. It's react specific change and not a nextjs change. So instead of fixing individual components, do you think it's better to add generalized fix? This PR just added fix to Grid but we could add that to isMuiElement util

Ideally, we should not have used muiName if possible so I think this PR fixes the issue and also prepares the component for migrating to zero-runtime package as well.

Copy link
Contributor

@sai6855 sai6855 left a comment

Choose a reason for hiding this comment

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

It's working fine here , click on server page link to see refelcted changes.

@siriwatknp siriwatknp requested a review from mnajdova September 22, 2023 08:20
margin: 'var(--_CardOverflow-margin)',
borderRadius: 'var(--_CardOverflow-radius)',
padding: 'var(--_CardOverflow-padding)',
[`.${cardClasses.horizontal} > &`]: {
Copy link
Member

Choose a reason for hiding this comment

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

When is this class being set? Isn't this a parent classname?

Copy link
Member

Choose a reason for hiding this comment

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

Do we expect people to set it themselves?

Copy link
Member Author

Choose a reason for hiding this comment

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

When is this class being set?

It is set by the Card component. The CardOverflow should be used as a direct child of the Card.

Do we expect people to set it themselves?

Nope, they don't need to.

Copy link
Member

@mnajdova mnajdova Oct 19, 2023

Choose a reason for hiding this comment

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

Aaah, we are basically using a parent selector to style the current component, nicee :D I never thought of using this, or more I didn't even know it is possible :)

@siriwatknp siriwatknp requested a review from mnajdova September 26, 2023 02:14
@siriwatknp
Copy link
Member Author

@mnajdova in case you missed this one.

Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

I could verify that it works as expected here https://codesandbox.io/p/github/jamesxv7/joy-ui-nextjs-ts/csb-3jkvzn/draft/gallant-platform?file=%2Fpackage-lock.json%3A12%2C36. I would recommend next time to link a sandbox with the test-case & the fix so that we don't have to manually do it.

@siriwatknp siriwatknp merged commit 1657fbd into mui:master Oct 20, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: card This is the name of the generic UI component, not the React module! nextjs package: joy-ui Specific to @mui/joy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[joy-ui] In the Next.js app router example, card overflow component is not rendered as per demo
5 participants