-
Notifications
You must be signed in to change notification settings - Fork 4
feat: reduce HTML nesting and improve TableCell architecture #1223
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
Conversation
BouklifYacine
commented
Dec 23, 2025
- Create TableStructuredCell for tree-view/expandable functionality
- Simplify TableCell to be a pure composable wrapper with children prop
- Remove IconTextIcon usage in table context (eliminates extra wrapper div)
- Replace TanStack Row prop with primitive props (depth, isExpandable, isExpanded, onToggleExpand)
- Delete unused TableCellChips, TableCellDate, TableCellNumber components
- Add flex layout with gap for cell content via CSS
- Create TableStructuredCell for tree-view/expandable functionality - Simplify TableCell to be a pure composable wrapper with children prop - Remove IconTextIcon usage in table context (eliminates extra wrapper div) - Replace TanStack Row prop with primitive props (depth, isExpandable, isExpanded, onToggleExpand) - Delete unused TableCellChips, TableCellDate, TableCellNumber components - Add flex layout with gap for cell content via CSS
| } | ||
|
|
||
| // Flex container for cell content (chips, icons, etc.) | ||
| .moonstone-tableCellContentWrapper { |
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.
To avoid repeating the same CSS, you can use our helper classes from layout.scss flexRow, alignCenter
| className | ||
| )} | ||
| style={{width: width}} | ||
| style={{width}} |
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 we need to specify the property
width - Don't forget to add
props.styleto allow our user to add custom style here
| /** | ||
| * Whether this row is currently expanded | ||
| */ | ||
| isExpanded: boolean; |
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.
Should this prop be optional? Because if the item is not expandable there is no reason to provide isExpanded
| /** | ||
| * Callback fired when the expand/collapse toggle is clicked | ||
| */ | ||
| onToggleExpand: () => void; |
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.
Should this prop be optional?
| <Typography | ||
| ref={ref} | ||
| component={component} | ||
| variant="body" | ||
| className={clsx( | ||
| 'moonstone-TableCell', | ||
| 'textAlign' + capitalize(textAlign), | ||
| 'moonstone-verticalAlign' + capitalize(verticalAlign), | ||
| {flexFluid: typeof width === 'undefined'}, | ||
| className | ||
| )} | ||
| style={{width}} | ||
| {...props} | ||
| > | ||
| {renderContent()} | ||
| </Typography> |
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.
Maybe we should call TableCell directly instead of duplicating the code?
| const renderContent = () => { | ||
| if (isExpandable) { | ||
| return ( | ||
| <div |
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 am wondering if we can simply more, and get rid of some div and span by adding necessary classes directly to the td element.
| className={clsx( | ||
| 'moonstone-TableCell', | ||
| 'textAlign' + capitalize(textAlign), | ||
| 'flexRow', |
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 we need to add gap: var(--spacing-nano) to .moonstone-TableCell