-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Try global styles at blocks #20273
Try global styles at blocks #20273
Conversation
Do you think it could be better to split the PRs block by block (or maybe group by similar blocks), just to review and merge quickly? |
Also would be good to focus initially on one or two blocks until we know things are sailing smoothly. |
@@ -1,7 +1,7 @@ | |||
$blocks-button__height: 56px; | |||
|
|||
.wp-block-button { | |||
color: $white; | |||
color: var(--wp--color--white, $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.
This covers the case where --wp--color--white
is not present, so it fallbacks to $white
. However, we also need to cover cases where the browser doesn't have support for CSS Custom Properties and write something like:
.wp-block-button {
color: $white;
color: var(--wp--color--white, $white);
}
which can be done automatically with some plugins.
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.
We also don't want to do this until we're certain this is the way to go.
@@ -1,13 +1,13 @@ | |||
.wp-block-pullquote { | |||
border-top: 4px solid $dark-gray-500; | |||
border-bottom: 4px solid $dark-gray-500; | |||
border-top: 4px solid var(--wp--color--foreground-500, $dark-gray-500); |
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.
@@ -1,12 +1,12 @@ | |||
.wp-block-quote { | |||
border-left: 4px solid $black; | |||
border-left: 4px solid var(--wp--color--border, $black); |
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.
@@ -61,7 +61,7 @@ | |||
background-color: transparent; | |||
|
|||
tbody tr:nth-child(odd) { | |||
background-color: $light-gray-200; | |||
background-color: var(--wp--color--foreground-200, $light-gray-200); |
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.
@@ -1,5 +1,5 @@ | |||
pre.wp-block-verse { | |||
color: $dark-gray-900; | |||
color: var(--wp--color--foreground-900, $dark-gray-900); |
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.
@nosolosw Ah yes! An alternative From a core block perspective, it's easier to identify the global styles as they live in a separate folder. As of this moment, I'm unsure how this may play out for 3rd party blocks. Perhaps they too can provide a (Just thinking out loud) |
This was more of an exploratory PR to see how things looked. We may want to do a single PR with a few blocks first and then expand by doing separate PRs per block.
I wish we could remove the need for a scoping mechanism altogether, but it doesn't seem like we can so far. The way I see it, we have two alternatives:
Both options have cons/pros. I think I slightly prefer the second one for clarity (authors don't need to know whether a style should be scoped with |
Also worth noting that this is only for specific bits, not everything. If a property was already included in the CSS, fallbacks can be used. The issue is for those properties that weren't previously included and we want to add to expose the CSS vars for the style system. This may be a minority of things and there may be situations where it's ok to just have them in the block stylesheet. It needs to be evaluated case-by-case. |
We're taking a different direction so I'm closing this. |
This PR does two things:
wp-gs
class, it enqueues the styles in a separate stylesheet (if the theme has support for global styles and the experiment is enabled).In creating an experimental theme for testing, I've found this has a number of advantages over the
wp-gs
:wp-gs
or not.