-
Notifications
You must be signed in to change notification settings - Fork 4.6k
DataViews: Sticky elements inherit bg from container #73240
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
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Nice work here :) This had regressed a few times in the past already (hover styles mostly) |
|
Size Change: +87 B (0%) Total Size: 2.42 MB
ℹ️ View Unchanged
|
ntsekouras
left a comment
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.
LGTM, thanks!
If we do that then it won't be possible for DataViews to inherit the background from the container it's placed in (which was the whole purpose of this PR 😅). Agree we should fix Storybook though, maybe the story just needs an update to wrap the DataViews instance in a container with a backround? |
I see, so it's possible that the background will be applied to a parent container of the dataview-wrapper.
Yes, I think that's fine. |
Isn't there a way to fallback to white though or something? I think DataViews should just work regardless of where you put it basically (ideally). |
As far as I know it's not possible to do this with css. Maybe there's another way? |
|
Apparently our only solution for an automatic behavior is JS and store this maybe in a local CSS variable to use across the board in dataviews. Alternatively, we could use a CSS variable and ask folks to provide it. |
To me this seems like a simple and clear solution. It might look something like this: .dataviews-footer {
background-color: var(--wp-dataviews-background, #fff);
} |
|
I did think about a CSS variable. It works, but wouldn't it require all container components (e.g. Card) to define Cross-awareness of components doesn't feel great to me. This is starting to feel a bit related to the conversation in #72336. I suppose we could go in the opposite direction and say that DataViews always has a white background (the whole thing, not just the sticky elements). With one eye on:
That would produce something like this, which honestly seems okay to me:
|


What?
Update DataViews styles so that sticky elements inherit their background color from the parent container.
Why?
Currently these elements have a hard-coded background color. That means if you want to use DataViews with a non-white background color you need to apply style overrides or endure these awkward mismatches:
How?
Apply
background-color: inheritto relevant elements. Result:Testing Instructions
Storybook
npm run storybook.Site editor
Check table layouts for any regressions.
Note
There is a trade-off with this approach; if a DataViews instance is placed in a container with no background color (or a transparent one) the inheritance will fail. Perhaps we should add a note to the documentation about this?