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

DataViews: Split the components into composable components. #63646

Open
youknowriad opened this issue Jul 17, 2024 · 3 comments
Open

DataViews: Split the components into composable components. #63646

youknowriad opened this issue Jul 17, 2024 · 3 comments
Labels
[Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond [Type] Enhancement A suggestion for improvement.

Comments

@youknowriad
Copy link
Contributor

youknowriad commented Jul 17, 2024

Part of #55083

Right now, when you render the DataViews component, it gets rendered all in one including:

  • Search bar
  • Filters
  • View Config
  • Layout switcher
  • Pagination
  • Layouts

This approach provides a straightforward way to use DataViews but lacks flexibility. For instance in #55101 we want to add a "toggle" to show the dataviews sidebar at the right of the view config dropdown. That toggle doesn't have anything to do with DataViews so it shouldn't rendered within the dataviews component.

We have two options:

Short Term option

Just have some kind of slot prop to inject UI there. I'll probably use this approach initially.

Long Term option

Expose the underlying DataViews component and allow composition:

<DataViews>
    <HStack>
        <DataViews.Search />
        <DataViews.Filters />
        <DataViews.BulkActions />
        <DataViews.LayoutSwitcher />
        <DataViews.ViewConfig />
        <Button>My custom Button</Button>
     </HStack>
      <DataViews.Layout />
      <DataViews.Pagination />
      <DataViews.BulkActionToolbar />
</DataViews>

Any thoughts @ntsekouras @ellatrix @oandregal @jorgefilipecosta
Also components team as they're exploring a similar pattern for the components package. @ciampo @mirka @DaniGuardiola

@youknowriad youknowriad added [Type] Enhancement A suggestion for improvement. [Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond labels Jul 17, 2024
@ciampo
Copy link
Contributor

ciampo commented Jul 17, 2024

Adopting compound components seems like a good idea to me, to offer an a-la-carte set of components that consumers of the package can pick and render as needed.

Other approaches that can be used (not necessarily as an alternative, but in conjunction) are render props, which allow components to identify "slots" where consumers can render custom react components.

Related, this recent article from @DaniGuardiola explores the topic in depth: https://dio.la/article/the-everything-bagel-of-components

@ntsekouras
Copy link
Contributor

I think composable components are good and flexible. This actually was my approach at my very first experiment of this component.

@youknowriad
Copy link
Contributor Author

Going to give this a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

3 participants