forumone / nextjs-project

Next.js project template
0 stars 0 forks source link

Sortable table #107

Open kmonahan opened 2 months ago

kmonahan commented 2 months ago

Ports the styles and icons for a sortable table from https://github.com/forumone/gesso/pull/794 and adds a story with example usage, based on https://forumone.github.io/gesso/?path=/story/components-table--sortable. Also creates a SortableHeader component and pulls in a couple utilities from Gesso Drupal that we didn't have here yet.

The main difference between this and the Drupal implementation is that the React version assumes you are sorting data and then rendering a table, rather than assuming you have a table HTML as your starting point. Thus the table output and sorting logic are in the story (and would be in the component in a real project) rather than an external JS file. Unless I needed to do something radically different on a project, I'd probably copy/paste the story example and then update the typings to match whatever data structure I was using.

We discussed this approach generally at the last Gesso for React check-in, but now that you see it, thoughts? Anything that feels like it is generic/reusable enough to warrant pulling out of the story into its own reusable component or utility function?