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 the slots concept introduction page #13881

Open
wants to merge 41 commits into
base: master
Choose a base branch
from

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Jul 18, 2024

Closes #13354
Doc preview

Todo

  • Add PropsFromSlot to charts and tree view
  • Create the issues to add module augmentation on every package

@flaviendelangle flaviendelangle added the docs Improvements or additions to the documentation label Jul 18, 2024
@flaviendelangle flaviendelangle self-assigned this Jul 18, 2024
## Slot props

To override default props or pass custom props to slot components, use the `slotProps` prop.
## Custom slot props with TypeScript
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 kept the module augmentation doc here for now because only the grid has it so it felt weird to movie it fully to the shared page.

@@ -21,6 +20,13 @@ const pages: MuiPage[] = [
{ pathname: `/x/introduction/roadmap` },
],
},
{
pathname: '/x/common-features-group',
Copy link
Member Author

Choose a reason for hiding this comment

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

Do we have other pages to move here?
It felt weird to me to put this in "Introduction", which is why I chose to create a new folder

Copy link
Member

Choose a reason for hiding this comment

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

Maybe the loacalization. Even if it's not yet supported for chart

Copy link
Member Author

Choose a reason for hiding this comment

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

Might make sense at some point indeed
I was thinking about existing pages, but for new pages it's definitely a good candidate once we have at least 3 sets of components supporting it.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jul 25, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jul 26, 2024
@LukasTy LukasTy changed the title [docs] Create a new page to introduce the concept of slots [docs] Add a slots concept introduction page Jul 31, 2024
@LukasTy LukasTy changed the title [docs] Add a slots concept introduction page [docs] Add the slots concept introduction page Jul 31, 2024
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 1, 2024
Copy link

github-actions bot commented Aug 1, 2024

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 2, 2024
Copy link

github-actions bot commented Aug 9, 2024

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 9, 2024

<p class="description">Learn how to override parts of the MUI X components.</p>

## What is a slot?
Copy link
Member

Choose a reason for hiding this comment

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

@flaviendelangle I think we could use a deeper explanation here. Have you seen this piece on overriding component structure from the Core docs? I really like the "mental model" section for explaining what a slot is. I think we could repurpose some of the content there and update it to make sense in the X context.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea

But some of the content there do not apply well for component of the size of the one in X.
For instance:

Slots are most commonly filled by HTML tags, but may also be filled by React components.

This is wrong for X, very few slots in X are filled by HTML tags.
The vast majority are filled by React components which have several HTML tags.

All components contain a root slot that defines their primary node in the DOM tree; more complex components also contain additional interior slots named after the elements they represent.

I think every single X component has internal slots.
And I'm not 100% sure that every single X component has a root slot (but they probably should).


I'll try to re-work the section to keep the good parts of the core doc without putting things that don't make sense for X.

Copy link
Member Author

Choose a reason for hiding this comment

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

@samuelsycamore I expended a bit the "What is a slot" section.

I don't think there is a lot of info in the core section that are relevant here tbh.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 12, 2024
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 19, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added PR: out-of-date The pull request has merge conflicts and can't be merged and removed PR: out-of-date The pull request has merge conflicts and can't be merged labels Aug 19, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[docs] Create a new page to introduce the concept of slots and slotProps
6 participants