-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Apply background to DataViews wrapper #73390
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
|
Size Change: +69 B (0%) Total Size: 2.54 MB
ℹ️ View Unchanged
|
|
This approach works for me |
|
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. |
| font-size: $default-font-size; | ||
| line-height: $default-line-height; | ||
| background-color: inherit; | ||
| background-color: var(--wp-dataviews-background, $white); |
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.
The concern I have about using --wp-dataviews-background is that it becomes a public API that we need to maintain. If we are committed to doing so and this is the way we recommend theming going forward: we need to add tests so it doesn't regress unintentionally.
I also worry that this is insufficient: if consumers can tweak the background color but not the foreground one, wouldn't that be an issue?
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 your second point, obviously we can't fully control this, but assuming consumers use semantic color tokens from @wordpress/theme (which they should be if they want to maintain theme-ability) then contrast would be handled automatically.
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 be --wp-dataviews-color-background for consistency with the existing --wp-components-color-background (i.e. the naming convention used in the components package)?
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.
Overall I like the approach here, too, of using a CSS variable and falling back to $white. Or failing that, reverting #73240 as the update to use inherit breaks the sticky footer for DataViewsPicker when used in a modal, too (e.g. the DataViews-powered media library experiment). I.e. this is what it's looking like without this PR:
In practical usage, if someone's using DataViews or DataViewsPicker within a Modal component it's pretty awkward to set the background color on the parent due to the component's internal classnames, so I reckon a CSS variable is a better way to go than exclusively relying upon inherit.
But this PR is testing nicely for me when rebased against trunk and using the DataViewsPicker WithModal story 👍
|
@oandregal I just wanted to point out that this feels closely related to #72989. There seems to be a growing need for more flexiblity about how certain DataViews aspects are styled in different contexts. I don't know if that changes your perspective at all? |
|
@jameskoster I've been catching up on For me, this is good to go as long we treat this as public API:
All of that shouldn't block this PR. I'm happy to help figure out how to better test this, but I'd appreciate it if you all bootstrap a new README section in DataViews for this (doesn't need to be in this PR, but it needs to happen). |
| font-size: $default-font-size; | ||
| line-height: $default-line-height; | ||
| background-color: inherit; | ||
| background-color: var(--wp-dataviews-color-background, $white); |
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.
@jameskoster I don't know how standard all of this is, but I've noticed that we're using --wp-* in existing components, and --wpds- in other places. When do we use one, and when do we use another? I haven't found anything that clarifies that, and would like to understand which one should we use here.
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.
wpds is the prefix for the new theme package. I think here the name is right and similar to the vars of components package.
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 was discussed at #72989 (comment)
|
@jameskoster I've got a follow-up question about the approach at https://github.com/WordPress/gutenberg/pull/72989/files#r2549149227 I thought you argued for using CSS Custom Properties for styling DataViews, or did I misunderstand? |
We may change direction, but would you agree that DataViews should 'work' on different background colors regardless to increase portability? Or do you think this is too much of a stretch technically? To elaborate a bit: in So based on the assumption that we want DataViews to look correct on different backgrounds we need a strategy to ensure compatibility with those tokens. That way, if we decided (for example) that Modals should have a light gray background then DataViews rendered in a Modal would 'just work'. I acknowledge an alternative approach would be to say DataViews always has a white background. But if we go in that direction we may need to adapt the design a bit to account for the fact it can render in many different contexts like the modal example above. This all ties in very closely with github.com//issues/72336. |
Yeah, I agree. We've passed the "prototype phase" and we are now in the "expand phase" for the library. We need to tie it to the larger efforts (design system, etc.), which means support theming concerns. Using CSS Custom Properties a public API for styling/customization makes sense, and I've used that in the past in a smaller scale project. There are implementation details that are not clear to me yet (how do we handle breaking changes, how do we test, what are the proper tokens to expose, how do we tie this with WordPress admin themes, etc.). Those are important concerns to figure it out, but don't need to all clear before merging this PR. |
|
I think the following approach could also be considered. Note that I removed the .dataviews-wrapper,
.dataviews-picker-wrapper {
--dataviews-color-background: $white;
background-color: var(--dataviews-color-background);
}This is similar to the approach taken to allow the size of checkboxes to be overridden, for example. The advantage of this approach is that it limits the scope of the CSS custom property to the DataViews package. Consumers are forced to explicitly define a CSS custom property at the same hierarchy if they want to override the color: .my-app {
.dataviews-wrapper,
.dataviews-picker-wrapper {
--dataviews-color-background: #ddd;
}
} |
8a1a04d to
0adb4ec
Compare
|
I've just given this a rebase to fix merge conflicts. Any objections if we merge this PR in its current state? It looks like the main question is whether we're happy with the I don't have a strong opinion re: the naming, but it would be good to land this PR in time for Gutenberg 22.2 so that the bug introduced in #73240 doesn't make it into the release. |
89ad130 to
2b51c26
Compare
|
I've pushed documentation. I am still unsure how can we add tests for this, in the meantime, I've added it to storybook. |
This means consumers need to know the internal structure of the DataViews component, and if it changes it'll be a breaking change. If we were to set an initial value for the property, I'd rather do it with a |
|
Thanks for landing this, @oandregal! 🙇 |
What?
Small follow-up to #73240.
.dataviews-wrapperand.dataviews-picker-wrapper--wp-dataviews-backgroundWhy?
Allows consumers to apply a different background color to DataViews.
Testing Instructions
npm run storybook.dataviews-wrapper