Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
91203b8
Add TreeView docs
colebemis Sep 2, 2022
d425776
Update TreeView props
colebemis Sep 2, 2022
6523985
Scaffold treeview markup
colebemis Sep 2, 2022
30bbae4
Add TreeView to drafts
colebemis Sep 2, 2022
15dc5b2
Add comment
colebemis Sep 2, 2022
46fd1d5
Track item levels
colebemis Sep 2, 2022
a980f76
Add TreeView stories
colebemis Sep 8, 2022
9961985
Update TreeView docs
colebemis Sep 8, 2022
945c58c
Update TreeView markup
colebemis Sep 8, 2022
5b03f71
Create curly-birds-argue.md
colebemis Sep 8, 2022
4072099
Merge branch 'main' into treeview-markup
colebemis Sep 8, 2022
109f05e
Fix examples
colebemis Sep 9, 2022
49303b0
Update src/TreeView/TreeView.tsx
colebemis Sep 9, 2022
cbebf14
Update docs/content/TreeView.mdx
colebemis Sep 9, 2022
b3a3096
Add some tests
colebemis Sep 9, 2022
2b666bd
Implement arrow key navigation
colebemis Sep 12, 2022
df5444b
Fix arrow left
colebemis Sep 12, 2022
ba2166a
Set up aria-activedescendant
colebemis Sep 13, 2022
3437e11
Display focus ring on active descendant
colebemis Sep 13, 2022
d6002e3
Use arrow key to change active descendant
colebemis Sep 14, 2022
769715b
Handle expand/collapse with arrow keys
colebemis Sep 14, 2022
c4bc882
Merge branch 'main' into treeview-arrow-keys
colebemis Sep 14, 2022
bbec34b
Fix lint error
colebemis Sep 14, 2022
e22679d
Add up and down arrow key test
colebemis Sep 14, 2022
dbece82
Prevent default when moving focus with arrow keys
colebemis Sep 14, 2022
2f58284
Open links in same tab by default
colebemis Sep 14, 2022
2ad9f73
Add test for right arrow key expand
colebemis Sep 15, 2022
0065cfa
Add defaultExpanded prop
colebemis Sep 15, 2022
d41f319
Test left arrow key collapse
colebemis Sep 15, 2022
515a9fc
Reorganize tests
colebemis Sep 15, 2022
f99388b
Create neat-squids-cheat.md
colebemis Sep 15, 2022
b165dcf
Add more tests
colebemis Sep 15, 2022
96ac6d8
Implement home and end key behavior
colebemis Sep 15, 2022
311c27f
Merge branch 'treeview-arrow-keys' of github.com:primer/react into tr…
colebemis Sep 15, 2022
1325ca4
Update active descendant on click
colebemis Sep 15, 2022
c0c1745
Remove focus state
colebemis Sep 15, 2022
8303416
Remove focus state from context
colebemis Sep 15, 2022
9106046
Test enter and space keys
colebemis Sep 15, 2022
847053d
Update focus style
colebemis Sep 15, 2022
e949bc6
Merge branch 'main' into treeview-arrow-keys
colebemis Sep 16, 2022
79d0ccc
Remove Space key behavior
colebemis Sep 16, 2022
e1dcac4
Merge branch 'treeview-arrow-keys' of github.com:primer/react into tr…
colebemis Sep 16, 2022
d1f2945
Wrap test cases with themeprovider
colebemis Sep 16, 2022
13473b2
Add test for link item
colebemis Sep 16, 2022
b9b4415
Update urls
colebemis Sep 19, 2022
92d746a
Add indicator lines for each nested level
colebemis Sep 19, 2022
c8a8017
Create heavy-pets-own.md
colebemis Sep 20, 2022
c6469db
Merge branch 'main' into treeview-nested-lines
colebemis Sep 20, 2022
7881022
Create LevelIndicatorLines component
colebemis Sep 20, 2022
830d6db
Merge branch 'treeview-nested-lines' of github.com:primer/react into …
colebemis Sep 20, 2022
a0425a4
Merge branch 'main' into treeview-nested-lines
colebemis Sep 20, 2022
003153f
Remove transitions for now
colebemis Sep 21, 2022
61a2d83
Merge branch 'main' into treeview-nested-lines
colebemis Sep 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/heavy-pets-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

Adds lines to indicate the depth of items in a TreeView
37 changes: 36 additions & 1 deletion src/TreeView/TreeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ const Item: React.FC<TreeViewItemProps> = ({
color: 'fg.default',
borderRadius: 2,
cursor: 'pointer',
transition: 'background 33.333ms linear',
'&:hover': {
backgroundColor: 'actionListItem.default.hoverBg'
},
Expand All @@ -361,6 +360,9 @@ const Item: React.FC<TreeViewItemProps> = ({
}
}}
>
<Box sx={{gridArea: 'spacer', display: 'flex'}}>
<LevelIndicatorLines level={level} />
</Box>
{hasSubTree ? (
<Box
onClick={event => {
Expand Down Expand Up @@ -405,6 +407,39 @@ const Item: React.FC<TreeViewItemProps> = ({
)
}

/** Lines to indicate the depth of an item in a TreeView */
const LevelIndicatorLines: React.FC<{level: number}> = ({level}) => {
return (
<Box sx={{width: '100%', display: 'flex'}}>
{Array.from({length: level - 1}).map((_, index) => (
<Box
key={index}
sx={{
width: '100%',
height: '100%',
borderRight: '1px solid',

// On devices without hover, the nesting indicator lines
// appear at all times.
borderColor: 'border.subtle',

// On devices with :hover support, the nesting indicator lines
// fade in when the user mouses over the entire component,
// or when there's focus inside the component. This makes
// sure the component remains simple when not in use.
'@media (hover: hover)': {
Comment on lines +426 to +430
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

borderColor: 'transparent',
'[role=tree]:hover &, [role=tree]:focus &': {
borderColor: 'border.subtle'
}
}
}}
/>
))}
</Box>
)
}

// ----------------------------------------------------------------------------
// TreeView.LinkItem

Expand Down