Twenty Twenty Blocks: Try adding new Global Styles Rules - #44
Conversation
| font-feature-settings: "lnum"; | ||
| font-variant-numeric: lining-nums; | ||
| font-weight: 700; | ||
| font-weight: var(--wp--typography--font-weight-heading); |
There was a problem hiding this comment.
Have the --wp--typography-- variables gone away? I don't see them being applied anymore when I activate this theme. Do they need to be converted to presets in the theme config?
There was a problem hiding this comment.
Ah, whoops. That's a leftover from the last attempt at this. It needs to be converted to use the new system.
There was a problem hiding this comment.
This should be take care of in fe1e88e.
There was a problem hiding this comment.
Actually wait — I need to get it fixed in the editor styles too. 👍
|
@jffng This should be ready for another review. 👍 |
| font-size: 36px; | ||
| font-weight: 800; | ||
| .editor-styles-wrapper h1.wp-block { | ||
| font-size: 84px; |
There was a problem hiding this comment.
Just wondering why we're using px values here when rem values are used in the frontend.
There was a problem hiding this comment.
In the frontend, Twenty Twenty modifies the value of 1 rem to be 10px instead of the usual 16px. Since that doesn't happen in the editor (and can't really, without messing with a lot of other font sizes), we're stuck with pixels for the moment.
These should really be variables, but I didn't switch to using variables for these sizes because the heading font sizes don't match up with the small, normal, large, + huge sizes. I figured we'd keep things simple for now, and can open up a separate PR improve this.
jffng
left a comment
There was a problem hiding this comment.
I left one comment about applying colors to buttons. Other than that, this works in my testing.
| background-color: #000; | ||
| color: #f5efe0; | ||
| background-color: var(--wp--preset--color--text); | ||
| color: var(--wp--preset--color--primary); |
There was a problem hiding this comment.
I had to do a few weird things to get this working:
- Rename the "Text" color to "Foreground". Otherwise, the class to indicate that this color was being used was
has-text-color. This also happens to be the generic classname that's added to blocks when they have any text color assigned. That caused some conflicting styles. - I had to rewrite some of the styles, because they seemed to be wrong.
- I had to add some extra specificity to get the custom color rules working for buttons.
It's possible I chopped out a little more code than was necessary here, but it generally seemed to work for me.
| @@ -2736,21 +2736,21 @@ h2.entry-title { | |||
| /* CUSTOM COLORS */ | |||
|
|
|||
| :root .has-accent-color { | |||
There was a problem hiding this comment.
Is the :root selector still needed? I noticed that in #45 it wasn't used and still worked.
There was a problem hiding this comment.
Yeah, these don't get used at all currently — they're overridden by rules assigned to .editor-styles-wrapper instead.
jffng
left a comment
There was a problem hiding this comment.
This works and I think does a good job demonstrating where we're at with the current Global Styles mechanism. Left one comment that's not super relevant but had me head-scratching nonetheless.
| /* CUSTOM COLORS */ | ||
|
|
||
| :root .has-accent-color { | ||
| .editor-styles-wrapper .has-primary-color, |
There was a problem hiding this comment.
Why do we need to target .editor-styles-wrapper? I though that enqueueing via add_editor_style was supposed to handle this for us?
There was a problem hiding this comment.
Ah, that's a good question. The non-blocks version of twenty twenty enqueues the editor styles using the old hook, not via add_editor_style. Since we don't do that in the block-based theme here, we should probably strip all these out of the editor stylesheet. They're not necessary anymore.
I'll leave that for a followup PR though.


Takes a quick pass at adding Global Styles rules to Twenty Twenty Blocks, as per the new documentation. Essentially an updated version of #26.