-
Notifications
You must be signed in to change notification settings - Fork 9
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
#870 - Add PivotTableRenderer to bold #876
base: main
Are you sure you want to change the base?
Conversation
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.
These functions transform the table calculated with getResult
into a list of PivotTableCell
. I didn't find a way to test this code directly.
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.
Thats why you usually don't return React Components from util functions 😬 This should be either (a) a component that renders the cells or (b) a hook usePivotTableCells
that returns an array of PivotTableCellProp
that you can use in the component along with a .map
to render the Cells. Here you are mixing util functions with components an this makes this behavior too complex AND makes it really hard to implement tests. Dangerous combination.
Maybe a combination of (a) and (b) is good too: Make a HorizontalPivotTable
, VerticalPivotTable
, etc that uses a hook/util function to calculate its props sounds good.
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 chose to follow the (b) approach. It will be simpler to test.
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.
Nice!
I'm requesting changes because i think the export button is missing
.loki/reference/chrome_laptop_Components_PivotTable_PivotTableRenderer_All_Types.png
Outdated
Show resolved
Hide resolved
src/components/PivotTable/PivotTableCell/PivotTableProvider.tsx
Outdated
Show resolved
Hide resolved
src/components/PivotTable/PivotTableRenderer/PivotTableBuilder.tsx
Outdated
Show resolved
Hide resolved
return { divs, rowTotalValues, totalRowNumber: maxRowEnd, cellPosition } | ||
} | ||
|
||
function getVertical<T extends object>({ |
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.
The same comments I made in previous method can be applied here
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 think the Export Button is missing here
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.
Exporting the table will be done in another issue.
src/components/PivotTable/PivotTableRenderer/PivotTableRenderer.tsx
Outdated
Show resolved
Hide resolved
src/components/PivotTable/PivotTableRenderer/model-pivotTableRenderer.ts
Outdated
Show resolved
Hide resolved
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.
🚀
src/components/PivotTable/PivotTableRenderer/model-pivotTableRenderer.ts
Outdated
Show resolved
Hide resolved
src/components/PivotTable/PivotTableRenderer/PivotTableRenderer.tsx
Outdated
Show resolved
Hide resolved
src/components/PivotTable/PivotTableRenderer/PivotTableRenderer.tsx
Outdated
Show resolved
Hide resolved
src/components/PivotTable/PivotTableRenderer/PivotTableRenderer.test.tsx
Outdated
Show resolved
Hide resolved
src/components/PivotTable/PivotTableRenderer/PivotTableBuilder.tsx
Outdated
Show resolved
Hide resolved
src/components/PivotTable/PivotTableRenderer/PivotTableBuilder.tsx
Outdated
Show resolved
Hide resolved
/** | ||
* Create vertical header | ||
*/ | ||
keys.forEach((k, idx) => { | ||
const headerGridArea = new GridArea(headerSpace, idx + 1, headerSpace + 1, idx + 2) | ||
divs.push( | ||
<PivotTableCell | ||
types={new Set([PivotTableCellType.HEADER])} | ||
key={headerGridArea.toString()} | ||
gridArea={headerGridArea} | ||
> | ||
{keysMapping.get(k).keyName} | ||
</PivotTableCell> | ||
) | ||
}) |
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.
☝🏾
src/components/PivotTable/PivotTableRenderer/PivotTableBuilder.tsx
Outdated
Show resolved
Hide resolved
src/components/PivotTable/PivotTableRenderer/PivotTableRenderer.stories.tsx
Outdated
Show resolved
Hide resolved
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.
Nice!
src/components/PivotTable/PivotTableRenderer/PivotTableRenderer.tsx
Outdated
Show resolved
Hide resolved
src/components/PivotTable/PivotTableRenderer/PivotTableRenderer.tsx
Outdated
Show resolved
Hide resolved
src/components/PivotTable/PivotTableRenderer/PivotTableRenderer.test.tsx
Outdated
Show resolved
Hide resolved
src/components/PivotTable/PivotTableRenderer/PivotTableBuilder.tsx
Outdated
Show resolved
Hide resolved
src/components/PivotTable/PivotTableRenderer/PivotTableBuilder.tsx
Outdated
Show resolved
Hide resolved
src/components/PivotTable/PivotTableRenderer/PivotTableBuilder.tsx
Outdated
Show resolved
Hide resolved
src/components/PivotTable/PivotTableRenderer/PivotTableBuilder.tsx
Outdated
Show resolved
Hide resolved
src/components/PivotTable/PivotTableRenderer/PivotTableBuilder.tsx
Outdated
Show resolved
Hide resolved
} | ||
const maxLeafValue = props.defaultTree.maxLeafValue as number | ||
return ( | ||
<PivotTableProvider maxValue={maxLeafValue} suffix={''}> |
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.
<PivotTableProvider maxValue={maxLeafValue} suffix={''}> | |
<PivotTableProvider maxValue={maxLeafValue} suffix=''> |
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.
Wow! It's a really complex component! Great!
I think you can improve the readability and maintainability by splitting some complex code and giving better names for the vars and functions.
src/components/PivotTable/PivotTableRenderer/PivotTableBuilder.tsx
Outdated
Show resolved
Hide resolved
src/components/PivotTable/PivotTableRenderer/classes/GroupResult.ts
Outdated
Show resolved
Hide resolved
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.
When working inside a lib take extra care about leaving commented code and "console.log". The lib code is already big enough and console.log can compromise the performance and debug of the systems that use this lib.
Most of the other comments are only suggestions.
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.
Beautiful! 😍
closes #870
The component receives data in a Tree data structure and outputs a table using the desired keys as headers.