-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
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
[Joy] Support slots
/slotsProps
for every component (components with only root slot too)
#36540
Conversation
Netlify deploy previewhttps://deploy-preview-36540--material-ui.netlify.app/ @mui/joy: parsed: +0.44% , gzip: +0.16% Bundle size report |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow-up on (4) of #36490 (comment)
I'm not sure about this direction. When I land on the page, I assume that I can do slots={{ root }}
but it's not the case. What I was wondering there is about the class names. I wonder if there is a way (design-wise) to communicate this. Maybe it's about having more columns. As a developer, I would want to understand, that I can use a class name, a theme component style override but instead of slots.root
=> component
.
|
||
export type CardSlot = 'root'; | ||
|
||
export interface CardSlots { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume that we can't export any of these types since there is no slots
prop?
export interface CardSlots { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hbjORbj Is it necessary to export these interfaces (including other components)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For other components, yes, we need to export this to read the JSDoc and generated API docs. More specifically, parseSlots
function needs it. https://github.com/mui/material-ui/blob/master/packages/api-docs-builder/utils/parseSlots.ts
If my understanding is correct, what you are asking should be done in a separate PR? |
@oliviertassinari @siriwatknp During the Friday backlog grooming session, I brought up this topic (displaying classnames for Joy/Base in API docs), and Marija/Michal/I agreed on creating a new section where we list the classnames except those already displayed in "Default class" column under "Slots" section. I am preparing a PR for this. After I create this PR, we can discuss again to make adjustments. |
I guess the PR in question is #36589. It's connected, but these seems different problems: modifier class names vs. class names of components without |
I agree that Joy users might expect slots/slotProps to work for every component regardless of the number of slots. They won't check the API reference to know if the component supports these props or not, but rather they just go for these props because they are used to using them. Even if they realise that these props aren't supported, they will be confused because they don't know why they aren't. I think we have first clearly communicate that cc @siriwatknp |
👍 All in. All components should support <MenuButton slots={{ root: IconButton }}>
<Icon />
</MenuButton>
That will be done by #34990 |
slots
/slotsProps
for components with only root slot too
I made a change so that Joy components that only have root slot also support |
f2d3781
to
7a6cccd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hbjORbj I think some components like Card need to import and use useSlot
because it currently does not accept slots
or slotProps
.
@siriwatknp You are right. My bad for missing that. Doing it now! UPDATE: All ready, I think. |
slots
/slotsProps
for components with only root slot tooslots
/slotsProps
for every component (components with only root slot too)
packages/mui-joy/src/Menu/Menu.tsx
Outdated
open, | ||
disablePortal, | ||
keepMounted, | ||
as: PopperUnstyled, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@siriwatknp Reminder |
74df72d
to
2570f01
Compare
I think we can merge this? I rebased this branch on top of #36599 Here's a filter of relevant commits for easier review: https://github.com/mui/material-ui/pull/36540/files/f7d03cd84301166c96df417ed8fc47e356c1c85a..01cb82b550c119222d5babde2c90dca12d5b3d64 UPDATE: Merged #36599. This PR is rebased. Ready for merge. |
Follow-up on (4) of #36490 (comment)
Changes
slots
/slotProps
Preview: e.g., https://deploy-preview-36540--material-ui.netlify.app/joy-ui/api/card/#slots