-
Notifications
You must be signed in to change notification settings - Fork 486
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
feat(@clayui/core): adds the implementation of the new data-oriented composition for Table #5679
Conversation
…composition for Table Instead of implementing this on top of the Table currently, we are recreating the component parts in a new composition to avoid backward compatibility or mechanisms that have to identify when using the old or new composition to use the right component. So to use the new composition use the Table from `@clayui/core` and we leave the component in `@clayui/table` in deprecation mode.
cc @ethib137 let me know what 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.
This is looking great @matuzalemsteles ! Is it fully working with collections now?
} & React.ThHTMLAttributes<HTMLTableCellElement> & | ||
React.TdHTMLAttributes<HTMLTableCellElement>; | ||
|
||
export const Column = React.forwardRef<HTMLTableCellElement, Props>( |
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.
Is there a reason why we use 'Column' instead of 'Cell' as the name?
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.
In fact, there isn't much of a reason, just using a slightly more "popular/common" nomenclature.
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.
Hey @matuzalemsteles can you point me towards where you've seen column
used? If we were to think about this like google sheets, this component renders a single cell such as A1
, right? In the context of google sheets a column would refer to A:A
or all the cells in a column.
Checking a few other libraries, MaterialUI uses TableCell
, NextUI uses TableColumn
only for cells in the header and TableCell
for cells in the body.
Additionally, FDS uses TableCell
and TableHeadCell
. Also, most of the classnames being applied to this component are prefixed table-cell-*
.
So what do you think, does Cell
make more sense, or do you still see more reasons for Column
?
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.
@ethib137 These are good points, I hadn't thought about this side of Google Sheets. I really think that the case of Google sheets makes sense mainly because you deal with cells specifically although you call a column like A
which groups several cells I would say that this is different for Table where sheets have the concept of cells much stronger because the cell can have a relationship between different cells, not necessarily related only to the specific column but can, for example, be diagonal and column is only used as a reference, which is different in a table where the cell has to be associated with a column to have context, which is not true in Google Sheets since the nature of the cell can have its own context and it is a more flexible term we can say like this.
But yes, calling cells for body elements makes sense, I don't like it particularly because the cell seems to not necessarily be "associated" with a column directly... For example Column is also a common name for components not necessarily related to a table , for example a group of elements to be rendered horizontally or vertically. For example:
- Braid Design System
- Base Web They don't necessarily use Column as a composition, there are some components as part of their Table that use the term column but their composition is very different.
- Adobe Spectrum - They use the same Column pattern for the header and Cell for the body.
- Polaris - Their composition is a little confusing but I would say that they use the same naming pattern of Column for header and cell for cell, in other table components the cell is not mentioned as part of the APIs, only rows.
- Evergreen - Here they already use Cell for anywhere but you can understand that the cell is not necessarily associated with a column so it seems that it can be rendered in different ways which makes sense here.
- Carbon - Composition follows the same pattern of having Column for header but they only call it Header, and Cell just for the body.
- Radix - Composition is based on HeaderCell and Cell for the body only.
I don't really like the idea of creating a Column component to be used only in the Head and a Cell for only the body, I want to reduce the number of components for the composition and make the component more intelligent, which is also one of the reasons because I went with Column instead of just Cell for naming.
Anyway, we can go with Cell because we are already using this term in several places, so it will be simpler for current developers to associate this.
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.
Sounds good. Thanks @matuzalemsteles . Can you create a ticket for making this change?
Yes, but we are not yet using all the features it provides. For example, I haven't enabled virtualization yet because I will do that when I'm working on the treegrid implementation. Another feature we probably won't use is infinite scroll since table is typically used with pagination, so I'll enable when we have use cases for that. |
I'm going to merge this to continue working on the other tasks. But if we need to make any changes we can send it in another PR anyway. |
Closes LPS-192998
This PR implements new components for Table to make room for new OOTB features for developers, so we can continue improving the UX and making the component more useful and prevent developers from having to implement more features on top of that.
The idea here is to bring a data-oriented composition using the Collection pattern that we already use in other Clay components, this already brings the UX benefits that we have in other components and we can also implement the features such as list virtualization that we need to implement the treegrid pattern and the column resizer.
Instead of implementing this on top of the Table currently, we are recreating the component parts in a new composition to avoid backward compatibility or mechanisms that have to identify when using the old or new composition to use the right component. So to use the new composition use the Table from
@clayui/core
and we leave the component in@clayui/table
in deprecation mode.This is the new UX and composition of the component, it is not yet public. I will make it public only after we implement all the new features, such as treegrid support and column resizer with OOTB accessibility.
Just like in other components that use collection, the list can be static or dynamic, for example
<Row />
can be a static list when the column is not dynamic.