generated from cremalab/app-web
-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Proposal
Tables can be a pain. Let's make it as quick and easy to spit out a simple table that handles sorting and selection.
AC
- Any data can be mapped to a row
- Can sorting by column
- Can select by row
- Does not support complicated tables
Interface Options
A - Render Children and Props
Pros:
- Kind of looks like a table...
Cons:
- We'll still have to pass configuration for header/footer to distinct props which will give this a weird shape
- Need to pull in custom, or native table elements—you essentially still need to build a table
- Kind of looks like a table—seems like a shallow module (bad)—doesn't hide much
<Table
data={data}
renderHeader={() => (...)}
>
{({ a, b, c, d }) => (
<Tr>
<Td>{a}</Td>
<Td>{b}</Td>
<Td>{c}</Td>
<Td>{d}</Td>
</Tr>
)}
</Table>B - Render Props
Pros:
- Kind of looks like a table
- All render props are passed as props—as opposed to using
children
Cons:
- Same as Option A
<Table
data={data}
renderHeader={() => (...)}
renderRow={({ a, b, c, d }) => (
<Tr>
<Td>{a}</Td>
<Td>{b}</Td>
<Td>{c}</Td>
<Td>{d}</Td>
</Tr>
)}
/>C - Config-Based
Pros:
- No knowledge of table structure is needed (deep module)
- Column headers and table data values are define once—instead of potentially defining them separately—and potentially mismatching them.
Cons:
- Lose FULL control—but that's the point. This is the starting point for a useful abstraction that the user could augment to fit their needs.
<Table
data={data}
columns={[
{ label: null }, // maybe we need a gap 🤷♂️
{ label: "A", getValue: (user) => user.a, sortable: true },
{ label: "B", getValue: (user) => user.b },
{ label: "C", getValue: (user) => user.c.toString() },
{ label: "D", getValue: (user) => user.d.e },
]}
/>I might convert
columnsto a single function that has "datum" passed to it
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
🏗 In progress