-
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
Add isRootDropTarget parameter to renderEmptyState in GridList component #5211
Add isRootDropTarget parameter to renderEmptyState in GridList component #5211
Conversation
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 like this idea a lot!
I say we go ahead and pass all the render props in (except for isEmpty
since it is implied). And we can use one argument with everything.
@@ -176,7 +176,7 @@ function GridListInner<T extends object>({props, collection, gridListRef: ref}: | |||
// they don't affect the layout of the children. However, WebKit currently has | |||
// a bug that makes grid elements with display: contents hidden to screen readers. | |||
// https://bugs.webkit.org/show_bug.cgi?id=239479 | |||
let content = props.renderEmptyState(); | |||
let content = props.renderEmptyState(isRootDropTarget); |
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.
let content = props.renderEmptyState(isRootDropTarget); | |
let content = props.renderEmptyState({ | |
isDropTarget: isRootDropTarget, | |
isFocused, | |
isFocusVisible, | |
state | |
}); |
@@ -54,7 +54,7 @@ export interface GridListProps<T> extends Omit<AriaGridListProps<T>, 'children'> | |||
/** The drag and drop hooks returned by `useDragAndDrop` used to enable drag and drop behavior for the GridList. */ | |||
dragAndDropHooks?: DragAndDropHooks, | |||
/** Provides content to display when there are no items in the list. */ | |||
renderEmptyState?: () => ReactNode | |||
renderEmptyState?: (isRootDropTarget: boolean) => ReactNode |
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.
renderEmptyState?: (isRootDropTarget: boolean) => ReactNode | |
renderEmptyState?: (props: {isDropTarget: boolean, isFocused: boolean, isFocusVisible: boolean, state: ListState<unknown>}) => ReactNode |
2231b33
to
0c48238
Compare
GET_BUILD |
Build successful! 🎉 |
@@ -176,7 +176,12 @@ function GridListInner<T extends object>({props, collection, gridListRef: ref}: | |||
// they don't affect the layout of the children. However, WebKit currently has | |||
// a bug that makes grid elements with display: contents hidden to screen readers. | |||
// https://bugs.webkit.org/show_bug.cgi?id=239479 | |||
let content = props.renderEmptyState(); | |||
let content = props.renderEmptyState({ |
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.
seems like a fine approach to me
we will need this in ListBox, Table, and TagGroup as well in order to be consistent
also, some form of a test/storybook example would be appreciated if you do not mind https://react-spectrum.adobe.com/contribute.html#pull-requests
cbd6aaf
to
0c48238
Compare
5982fb7
to
62bd780
Compare
@snowystinger @reidbarber Hello, I updated |
GET_BUILD |
Build successful! 🎉 |
@@ -850,7 +850,7 @@ Use the `renderEmptyState` prop to customize what the `ListBox` will display if | |||
<ListBox | |||
aria-label="Search results" | |||
/*- begin highlight -*/ | |||
renderEmptyState={() => 'No results found.'} | |||
renderEmptyState={({isDropTarget, state, isFocused, isFocusVisible}) => <span style={{color: isDropTarget ? 'red' : 'black'}}>No results found.</span>} |
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.
these are great, though in dark mode, it's a little hard to see
Instead, we should use one of the variables available to us in our docs, --spectrum-alias-text-color
There is another issue, though: I cannot drop anything on this example, so it never goes to red.
As a result, I think it should be in the example a little further down https://github.com/adobe/react-spectrum/blob/main/packages/react-aria-components/docs/ListBox.mdx#L1101
And instead of changing colors (esp to red which is negative), let's swap the string. Something like
isDropTarget ? 'This will not be uploaded' : 'Drop items here'
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, updated docs like that in all of the cases and also added for GridList
(forgot this one)
caa1271
to
ccd1870
Compare
ccd1870
to
1f1576c
Compare
GET_BUILD |
Build successful! 🎉 |
## API Changes
unknown top level export { type: 'identifier', name: 'Column' } |
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.
LGTM, thanks!!
51c0be2
Add
isRootDropTarget
parameter torenderEmptyState
inGridList
componentCloses #5210
✅ Pull Request Checklist:
📝 Test Instructions:
🧢 Your Project: