-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
v3 TreeView #6020
v3 TreeView #6020
Conversation
…op considerations
default pointer styling, focus styling when focus is withing the row, clicking on the chevron should move focus into tree, checkbox now appears when single selection
conditions to macros must have "is" as a prefix?
…m rainbow for macros
…erronously overwritten icon slot propogated styles from TreeView row were making it to the ActionMenu button. Preventing this from happening by making ActionButton clearSlots and only accept text slot props. To preserve ActionGroup classname for icon, moved it to ActionButton directly
Build successful! 🎉 |
Build successful! 🎉 |
} | ||
}}> | ||
<ActionButton | ||
ref={ref} | ||
// @ts-ignore (private) | ||
hideButtonText={hideButtonText} |
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.
womps :(
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.
yeaaaah pretty annoying that I had to do this, open to any alternative ideas
"@react-aria/tree": "3.0.0-alpha.1", | ||
"@react-aria/utils": "^3.23.2", | ||
"@react-spectrum/checkbox": "^3.9.4", | ||
"@react-spectrum/style-macro-s1": "^3.5.3", |
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.
is that really the right version?
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.
oh hm, well it is the version that is set on the current style macro package but I can see your point. I'll to drop it down to 1.0.0-alpha.1
I guess since that package is private
default: 'default', | ||
isLink: 'pointer' | ||
}, | ||
// TODO: not sure where to get the equivalent colors here, for instance isHovered is spectrum 600 with 10% opacity but I don't think that exists in the theme |
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.
still true?
can we add it?
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.
yep, still true from what I can tell, I'd be happy to add it but I'm just not sure what our process for that is for v3. Do I just add whatever I need to the spectrum-theme?
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.
yeah, i think that'd be fine, so long as it's not a one off thing, if it is, then maybe the colors should be revisited
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.
kk, I'll add that as one of the post alpha followups
} | ||
|
||
return ( | ||
// TODO right now all the tree rows have the various data attributes applied on their dom nodes, should they? Doesn't feel very useful |
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.
I don't think it matters if they are just leftover from RAC
transition: '[transform ease var(--spectrum-global-animation-duration-100)]' | ||
}); | ||
|
||
function ExpandableRowChevronMacros(props: ExpandableRowChevronProps) { |
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.
why include "Macros" in the name? is it different than the style macros or is there a non-macros one? otherwise I think it's unnecessary. i know it's internal only, but i started looking for things it might mean to warrant it
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.
I don't actually remember why I named it this haha, I think it was just to set it apart from the TableView's ExpandableRowChevron but I'll just rename this
// TODO: api discussion, how do we feel about the below? This is so we can still style the row as grey when a child element within is focused | ||
// Maybe should have this for the other collection item render props | ||
// Whether the tree item's children have keyboard focus. | ||
isFocusVisibleWithin: boolean |
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.
makes sense to me
i'm fine with the name as well
I'm surprised we don't have this on Table RAC, meanwhile, TableView has this kind of styling which means we'll need this in Table as well
scripts/setupTests.js
Outdated
@@ -91,5 +92,7 @@ expect.extend({ | |||
} | |||
}); | |||
|
|||
configure({asyncUtilTimeout: 400}); |
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.
does this still happen now after devon's work?
Build successful! 🎉 |
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.
A couple non-blocking questions. Looks great!
UNSAFE_style={{paddingInlineEnd: '0px'}} | ||
slot="selection" /> | ||
)} | ||
<div style={{gridArea: 'level-padding', marginInlineEnd: `calc(${level - 1} * var(--spectrum-global-dimension-size-200))`}} /> |
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.
Is there a reason we're using style instead of a style()
macro in className?
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.
Ah good point, I can add that in a followup
Build successful! 🎉 |
## API Changes
unknown top level export { type: 'any' } @react-spectrum/treeItem-Item<T> {
- props: ItemProps<T>
- returnVal: undefined
-}
+ Section-Section<T> {
- props: SectionProps<T>
- returnVal: undefined
-}
+ Tree-Tree<T extends {}> {
-} TreeViewItem-
+TreeViewItem {
+ TreeViewItem?: boolean
+} TreeView-
+TreeView<T extends {}> {
+ children?: ReactNode | ({}) => ReactNode
+ onAction?: (Key) => void
+ renderEmptyState?: () => JSX.Element
+} SpectrumTreeViewProps-
+SpectrumTreeViewProps<T> {
+ children?: ReactNode | (T) => ReactNode
+ onAction?: (Key) => void
+ renderEmptyState?: () => JSX.Element
+} SpectrumTreeViewItemProps-
+SpectrumTreeViewItemProps {
+ children: ReactNode
+ hasChildItems?: boolean
+} |
forcedColorAdjust: 'none', | ||
|
||
boxShadow: { | ||
isFocusVisible: '[inset 2px 0 0 0 var(--spectrum-alias-focus-color), inset -2px 0 0 0 var(--spectrum-alias-focus-color), inset 0 -2px 0 0 var(--spectrum-alias-focus-color), inset 0 2px 0 0 var(--spectrum-alias-focus-color)]', |
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.
probably could use outline for the focus ring like we are in s2. might simplify this a bit.
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.
Sure, added it to the followup ticket to try
} else { | ||
content.push(node); | ||
} | ||
}); |
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.
We generally try to avoid this kind of thing with the new collections API since someone could wrap TreeViewItem
in their own custom component. Should we have a TreeItemContent component in Spectrum like we do in RAC?
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.
Definitely could go that route, I can play around with that
Closes
✅ Pull Request Checklist:
📝 Test Instructions:
Test the TreeView stories. See https://www.chromatic.com/build?appId=5f0dd5ad2b5fc10022a2e320&number=733 and
https://www.chromatic.com/build?appId=651b502f6b74abaae4ee734c&number=24 for the chromatic stories
🧢 Your Project:
RSP