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] Add section about overriding slots to base concepts #10421

Merged
merged 13 commits into from
Oct 4, 2023

Conversation

noraleonte
Copy link
Contributor

closes #9285

@noraleonte noraleonte added the docs Improvements or additions to the documentation label Sep 21, 2023
@noraleonte
Copy link
Contributor Author

I am opening this one up for review.
I added a new section to the base concepts page, explaining what slots and slotProps are. Added a very simple example overriding just the openPickerIcon, as well as a more complex one, and a link to the dedicated page for this type of customization. I feel like the Custom slots and subcomponents page tackles enough complex examples (as mentioned here) but this feels like a good gateway to get there. Let me know what you think, if you'd add something, change the description/examples in any way. 🤙 🌵

@mui-bot
Copy link

mui-bot commented Sep 21, 2023

@LukasTy LukasTy added the component: pickers This is the name of the generic UI component, not the React module! label Sep 21, 2023
Copy link
Member

@LukasTy LukasTy left a comment

Choose a reason for hiding this comment

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

Thank you for taking the time to improve this misleading and mysterious concept. 🙈

docs/data/date-pickers/base-concepts/CustomSlots.tsx Outdated Show resolved Hide resolved
docs/data/date-pickers/base-concepts/base-concepts.md Outdated Show resolved Hide resolved
docs/data/date-pickers/base-concepts/base-concepts.md Outdated Show resolved Hide resolved
docs/data/date-pickers/base-concepts/base-concepts.md Outdated Show resolved Hide resolved
docs/data/date-pickers/base-concepts/base-concepts.md Outdated Show resolved Hide resolved
docs/data/date-pickers/base-concepts/base-concepts.md Outdated Show resolved Hide resolved
docs/data/date-pickers/base-concepts/base-concepts.md Outdated Show resolved Hide resolved
@@ -1,10 +1,10 @@
---
productId: x-date-pickers
title: Date and Time Pickers - Custom subcomponents
title: Date and Time Pickers - Custom slots and subcomponents
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about not renaming the menu item and it's heading? 🤔
Technically, almost all the Visual customization pages are about custom slots. 🙈

Maybe it's already time to rename all or most of the components word mentions on this page into slots? 🤔
Or at least only rename the section below to Overriding slot components or Overidding slots?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am somewhat in favor of leaving at least some mention of the word 'subcomponent' 🤔
I am not sure how easy it is for someone who is starting out on this doc to make the connection between slot and subcomponent 🤔
I am open to suggestions on this

Technically, almost all the Visual customization pages are about custom slots

Yeah, that is true. I feel like the other pages are more focused on specific use-cases. This one includes more scenarios and is somewhat of a gateway into understanding slots better. It would still make sense to have the slots mentioned in the menu as well 🤔

rename the section below to Overriding slot components or Overidding slots

totally agree 👍

Copy link
Member

Choose a reason for hiding this comment

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

Would you agree that eventually, this page will become an home page for slot customization but all the actual examples will be moved to standalone pages (like we started doing)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, it probably will. And I would be in favor of using the term 'components' less and less, but maybe removing 'subcomponents' entirely from the headings is not the way to go 🤔 I feel like it's clear to us that slots are actually building blocks that you can override, but is it clear to users at a first look? So if somebody is on the docs, trying to figure out how to replace the openPickerIcon, which menu item is more self-explanatory 'Custom slots' or 'Custom slots and subcomponents'?

Copy link
Member

Choose a reason for hiding this comment

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

I agree that "slot" is not understandable by people reaching to the doc for the 1st time

Copy link
Member

Choose a reason for hiding this comment

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

If there are no other objections, I'm fine with the suggested renaming. 👌

Copy link
Member

Choose a reason for hiding this comment

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

What about using a verb to describe what the user would actually do with this information? For example, the Base and Joy docs on this topic use the title "Overriding component structure", which IMO gives the reader a much better idea of how to apply this information, and doesn't require any knowledge of MUI-specific terminology.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Overriding component structure is definitely a super valid option 💯 But in our case, I feel like it would add a bit of inconsistency, especially since the Visual customization section includes a number of other pages, most of them named like this:
image
I like the idea of introducing the word 'slots' to suggest the link between slots and subcomponents (also helps the search of either of these terms), and revisiting this topic in a broader refactor of the docs structure. WDYT about this?

Copy link
Member

@samuelsycamore samuelsycamore left a comment

Choose a reason for hiding this comment

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

Big improvement! I left a couple style suggestions here.

Also: have you seen this page on Overriding component structure from the Base UI docs? I think it's helpful to present the mental model for slots, particularly this line:

"A component's structure is determined by the elements that fill that component's slots. Slots are most commonly filled by HTML tags, but may also be filled by React components."

Maybe it would be worth adding this line and/or a link back to this Base UI doc here?

docs/data/date-pickers/base-concepts/base-concepts.md Outdated Show resolved Hide resolved
docs/data/date-pickers/base-concepts/base-concepts.md Outdated Show resolved Hide resolved
docs/data/date-pickers/base-concepts/base-concepts.md Outdated Show resolved Hide resolved
@samuelsycamore
Copy link
Member

Also: please feel free to ping me for a review on any and all docs PRs over here on the X side of things! 💙

Copy link
Member

@LukasTy LukasTy left a comment

Choose a reason for hiding this comment

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

Very nice improvement! 🙌

docs/data/date-pickers/base-concepts/CustomSlots.tsx Outdated Show resolved Hide resolved
docs/data/date-pickers/base-concepts/base-concepts.md Outdated Show resolved Hide resolved
docs/data/date-pickers/base-concepts/base-concepts.md Outdated Show resolved Hide resolved
docs/data/date-pickers/base-concepts/base-concepts.md Outdated Show resolved Hide resolved
@@ -1,10 +1,10 @@
---
productId: x-date-pickers
title: Date and Time Pickers - Custom subcomponents
title: Date and Time Pickers - Custom slots and subcomponents
Copy link
Member

Choose a reason for hiding this comment

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

If there are no other objections, I'm fine with the suggested renaming. 👌

Copy link
Member

@samuelsycamore samuelsycamore left a comment

Choose a reason for hiding this comment

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

One small nitpick on style here but otherwise I'd say it's good to go!

@noraleonte noraleonte merged commit 8cafb55 into mui:master Oct 4, 2023
18 checks passed
@noraleonte noraleonte deleted the add-slots-customization-example branch October 4, 2023 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pickers This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants