-
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: Move color and font size from captions to theme #14366
Conversation
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.
❤️ Love this!
One small step for caption color. One giant leap for opinionated styles 👨🚀 😄 Couple questions while we're here.
I understand we're styling Could we not just do a general style that will only apply to those that actually need it?
|
Wonderful feedback, thank you Chris and Marty! I have tried to address it in 0666ad8. But note that the way
Whereas I took your advice and moved the generic Thanks all. |
Keeping the extended markup in Shaping up the In 0666ad8, I see we've got the |
Once again solid feedback. I pushed a fix to move the Editor: Theme: Theme, before this latest commit: I misremembered when I wrote in the initial description.
|
This was part of the issue. In order to have the front end match the back end, the theme has to do something. If it's opt-in for the front, it should be opt-in for the back as well. The opinionated styles should only show when the theme opts in. This is especially a problem with colors. You should use a dark theme for your test cases. And this discussion relates to the other issue about specificity. Styling anything with more than one class should be how the theme overrides the editor styles. If the editor styles had only one class, it would solve a lot of problems. All selectors should be as vague as possible and still get the job done. |
Yep, this I think is the fundamental problem… Ignoring any special styles that are used to build the editor itself, the editor should only ever load presentational/block styles that are loaded in both the front-end and back-end. |
What was the original reason for ignoring a theme's choice and always loading I remember something about blocks functioning properly but I don't know how valid that is. This PR for |
I can't recall the specific circumstances, but I know for a fact no malice has ever been intended 😅 — I know that should go without saying, but sometimes it's good to just outright say it: all decisions can be revisited. In this case, if we're careful and smart about what goes in style.scss and what goes in The balance to be mindful of is that of ensuring the editor has a sufficient default style. For any theme that is not Gutenberg aware, we have to provide a good experience. Without structural CSS in the Cover block, for example, it won't work at all in older themes. But as is hopefully demonstrated by changes in this PR, we evaluate each and every specific selector and fix them up. In that vein, I'd like to also direct your attention towards #14407 which tackles a tangential but very much editor style related issue. That PR is very much in progress and some of the open questions are around where to put which styles. Any changes we might need to do to theme.scss loading could either happen in that PR, or grow out of it. |
Of course not! 😄 #14407 looks pretty heavy. I like it! |
Never! I feel grateful that I get to ping you on PRs, your help has been invaluable. The past two years of working on this has just taught me that it's often good to re-state the obvious, if nothing else then as a confirmation ❤️ |
So this one is technically approved and milestoned. But is it actually approved? Since the first approval I made a fair bit of changes. It would be nice to get a second sanity check. It won't make the deadline for 5.3 (today), which is okay, but it'd be nice to merge in right after. |
@jasmussen I don't think this one is ready yet. In the editor the
Not sure of the best way to handle that. Add the style again in I'm also wondering if the Can you see a case where the |
Interesting, good call. This is actually "fixed" in that other PR I'm working on: #14407 (comment) — but I suppose I can remove it here too, if it doesn't serve a purpose, that is. I know you're busy @ellatrix but I feel like you must be the best to know what that margin might be necessary for. Do you think we can remove it?
About to head out for the day, but I seem to recall maybe the figure having a zero bottom margin, which means we need it elsewhere, or we need to revisit that zero bottom margin. Which begs the question, do I fix that here, or do we remember it and fix it as part of #14407 which will no doubt have to touch that aspect? Thanks. |
Yeah, #14407 does kinda blur this PR a bit.
You're correct. I do see a couple with margins removed:
I'm guessing this is to remove the default
Probably best to avoid shorthand properties like |
@jasmussen Sorry, I missed the ping. I don't know why that rule is there, it's not used by rich text for anything. Just styling. |
Addressed margin feedback in 710b354, thanks @m-e-h. As a small iterative improvement, I would very much like to ship this PR even if it isn't yet perfect. As mentioned, #14407 is a much more profound effort to further the improvements that this PR started. In other words, instead of working on two slightly overlapping PRs, I'd love to ship this, rebase the other and continue work there. If that's okay with everyone, I'd love to get this given a final review. Thanks. |
@jasmussen I know it's taken care of in #14407
|
Agreed with @m-e-h — I'm still seeing that rule override the caption's top margin, and it's resulting in different spacing than before this PR. Once that's sorted out, we'll be good to go. |
4b7d229
to
a252b7c
Compare
Great call folks. I've removed it. Aside from being good feedback that I missed (thanks) — I am ever so slightly nervous about removing that property simply because I'm not sure why it was there in the first place. Which makes now a good time to merge this because it's just after the 5.3 release, so it has a week to simmer. Looks good to me: Rebased. This should be good to go now. |
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.
🎉 Looks great! Thanks Joen.
This PR moves the color and font size styles for captions to a separate CSS file that themes opt in to. As a reminder, we have style.scss, which contains structural and base styles that are loaded in the editor and the theme. There's editor.scss which is only loaded in the editor. There's theme.scss, which is loaded in the editor and the theme if the theme opts in to them. Addresses one item surfaced in #12299 (comment), props @joyously.
a252b7c
to
9b84916
Compare
The removal of the margin (especially the top one) is a breaking change for custom blocks that reuse RichText within a block. Example: Before: After: It's also breaking the reusable blocks edit mode: Before: After: I suspect there are also other cases. I'm not sure this kind of changes can be made so lightly. Even if this is "just" CSS, it can break things because it's changing the expected rendering. There has been a recent discussion on Slack about what can be considered a breaking change and what the level of backwards compatibility should be. There's a tendency to consider CSS changes as something that doesn't need backwards compatibility because not part of a "formalized API". Honestly, I really don't mind when discussions like that are made in a so abstract way without considering the real consequences for the developers ecosystem out there. Trying to keep up with these changes is exhausting and not sustainable, especially when they're not communicated well in advance and with great relevance. That said, this is breaking also the core blocks. Will create a new issue. |
This PR moves the color and font size styles for captions to a separate CSS file that themes opt in to.
As a reminder, we have style.scss, which contains structural and base styles that are loaded in the editor and the theme.
There's editor.scss which is only loaded in the editor.
There's theme.scss, which is loaded in the editor and the theme if the theme opts in to them.
Addresses one item surfaced in #12299 (comment), props @joyously.
Here's a caption for at theme that has not opted into theme.scss styles:
Here's a theme that has opted in: