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

Adjust Table component to take an array of objects instead of just values for table cells #53

Open
Loque- opened this issue Aug 6, 2018 · 0 comments

Comments

@Loque-
Copy link
Collaborator

Loque- commented Aug 6, 2018

Currently Table takes a multi-dimensional array to describe its values;

const arrayExampleContent = [
  ['Content 1-1', 'Content 1-2', 'Content 1-3', 'Content 1-4'],
  ['Content 2-1', 'Content 2-2', 'Content 2-3', 'Content 2-4'],
  ['Content 3-1', 'Content 3-2', 'Content 3-3', 'Content 3-4'],
];

This is fine for simple tables, however as new requirements have come in, for example to render a name attribute for each cell, we have solved this by passing a companion, multi-dimensional array, that must match its structure, and passes additional flags to ensure it gets handled appropriately e.g;

const rowTableNamesWithTitles = ['one', ['i', 'am', 'named', 'individually'], 'three'];
<Table rows={arrayExampleContent} names={rowTableNamesWithTitles} nameByRow />,

I am proposing we do this instead to achieve the above and any future cell data that may be required;

const arrayExampleContent = [
  [{value: 'Content 1-1', name:'one'}, {value: 'Content 1-2', name:'one'},{value: 'Content 1-3', name:'one'}, {value: 'Content 1-4', name:'one'}],
  [{value: 'Content 2-1', name:'i'}, {value: 'Content 2-2', name:'am'}, {value: 'Content 2-3', name:'named'}, {value: 'Content 2-4', name:'individually'}],
  [{value: 'Content 3-1', name:'three'}, {value: 'Content 3-2', name:'three'},{value: 'Content 3-3', name:'three'}, {value: 'Content 3-4', name:'three'}],
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant