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] Document the TreeItem2 component and the useTreeItem2 hook #14551

Merged
merged 21 commits into from
Oct 9, 2024

Conversation

noraleonte
Copy link
Contributor

Closes #13161

@noraleonte noraleonte added docs Improvements or additions to the documentation component: tree view TreeView, TreeItem. This is the name of the generic UI component, not the React module! labels Sep 9, 2024
@noraleonte noraleonte self-assigned this Sep 9, 2024

You can select an item of the Tree View by clicking its content slot. The demo below demonstrates how to handle selection when the user clicks on an icon.

{{"demo": "HandleSelectionDemo.js"}}
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 struggling to find a decent use-case/ idea for a demo for handleSelection and handleCheckboxSelection -> so any suggestions are welcome here.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Sep 10, 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 25, 2024

By default, a tree item is expanded when clicking the content. You can change the expansion trigger using the `expansionTrigger` prop to the `iconContainer`. Read more about the expansion API on the dedicated [documentation page](/x/react-tree-view/rich-tree-view/expansion/#limit-expansion-to-icon-container).

To achieve a deeper customization of the expansion of an item use the `handleExpansion` interaction method. The demo below demonstrates how to introduce a new element that expands or collapses the item.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
To achieve a deeper customization of the expansion of an item use the `handleExpansion` interaction method. The demo below demonstrates how to introduce a new element that expands or collapses the item.
Use the `handleExpansion` interaction method for deeper customization of Item expansion.
The demo below shows how to introduce a new element that expands and collapses the Item.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for deeper customization of Item expansion. sounds a bit weird to me 🤔 not sure why. Maybe for deeper customization of the Item's expansion behavior.?

Co-authored-by: Sycamore <71297412+samuelsycamore@users.noreply.github.com>
Signed-off-by: Nora <72460825+noraleonte@users.noreply.github.com>
Copy link
Contributor Author

@noraleonte noraleonte left a comment

Choose a reason for hiding this comment

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

Thanks for the review @samuelsycamore 🎉 😄


By default, a tree item is expanded when clicking the content. You can change the expansion trigger using the `expansionTrigger` prop to the `iconContainer`. Read more about the expansion API on the dedicated [documentation page](/x/react-tree-view/rich-tree-view/expansion/#limit-expansion-to-icon-container).

To achieve a deeper customization of the expansion of an item use the `handleExpansion` interaction method. The demo below demonstrates how to introduce a new element that expands or collapses the item.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

for deeper customization of Item expansion. sounds a bit weird to me 🤔 not sure why. Maybe for deeper customization of the Item's expansion behavior.?

Copy link
Member

@flaviendelangle flaviendelangle left a comment

Choose a reason for hiding this comment

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

Thanks for the terrific work 🙏

@flaviendelangle flaviendelangle changed the title [docs] Create an "Item customization" doc page that uses useTreeItem2 and TreeItem2 [docs] Document the TreeItem2 component and the useTreeItem2 hook Oct 9, 2024
@noraleonte noraleonte merged commit e8991e9 into mui:master Oct 9, 2024
18 checks passed
@noraleonte noraleonte deleted the tree-item-customization branch October 9, 2024 13:05
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.

Great to have more customzation docs 👍

// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
// see https://nextjs.org/docs/basic-features/typescript for more information.
Copy link
Member

Choose a reason for hiding this comment

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

A small regression, it got fixed in HEAD already.

: '/static/x/tree-view-illustrations/tree-item-dark.png';
return (
<Card elevation={0} variant="outlined" sx={{ padding: 4 }}>
<CardMedia
Copy link
Member

Choose a reason for hiding this comment

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

This image width growth too much. src is 1440px so can only support up to 720px without looking blurry (desktop width is more like 740px).

Comment on lines +9 to +11
const src =
palette.mode === 'light'
? '/static/x/tree-view-illustrations/tree-item-light.png'
Copy link
Member

Choose a reason for hiding this comment

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

This pattern will blink for dark mode users (once docs-infra starts and finishes the migration to CSS variables).

I think the right pattern here is to follow the other instances:

<span class="only-light-mode">
<img src="/static/docs-infra/forking-an-example.png" alt="Forking an example" loading="lazy" width="1628" height="700" style="display: block; max-width: 774px;">
</span>
<span class="only-dark-mode">
<img src="/static/docs-infra/forking-an-example-dark.png" alt="Forking an example" loading="lazy" width="1628" height="700" style="display: block; max-width: 774px;">
</span>

Copy link
Member

@oliviertassinari oliviertassinari Nov 19, 2024

Choose a reason for hiding this comment

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

Another thought on this one. It feels like we should link the source to the Figma file we used (a code comment I guess) so anyone can easily come here and change the image when we reorganize the component structure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: tree view TreeView, TreeItem. 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.

[TreeView] Create an "Item customization" doc page that uses useTreeItem2 and TreeItem2
5 participants