Skip to content

Rewrite ItemTable with react-table #13

Closed
campb303 opened this issue Aug 6, 2020 · 6 comments
Closed

Rewrite ItemTable with react-table #13

campb303 opened this issue Aug 6, 2020 · 6 comments
Assignees
Labels
enhancement Request for a change to existing functionality

Comments

@campb303
Copy link
Collaborator

campb303 commented Aug 6, 2020

ItemTable currently uses the material-table library. This works well for a simple table view with sorting, however it does not allow for the complete styling needed for a responsive interface.

react-table is a barebones library meant for building a table but makes no styling decisions for the user. Rewriting the ItemTable using react-table would allow for the type of custom styling needed to achieve a tabular interface on large screens and a card-like interface on small screens.

Example: github.com/ArsenyYankovsky/react-responsive-cards-table
Responsive card table

@campb303 campb303 added enhancement Request for a change to existing functionality frontend labels Aug 7, 2020
@campb303 campb303 added this to the v1 milestone Sep 14, 2020
@campb303 campb303 assigned campb303 and wrigh393 and unassigned campb303 Sep 14, 2020
@campb303
Copy link
Collaborator Author

It may not be necessary to ditch material-table all together. Component overriding appears to be possible according the material-table's documentation.

It may be possible to replace the Row and Cell components with a card and add custom media queries to achieve the desired outcome.

@wrigh393
Copy link
Collaborator

wrigh393 commented Sep 23, 2020

After working with material-table's component overriding feature we've found that when overriding the row or cell component with a card it seems to breaks the styling of the table.

Default Behavior:
Default ItemTable behavior

Row Component override:
Row Component override example

Cell Component override:
Cell Component override

We are taking a look at using mui-datatables . Mui-datatables lacks some features that material-table provides like per column sorting but is responsive out of the box.

Here's an example of how mui-datatables could work for the ItemTable
mui-datatables example

@campb303
Copy link
Collaborator Author

There appears to be official support for custom rendering using a couple of options together. See this issue for more details.

@campb303
Copy link
Collaborator Author

campb303 commented Oct 9, 2020

We've moved from using material-table to react-table for table rendering. react-table is a headless table library meaning it controls markup but not UI. This is beneficial as it allows us to use any styling we choose and change it later without affecting the logic.

Initial table rendering was straightforward with a quickstart guide from this article.

The first major issue we encountered was variable column widths that would change depending on the content of the table. This was fixed by using the useFlexLayout() hook.

The next thing to address is table sorting. We've decided to use a combo search/title box in the table header to identify columns and act as filters. Now there needs to be some ui interaction to sort by columns, preferably multiple columns at a time.

Example: react-table ItemTable UI as of now:
react-table ItemTable UI as of now

@wrigh393
Copy link
Collaborator

wrigh393 commented Oct 9, 2020

We have implemented sorting by using the useSortBy() hook. This allows the table to be sorted by ascending and descending order.

The issue that we are facing right now is how to properly set the sorting as active when the user clicks on the button. When inactive we want the button to have a low opacity so that it is seen, but when it is active the button should be clearly visible. Here is an example of how we would like the sorting to work.

@campb303
Copy link
Collaborator Author

Resolved here

Sign in to join this conversation on GitHub.
Labels
enhancement Request for a change to existing functionality
Projects
None yet
Development

No branches or pull requests

2 participants