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

v3 TreeView #6020

Merged
merged 57 commits into from
Apr 25, 2024
Merged

v3 TreeView #6020

merged 57 commits into from
Apr 25, 2024

Conversation

LFDanLu
Copy link
Member

@LFDanLu LFDanLu commented Mar 7, 2024

Closes

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 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

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?
…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
@rspbot
Copy link

rspbot commented Apr 18, 2024

@rspbot
Copy link

rspbot commented Apr 22, 2024

reidbarber
reidbarber previously approved these changes Apr 22, 2024
}
}}>
<ActionButton
ref={ref}
// @ts-ignore (private)
hideButtonText={hideButtonText}
Copy link
Member

Choose a reason for hiding this comment

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

womps :(

Copy link
Member Author

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",
Copy link
Member

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?

Copy link
Member Author

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
Copy link
Member

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?

Copy link
Member Author

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?

Copy link
Member

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

Copy link
Member Author

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
Copy link
Member

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) {
Copy link
Member

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

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 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

Comment on lines 272 to 275
// 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
Copy link
Member

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

@@ -91,5 +92,7 @@ expect.extend({
}
});

configure({asyncUtilTimeout: 400});
Copy link
Member

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?

@rspbot
Copy link

rspbot commented Apr 23, 2024

ktabors
ktabors previously approved these changes Apr 24, 2024
Copy link
Member

@ktabors ktabors left a 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!

packages/@react-spectrum/tree/src/TreeView.tsx Outdated Show resolved Hide resolved
UNSAFE_style={{paddingInlineEnd: '0px'}}
slot="selection" />
)}
<div style={{gridArea: 'level-padding', marginInlineEnd: `calc(${level - 1} * var(--spectrum-global-dimension-size-200))`}} />
Copy link
Member

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?

Copy link
Member Author

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

snowystinger
snowystinger previously approved these changes Apr 24, 2024
@LFDanLu LFDanLu dismissed stale reviews from snowystinger and ktabors via 3882ad3 April 24, 2024 20:35
@rspbot
Copy link

rspbot commented Apr 24, 2024

@rspbot
Copy link

rspbot commented Apr 24, 2024

## API Changes

unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any', access: 'private' }
unknown top level export { type: 'any', access: 'private' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'identifier', name: 'Column' }
unknown top level export { type: 'identifier', name: 'Column' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }

@react-spectrum/tree

Item

-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
+}

@LFDanLu LFDanLu merged commit f3cbe03 into main Apr 25, 2024
25 checks passed
@LFDanLu LFDanLu deleted the S1_treeview branch April 25, 2024 21:42
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)]',
Copy link
Member

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.

Copy link
Member Author

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);
}
});
Copy link
Member

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?

Copy link
Member Author

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

@dannify dannify removed the release label Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants