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

feat: ListView components #1919

Merged
merged 41 commits into from
Apr 19, 2024
Merged

Conversation

bmingles
Copy link
Contributor

@bmingles bmingles commented Apr 4, 2024

  • ListView components
  • Smart item tooltip handling (only show when text is overflowing)
  • Split out some shared util code from Picker
  • Wrapped Text, View, and Heading in forwardRef

Testing
This can be tested using this PR: deephaven/deephaven-plugins#408 . To make TypeScript happy, you can install DHC as an alpha via:

npm run update-dh-packages -- --scope=@deephaven/js-plugin-ui -- 0.72.1-alpha-list-view.38

BREAKING CHANGE: LIST_VIEW_ROW_HEIGHT number constant replaced with dictionary LIST_VIEW_ROW_HEIGHTS

@bmingles bmingles force-pushed the 1909-list-view-components branch 2 times, most recently from 281cf5d to b6d1626 Compare April 10, 2024 20:36
@bmingles bmingles marked this pull request as ready for review April 10, 2024 21:02
@bmingles bmingles requested a review from mofojed April 10, 2024 21:56
import React, { useCallback, useState } from 'react';
import { Grid, Item, ListView, ItemKey, Text } from '@deephaven/components';
import { vsAccount, vsPerson } from '@deephaven/icons';
import { Icon } from '@adobe/react-spectrum';
Copy link
Member

Choose a reason for hiding this comment

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

Should re-export this from @deephaven/components.
Any reason why the default slot isn't "illustration"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just picked one of the 2 supported. Is illustration preferable over icon ?

Copy link
Member

Choose a reason for hiding this comment

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

There don't appear to be any docs on this eh? I'm not sure what the difference is... illustration may actually be for an "illustrated message" whereas icon is just something inline. So maybe icon is better.
And it seems there's an Illustration as well that puts illustration in the slot, so the default slot should already be icon when using Icon. Should we be re-exporting Illustration?
Doesn't seem to be an Image component, where'd the image slot come from?

Copy link
Contributor Author

@bmingles bmingles Apr 18, 2024

Choose a reason for hiding this comment

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

I think the illustration slot gets be added on the icons coming from @spectrum-icons/illustrations/xxxxx
https://react-spectrum.adobe.com/react-spectrum/ListView.html#complex-items

I think you are right that the default slot for Icon is 'icon'. Unfortunately the ListView has to have image or illustration vs Picker which supports icon. Maybe a Spectrum bug but not sure.

I don't think there is an Illustration component to re-export unless we were to export the @spectrum-icons/illustrations/xxxxx modules which seems to be an addon of some sort

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the expectation is you wouldn't put decorative icons in that slot, as it would be confusing with icons in the action slot (which I think in this example overflow because there is more than one)

image

Where as the primary slot is for images/illustrations, not icons.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I simplified things by just defaulting to "illustration" and removing the function arg. It's just for styleguide so probably doesn't matter too much anyway except to avoid confusing folks.

Copy link
Contributor Author

@bmingles bmingles Apr 18, 2024

Choose a reason for hiding this comment

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

I guess the lack of exporting Illustration might be an oversight:
https://github.com/adobe/react-spectrum/blob/main/packages/%40adobe/react-spectrum/src/index.ts#L32

We could file a PR with Spectrum include export {Illustration} from '@react-spectrum/icon';, but as-is we don't have access to it

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps, they also don't export UIIcon. Unsure if intentional or not. Could open a PR and see how they respond.

packages/components/src/spectrum/listView/ListView.tsx Outdated Show resolved Hide resolved
@bmingles bmingles requested a review from mofojed April 16, 2024 20:23
Copy link
Member

@mofojed mofojed left a comment

Choose a reason for hiding this comment

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

One package cleanup note, everything looking good otherwise.

@@ -22,6 +22,7 @@
"build:sass": "sass --embed-sources --load-path=../../node_modules ./src:./dist"
},
"dependencies": {
"@adobe/react-spectrum": "^3.34.1",
Copy link
Member

Choose a reason for hiding this comment

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

Should import everything from @deephaven/components, even in jsapi-components. Seems we're importing useProvider in ListView.tsx.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mofojed hmm, we aren't re-exporting currently. Any opinions on how we want to do this? useProvider seems too generic, but useSpectrumProvider seems a bit odd since we are trying to abstract away Spectrum.

Copy link
Member

Choose a reason for hiding this comment

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

Well, you're exporting SpectrumThemeProvider, useSpectrumThemeProvider to mirror that would be fine with me.
Unsure if we want to get more abstract than that, we already have ThemeProvider.

return (
// Images in ListView items require a slot of 'image' or 'illustration' to
// be set in order to be positioned correctly:
// https://github.com/adobe/react-spectrum/blob/784737effd44b9d5e2b1316e690da44555eafd7e/packages/%40react-spectrum/list/src/ListViewItem.tsx#L266-L267
Copy link
Member

Choose a reason for hiding this comment

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

Any reason they don't have a slot provider for icon? We could even add a PR for it... seems odd they support image and illustration but not icon.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm guessing @dsmmcken suggestion may be accurate here. Maybe they are trying to not overload the fact that icons can be included in actions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that's a key difference between listview and listbox, https://react-spectrum.adobe.com/react-spectrum/ListBox.html#complex-items

@bmingles bmingles requested a review from mofojed April 18, 2024 18:31
@bmingles bmingles merged commit b63ab18 into deephaven:main Apr 19, 2024
4 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Apr 19, 2024
@bmingles bmingles deleted the 1909-list-view-components branch April 19, 2024 14:09
@bmingles bmingles linked an issue Apr 26, 2024 that may be closed by this pull request
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ListView - React components in support of ui.list_view
3 participants