-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Make the editor canvas friendly towards colored backgrounds #6406
Conversation
Looks good from what I saw in the video. I also had the same considerations with different opacities based on if the BG is light/dark. To be honest, I cannot think of a different approach than this to add background support... so I think this is the best approach on that basis. Something I've picked up upon from adding this on a prior site built in Gutenberg and watching the video you've attached is that the hover states of the buttons need a white background as otherwise the border looks kinda ugly. |
Cool, thanks for the initial sanity check, Paul. I'll let this branch sit for a bit further, but then take a stab at making further improvements.
Yep — that's a solid point, and something I'll add. 🤘 |
Hmm... giving themes the power to modify the UI could potentially break any colors contrast ratio for accessibility. I'd tend to think Gutenberg should preserve the accessibility of its own interface, maybe reserving some light background around its controls. Also, using opacity will make a bit difficult calculating the contrast ratio... as we won't be able to pick up the actual color from the CSS (or browser inspector), inteaad we'll have to use tools that pick up the colors rendered on screen 🙂 |
In theory this seems like a good idea on unification. I absolutely agree with breaking it down. Before I review though, how does (if at all) fit in with: #5360? I also wonder a little from an accessibility view but right now we have that with editor styles. Maybe we can consider what boundaries we do/don't let people style? |
Ah yes, excellent memory, thanks for bringing that back on my mind, I'd forgotten it totally. Re-reading that post, it seems like this PR could still be complementary. I.e. we want to allow themes to load an editor style into the editor, and style every block. If a theme then opts-out of "opinionated styles" as Matías calls it, those styles would simply not load in the editor, and the theme would not have to deal with them, either in the editor or on the frontend. In that vein it would be similar to a theme that has not opted into wide images — they can still style the editor with an editor style. |
Responding separately due to the feedback from two angles:
and
Both good observations and thoughts. Given the overall positive reception this PR has engendered, I think this is what I'll tackle next. I feel like we have many options on the table, such as just always showing the filled-out buttons behind the side UI, or looking at things like inversion That said, a badly designed theme will always be able to work around these for non-UI aspects, such as providing light gray text on a white background. Enforcing that seems like a task for the theme-review team, if at all. |
407bfcf
to
e54bfdb
Compare
I created a more or less duplicate issue #6451 (sorry to dup - I find it very hard to search existing issues) I thnk some of the default colors on these edit controls certainly can use improvement, but I also now think this could be a theme requirement. It is possible to get very nice looking controls using just code listed in #6451. Letting the theme handle control styling alleviates trying to get a one-size-suites all solution. |
e54bfdb
to
1f0dcee
Compare
d46948f
to
087c016
Compare
This updates the extensibility document, and adds a section around loading editor styles. It gives examples for how to change the colors of the editor (which will look good once #6406 gets merged), as well as how to change the width of the editor. The last part fixes #1483. CC: @maddisondesigns
One long term vision for the editor, is to allow you to load the theme stylesheet into the editor canvas itself, so you have an almost if not completely WYSIWYG experience where the theme background and fonts apply to the editor. In the interim, we should make it easier to load _editor styles_ into the canvas. This already works today, but the block UI is not really ready for it — white backgrounds are used here and there, and borders are colored light grays which quickly disappear on some colors. This PR takes an initial stab at alleviating that, by moving to using various levels of opacities of the darkest gray we have, to emulate the range of opaque grays we have. As such, this PR includes a range of those opacities. For example, shown on a white background, $dark-opacity-500 should look the same as $dark-gray-500, but the latter should look good on colored backgrounds as well. This is going to be a fair bit of work, and this is only the beginnings of it. It styles the borders, the outermost toolbar borders, the naked mover/settings/more icons, and the title field, as well as the appender. In doing this, it now means you can at least change the background color and still sort of use the editor. Asking for thoughts now, before I do more work — what do you think of this approach? If there's positive agreement on this direction, I will fix the drag and drop shadows/colors. Note that this PR makes the UI work on _light_ backgrounds. If you cross a certain threshold of luminosity into the dark background territory, we need to invert the colors. This PR already contains the opacities for that, but we'll need to detect the background color and apply a body class, something like `body.has-dark-background`, so that I can invert the UI for that. Would appreciate thoughts on this too.
087c016
to
05386b8
Compare
7bde1c8
to
5f5868e
Compare
Okay, pushed some polish, and I think this is ready for final review. This PR now:
Please review any contrast issues that might have come up as part of this — I've tried my best to match the new opacity based grays to the existing grays, but if there are any regressions, they are easy to adjust. Default — this should ideally look the same as before: Light theme: I also included colors that work based on dark themes. But this is not yet activated anywhere. Essentially we need to apply an Let me know your feedback. |
) * Update theme extensibility documentation to include editor widths This updates the extensibility document, and adds a section around loading editor styles. It gives examples for how to change the colors of the editor (which will look good once #6406 gets merged), as well as how to change the width of the editor. The last part fixes #1483. CC: @maddisondesigns * Simplify syntax a bit. * Trim whitespace
border: 1px solid $dark-opacity-light-500; | ||
|
||
.is-dark-theme & { | ||
border: 1px solid $light-opacity-light-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.
border-color: $light-opacity-light-500;
} | ||
|
||
.edit-post-header-toolbar__block-toolbar & { | ||
border-left: 1px solid $light-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.
border-left-color: $light-gray-500;
border: 1px solid $dark-opacity-light-500; | ||
|
||
.is-dark-theme & { | ||
border: 1px solid $light-opacity-light-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.
border-color: $light-opacity-light-500;
outline: 1px dashed $dark-opacity-light-500; | ||
|
||
.is-dark-theme & { | ||
outline: 1px dashed $light-opacity-light-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.
outline-color: $light-opacity-light-500;
border-right: 1px solid $dark-opacity-light-500; | ||
|
||
.is-dark-theme & { | ||
border-right: 1px solid $light-opacity-light-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.
border-right-color: $light-opacity-light-500;
border-left: 1px solid $dark-opacity-light-500; | ||
|
||
.is-dark-theme & { | ||
border-left: 1px solid $light-opacity-light-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.
border-left-color: $light-opacity-light-500;
outline: 1px solid $dark-opacity-light-500; | ||
|
||
.is-dark-theme & { | ||
outline: 1px solid $light-opacity-light-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.
outline-color: $light-opacity-light-500;
Just left a few comments where it's probably best to set only the colour when Just a small nitpick really, heh. |
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.
@@ -67,7 +67,7 @@ | |||
|
|||
// This is a focus style shown for blocks that need an indicator even when in an isEditing state | |||
// like for example an image block that receives arrowkey focus. | |||
.edit-post-visual-editor .editor-block-list__block:not( .is-selected ) { | |||
.edit-post-visual-editor .editor-block-list__block:not( .is-selected ):not( [data-type="core/paragraph"] ) { |
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.
Why not paragraphs?
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.
Good question. This branch has been around long enough that I don't recall adding this — could it have come in as part of a rebase and later been removed?
In any case I removed it again becaues I couldn't see any regressions as a result.
@@ -1,6 +1,6 @@ | |||
.components-draggable__clone { | |||
& > .editor-block-list__block > .editor-block-list__block-draggable { | |||
background: $white; | |||
background: $white; // @todo: ensure this works with themes that invert the color |
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.
Has this been done?
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.
No, and I'm not sure that this can be done. At least I'm open to ideas here.
The thing is, the draggable clone has to have a background, or you can see the text below through it. It would be nice if we could eyedrop the color of the body
, but even then a user could've applied a background image or pattern.
.edit-post-header-toolbar__block-toolbar & { | ||
border-left-color: 1px solid $light-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.
Missing a new line at the end of the file here.
Thanks for the review, @noisysocks! I pushed some changes to address your comments. Except for this one #6406 (comment) because I'm not sure how to best address that. However, given that |
CC: @jorgefilipecosta — can you rebase your nested blocks for cover image branch and see if this improves things? |
@@ -3,8 +3,8 @@ | |||
// value is designed to work with). | |||
|
|||
$z-layers: ( | |||
'.editor-block-list__block-edit:before': 0, |
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.
Not certain why this change was required but it broke the PlainText inside blocks (code block for instance). It should be fixed by this though #6844
My apologies for the regression, and thank you for fixing it! |
One long term vision for the editor, is to allow you to load the theme stylesheet into the editor canvas itself, so you have an almost if not completely WYSIWYG experience where the theme background and fonts apply to the editor.
In the interim, we should make it easier to load editor styles into the canvas. This already works today, but the block UI is not really ready for it — white backgrounds are used here and there, and borders are colored light grays which quickly disappear on some colors.
This PR takes an initial stab at alleviating that, by moving to using various levels of opacities of the darkest gray we have, to emulate the range of opaque grays we have. As such, this PR includes a range of those opacities. For example, shown on a white background, $dark-opacity-500 should look the same as $dark-gray-500, but the latter should look good on colored backgrounds as well.
This is going to be a fair bit of work, and this is only the beginnings of it. It styles the borders, the outermost toolbar borders, the naked mover/settings/more icons, and the title field, as well as the appender. In doing this, it now means you can at least change the background color and still sort of use the editor.
Asking for thoughts now, before I do more work — what do you think of this approach?
If there's positive agreement on this direction, I will fix the drag and drop shadows/colors. Note that this PR makes the UI work on light backgrounds. If you cross a certain threshold of luminosity into the dark background territory, we need to invert the colors. This PR already contains the opacities for that, but we'll need to detect the background color and apply a body class, something like
body.has-dark-background
, so that I can invert the UI for that. Would appreciate thoughts on this too.Video: https://cloudup.com/cDX4dvMYFvs