-
Notifications
You must be signed in to change notification settings - Fork 5
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
Table rowgroups #393
Table rowgroups #393
Conversation
fczuardi
commented
Jun 13, 2018
- closes Make table row expandable/collapsible #391
d66dfa8
to
7d3f778
Compare
still missing from the patch is the small blue "L" icon on the rows that are grouped |
// iterate over all rows and sub-rows to create | ||
// a hash table of rows indexed by keys in the | ||
// format "<index>,<subIndex>" | ||
const rowsMap = this.props.data.reduce((entries, row, index) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when rows are added to props.data
after the component is mounted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would break selection checkboxes :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually is the selectionData passed to selectionHeader that breaks, it wont pass a selected row if the data about that row was added afterwards, I will update the index on component update to fix this (and write tests)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed with 77910db
packages/theme/src/colors.js
Outdated
RED_ORANGE: "#ff4411", | ||
INDIGO_MILK_CAP: "#3498db", | ||
INDIGO_MILK_CAP_06: "rgba(52,152,219,0.06)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we use a tool like: https://polished.js.org/docs/#transparentize to generate this color?
If some day we change the value for INDIGO_MILK_CAP
, the transparent one will be updated along with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed on d968410
packages/table/README.md
Outdated
@@ -58,6 +58,8 @@ core of the whole thing, it should be an array of objects, each item representin | |||
| selectionHeader | function ``(selectedRows, clearFunction) => React.node`` | a function that receives an array of selected rows data plus a function to clear selection; and should return a react node to be rendered as an action bar on top of the table, there is a helper component SelectionBar that can be used as the return of this function, or you can create your own... see the stories files for usage examples | | |||
| width | string | use this to manually change the width of the table | | |||
| rowHeight | string | use this to manually change the height of the body rows of the table, the package exports a set of named values as ``rowHeights``, you can import them and use ``rowHeights.SMALL`` to have a more compact table | | |||
| rowGroupKey | string | if you have rows that contains sub-rows as a list under a key, you can pass this property with the name of the key, to have a table with row groups generated | | |||
| collapsed | boolean | if row groups are used, this flag will add a button column with buttons that works as expand/collapse toggle on the start of row groups. The groups will start collapsed. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be split into 2 props: collapsible
and startCollapsed
. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how will this be used? will we have tables that starts expanded? if so, maybe we can have an expanded
for that case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we don't need to worry about it now
packages/table/src/Table.js
Outdated
_renderRow = (row, index, subIndex = "", group = false) => { | ||
const { selectableRows, collapsed, children } = this.props; | ||
const rowKey = `${index},${subIndex}`; | ||
const selected = this.state.selectedRows.indexOf(rowKey) !== -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I preferincludes
over indexOf
because it's declarative.
A downside is that it's not supported by IE.
We could add an indication of this restriction in the readme, so the use of a polyfill would be decided at the application using this component.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes
Anyway, this is minor and I'm OK if we decide to keep indexOf
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed on b60cce8
packages/table/src/Table.js
Outdated
? [ | ||
...oldExpandedRows.slice(0, expandedIndexOf), | ||
...oldExpandedRows.slice(expandedIndexOf + 1) | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed on 01af33d
affects: @crave/farmblocks-table
affects: @crave/farmblocks-table test(table): update README and stories to match the expected api affects: @crave/farmblocks-table
affects: @crave/farmblocks-table
…groud for grouped rows affects: @crave/farmblocks-table, @crave/farmblocks-theme feat(table): include new color on the palette and use it for row hover affects: @crave/farmblocks-table, @crave/farmblocks-theme
affects: @crave/farmblocks-table
affects: @crave/farmblocks-table
affects: @crave/farmblocks-table
… row groups affects: @crave/farmblocks-table
affects: @crave/farmblocks-table
…(integer) affects: @crave/farmblocks-table
f9c280f
to
9236cb6
Compare
affects: @crave/farmblocks-table
affects: @crave/farmblocks-table
affects: @crave/farmblocks-table
affects: @crave/farmblocks-table
affects: @crave/farmblocks-table
…ected rows to selection header affects: @crave/farmblocks-table
affects: @crave/farmblocks-table
…h css affects: @crave/farmblocks-table this is to prevent a Chrome glitch that causes a blink on first expand
8d70891
to
d968410
Compare
…nt backgroud for grouped rows
affects: @crave/farmblocks-table
affects: @crave/farmblocks-table
affects: @crave/farmblocks-table
b60cce8
to
482ea00
Compare