-
Notifications
You must be signed in to change notification settings - Fork 128
Introduce the TreeView
component
#3563
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
Conversation
Co-authored-by: Cameron Dutro <[email protected]>
🦋 Changeset detectedLatest commit: a9dc047 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
b5cf715
to
3adffd0
Compare
3adffd0
to
4e4c5ba
Compare
Hi people, I just pushed some additional stuff that we already had implemented for this component:
|
Whoa, nice! Thanks @camertron and @HDinger for this big addition 🙇🏻♀️ I added another engineering reviewer to see about getting some more eyes on this soon. |
do you have any updates on this? Is there anything we can support you with to make the review easier? |
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.
Thanks for the contribution @camertron and sorry for the slow reply @HDinger. We were discussing internally on the choices of accepting such a large contribution and for a component TreeView which doesn't have an immediate product need for us. Balancing the risk of taking on the maintenance burden vs the reward of bringing the component library closer to the react counterpart.
If you could help making sure the CI is passing for lint errors I can merge this into the next release.
@jonrohan ah yeah, we thought that was probably the nature of the conversation on your side 😅 Thank you so much for reviewing and being willing to merge 💟 Also, I am willing to help with future maintenance of this component as time allows 😄 |
What are you trying to accomplish?
This PR introduces
TreeView
, a new component modeled after the React component by the same name.TreeView
is a hierarchical list of items that may have a parent-child relationship where children can be toggled into view by expanding or collapsing their parent item.Terminology
Consider the following tree structure when reading through the list of terms:
["src", "action_list", "header.rb"]
.Example
Here's how to render the example tree above using the
TreeView
component:Static vs dynamic nodes
TreeView
sub-trees support fetching items from a remote server via one of two "loaders," either a spinner or a skeleton. Loaders accept asrc:
attribute with the URL to use to fetch items. The JSON-encoded path (i.e. array of strings) to the current node will be included as aGET
parameter in the remote request.Visuals
Both leaf nodes and sub-tree nodes support leading and trailing visuals, leading actions, and checkboxes. Please see the documentation for all the relevant details. Here's an example of adding a trailing visual:
Checkbox support
TreeView
supports checkboxes for leaf and sub-tree nodes. The component itself only handles the visual side of rendering checkboxes and their state, but does not track checked state, allow it to be submitted to the server, etc. Such behavior outsideTreeView
's scope of responsibility.Checking a sub-tree node will check all of its children recursively, and unchecking it will uncheck all its children recursively. Sub-tree nodes with some checked and some unchecked children are said to be in a "mixed" state, represented by a horizontal line inside the checkbox UI element.
Screenshots
Expanding/collapsing
Alt: a screen recording demonstrating how sub-tree nodes can be expanded and collapsed.
expand.mov
Loading spinner
Alt: a screen recording demonstrating the spinner that appears while sub-tree items are fetched from the server.
spinner.mov
Loading skeleton
Alt: a screen recording demonstrating the skeleton that appears while sub-tree items are fetched from the server.
skeleton.mov
Integration
This component is brand-new and thus should not affect any existing code in production.
Risk Assessment
Accessibility
Merge checklist