Skip to content

De-dupe .table-dark, add new border color utilities, and update table docs#30342

Closed
mdo wants to merge 4 commits intomasterfrom
dark-tables
Closed

De-dupe .table-dark, add new border color utilities, and update table docs#30342
mdo wants to merge 4 commits intomasterfrom
dark-tables

Conversation

@mdo
Copy link
Member

@mdo mdo commented Mar 5, 2020

Alternative to #30193. This ended up being a couple changes in one, hence the length title, but the two are connected.


De-duped .table-dark

Rather than deviate from the $theme-colors pattern we have elsewhere, this PR removes the .table-dark for changing the background, color, and border of a .table. Instead, this can be accomplished through all utilities.

Also removes thead-dark/thead-light modifiers for utilities.

New border-color utils

To support the utilities-driven approach for replacing .table-dark, I've added a few new border-color utilities. These are a subset of our available grays, but I do believe they provide an improved set of options without including all the grays (and thus duplicating $gray-900 and $dark options). The new options have been added to the borders utilities docs page.

New background-color utils

To match the border utilities, I've added one tint lighter for two gray backgrounds (didn't add $gray-100 as it's the same as $light). This way you can choose from additional gray backgrounds and still have a slight contrast in the border colors. Definitely interested in thoughts on this.

Updated table docs

This also obviously updates the examples in the tables docs to reflect the new dark table approach, but also clarifies how inheritance comes into play with the table styles and the table borders. It also adds a new multiple <tbody> example and tweaks a few other bits and pieces.

https://deploy-preview-30342--twbs-bootstrap.netlify.com/docs/4.3/content/tables/


Closes #28480, fixes #27879, nullifies #30046, fixes #28160, and fixes #24529.

@mdo
Copy link
Member Author

mdo commented Mar 5, 2020

For next steps, I'm wondering if we also remove the .table-* variants and opt for all background, border, and color variations... Might be pushing it too much.

@acshef
Copy link

acshef commented Mar 5, 2020

@mdo, if you remove the .table-* variants, will there still be the "fainter" colored backgrounds available in v5? It's always been tempting to use them outside of a <table> or .alert, but it's been semantically irksome to use .card.table-primary for something that's not a table.

image

@mdo
Copy link
Member Author

mdo commented Mar 6, 2020

Yeah we could perhaps ditch those and create a broader suite of utilities. It was a huge ask awhile back to have light and dark background options. Might be a v6 thing.

And also works with table color classes:

{{< example >}}
<table class="table table-striped">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This table looks pretty ugly 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I know lol... remove it? Find a better example?

@MartijnCuppens
Copy link
Member

Wow, the linear-background() hack is a genius move!

@tmorehouse

This comment has been minimized.

@tmorehouse
Copy link
Contributor

tmorehouse commented Mar 8, 2020

One may even want to add in a .table-hover-light modifier that uses a light translucent gradient rgba($white, .075) instead of rgba($black, .075), when users have dark (almost black) background color. It would just add two more generated CSS rules (assuming targets the td and th of tbody) and one new SASS variable

@mdo mdo force-pushed the dark-tables branch 2 times, most recently from e27c8bc to 1397d31 Compare March 8, 2020 22:43
@mdo
Copy link
Member Author

mdo commented Mar 8, 2020

Rebased and recombobulated the commits here in case we want to pull out the border and background utility changes.

mdo added 4 commits March 8, 2020 15:51
CSS doesn't allow inheriting `border-color` on td/th elements when using shorthand notation (e.g., `border: 1px solid #eee`). By separating the values, and disabling clean-css on these rulesets, we allow a single utility class on the `.table` to color our entire table's borders.
- New background-colors: gray-500, gray-700, and black
- New border-colors: gray-400, gray-600, and black

Note that the border colors are all one shade darker than the backgrounds so that they maintain some contrast.
@ysds
Copy link
Contributor

ysds commented Mar 9, 2020

Can we use the unset to nested tables if dropping IE11 in v5?

@MartijnCuppens
Copy link
Member

Can we use the unset to nested tables if dropping IE11 in v5?

We could, but I guess CSS specificity will be a PITA

@ysds
Copy link
Contributor

ysds commented Mar 9, 2020

We could, but I guess CSS specificity will be a PITA

Oh I forgot that..

@MartijnCuppens
Copy link
Member

CSS custom properties on the other hand... https://codepen.io/MartijnCuppens/pen/eYNVmzp

@mdo, we probably better switch to a CSS custom properties approach which will help us out with the nesting issues.

@tmorehouse
Copy link
Contributor

@MartijnCuppens Intereting idea.

One might have to be careful which the CSS variable names.. perhaps --table-bg-color... if similar variable names were used for other things (such as input group background colors, alert background colors, etc) when they are nested inside a table.

@MartijnCuppens
Copy link
Member

@tmorehouse, of course. That was just a quick demo 😉

@mdo
Copy link
Member Author

mdo commented Mar 20, 2020

So I need to circle back around to this and check in on some things around inheritance and nesting. I don't think mixing the CSS vars and Sass makes sense necessarily? Maybe I'm missing something there.

@MartijnCuppens
Copy link
Member

I'm working on an alternative solution, will open another PR soon.

@stgm
Copy link

stgm commented Nov 25, 2020

Has the use of linear-gradient been performance-tested in some way? I have an example where this makes Safari rendering extremely slow when scrolling. Removing the gradient helps, but obviously kills my striping. If this wasn't expected, I can have a look at creating an example and posting an issue.

@MartijnCuppens
Copy link
Member

If this wasn't expected, I can have a look at creating an example and posting an issue.

Please do if there are any performance issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v5: Revisit table styles Suggestion for .table-hover .table-dark is used in two conflicting contexts Inconsistant .table-active color

7 participants