Colored tables, prevent style leaks from nested tables & other table tweaks#26678
Colored tables, prevent style leaks from nested tables & other table tweaks#26678MartijnCuppens wants to merge 21 commits intotwbs:v4-devfrom
Conversation
|
Wow! this is a huge PR and at first glance it's pretty fantastic. Thanks a lot @MartijnCuppens I'll make sure to find time this week to review it. |
|
Thanks @andresgalante! Yeah, I was working on a solution to prevent styles from leaking to nested tables, but this code also influenced the the theming of coloured tables. Before I knew it I was rewriting a lot. The only thing I kept my hands of was the responsive tables (because of #25813). I think a rewrite like this is needed to make the bootstrap tables more consistent but if you have some improvement suggestions, let me know! |
|
I am concerned about this increase many CSS. Current: .table td,
.table th {
...
}After: .table > thead > tr > td,
.table > thead > tr > th,
.table > tbody > tr > td,
.table > tbody > tr > th,
.table > tfoot > tr > td,
.table > tfoot > tr > th {
...
}@mdo and many people may not like a universal selector for performance reason, but it is effective in this case? .table > * > * > td,
.table > * > * > th {
...
} |
|
This PR actually decreases the file size of the css files because of the flexible implementation of the coloured tables. But indeed, using the universal selector would decrease the file size even more (I would keep the |
|
Some v4 dev (June 14): PR without universal selector: PR with universal selector: |
|
About the universal selector usage: Let's analyse this case: For the first line, the browser searches for all This case: For the first line, the browser searches for all Original case: For the first line, the browser searches for all Source: https://www.youtube.com/watch?v=2Rn8an74khk&feature=youtu.be&t=14m28s I just changed my PR and used the universal selector. |
mdo
left a comment
There was a problem hiding this comment.
Definitely appreciate the huge undertaking here, but I didn't get far into this diff—we can't change the selectors like this. It was an intentional change in v4 to simplify the table selectors. Perhaps remove that and let's see where we net out?
|
@mdo, do you want me to remove the child combinator ( |
|
@mdo, you're right, this would mean every developer would need to add the For Nested What do you think? |
|
Closing for now given conflicts and upcoming changes to v5. Opened #28480 to revisit for our next major release. |
Edit: I'm going to review this for
v5thead,tbody,tfoot,tr,td&th) are inherited from their parent. This allows us to easily modify styles without the generation of a lot of css selectors.tfoot. There will always be a thicker line betweenthead,tbody&tfoot..tables don't inherit styles anymore$table-vertical-align$table-colorssass map allows us to easily add or remove colored tables.thead-lightand.thead-darkare removed in favor of more universal.table-lightand.table-dark(classes generated from$table-colorssass map)$table-show-border-top&$table-show-border-bottomcolor-yiq())box-shadowinstead ofbackground-color. This way we don't have to generate all the background colors for colored striped tables and colored hoverable tables.@transitionmixin)color-yiq()) have lighter rows, so that there is enough contrast.is-lightandis-darkfunctions. These might come in handy for other purposes in the future.Known issue:
Also made an interactive codepen demo:
https://codepen.io/MartijnCuppens/pen/jxRJPB
Documentation page:
http://martijncuppens.github.io/tables/docs/4.1/content/tables/
Closes #25842, closes #25685, closes #25675, closes #24529, closes #27312
Related PRs: #25864, #25755, #25677, #24660