Skip to content
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

Update the .is-dark-theme UI for Quote and Pullquote blocks #26510

Merged
merged 1 commit into from
Oct 27, 2020

Conversation

mapk
Copy link
Contributor

@mapk mapk commented Oct 27, 2020

Fixes #16732.
Updates the UI on Quote and Pullquote blocks for dark themes. This includes the borders and citations.

How has this been tested?

Tested locally.

Screenshots

Quote block before
quote-before

Quote block after
quote-after

Pullquote block before
pull-before

Pullquote block after
pull-after

Types of changes

CSS changes.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@mapk mapk added Needs Testing Needs further testing to be confirmed. [Block] Quote Affects the Quote Block [Block] Pullquote Affects the Pullquote Block labels Oct 27, 2020
@mapk mapk self-assigned this Oct 27, 2020
@mapk mapk requested a review from aristath October 27, 2020 16:24
Copy link
Member

@aristath aristath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! 👍 Thank you Mark

@github-actions
Copy link

Size Change: +92 B (0%)

Total Size: 1.2 MB

Filename Size Change
build/block-library/theme-rtl.css 837 B +46 B (5%) 🔍
build/block-library/theme.css 838 B +46 B (5%) 🔍
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.14 kB 0 B
build/annotations/index.js 3.78 kB 0 B
build/api-fetch/index.js 3.45 kB 0 B
build/autop/index.js 2.84 kB 0 B
build/blob/index.js 665 B 0 B
build/block-directory/index.js 8.72 kB 0 B
build/block-directory/style-rtl.css 943 B 0 B
build/block-directory/style.css 942 B 0 B
build/block-editor/index.js 130 kB 0 B
build/block-editor/style-rtl.css 11.1 kB 0 B
build/block-editor/style.css 11 kB 0 B
build/block-library/editor-rtl.css 8.94 kB 0 B
build/block-library/editor.css 8.94 kB 0 B
build/block-library/index.js 145 kB 0 B
build/block-library/style-rtl.css 7.75 kB 0 B
build/block-library/style.css 7.75 kB 0 B
build/block-serialization-default-parser/index.js 1.88 kB 0 B
build/block-serialization-spec-parser/index.js 3.1 kB 0 B
build/blocks/index.js 48.1 kB 0 B
build/components/index.js 172 kB 0 B
build/components/style-rtl.css 15.3 kB 0 B
build/components/style.css 15.3 kB 0 B
build/compose/index.js 9.81 kB 0 B
build/core-data/index.js 12.3 kB 0 B
build/data-controls/index.js 675 B 0 B
build/data/index.js 8.77 kB 0 B
build/date/index.js 31.8 kB 0 B
build/deprecated/index.js 768 B 0 B
build/dom-ready/index.js 571 B 0 B
build/dom/index.js 4.46 kB 0 B
build/edit-navigation/index.js 11.2 kB 0 B
build/edit-navigation/style-rtl.css 881 B 0 B
build/edit-navigation/style.css 885 B 0 B
build/edit-post/index.js 306 kB 0 B
build/edit-post/style-rtl.css 6.37 kB 0 B
build/edit-post/style.css 6.35 kB 0 B
build/edit-site/index.js 21.9 kB 0 B
build/edit-site/style-rtl.css 3.79 kB 0 B
build/edit-site/style.css 3.79 kB 0 B
build/edit-widgets/index.js 26.4 kB 0 B
build/edit-widgets/style-rtl.css 3.09 kB 0 B
build/edit-widgets/style.css 3.09 kB 0 B
build/editor/editor-styles-rtl.css 480 B 0 B
build/editor/editor-styles.css 482 B 0 B
build/editor/index.js 43.1 kB 0 B
build/editor/style-rtl.css 3.85 kB 0 B
build/editor/style.css 3.84 kB 0 B
build/element/index.js 4.65 kB 0 B
build/escape-html/index.js 735 B 0 B
build/format-library/index.js 7.7 kB 0 B
build/format-library/style-rtl.css 547 B 0 B
build/format-library/style.css 548 B 0 B
build/hooks/index.js 2.13 kB 0 B
build/html-entities/index.js 623 B 0 B
build/i18n/index.js 3.57 kB 0 B
build/is-shallow-equal/index.js 712 B 0 B
build/keyboard-shortcuts/index.js 2.52 kB 0 B
build/keycodes/index.js 1.94 kB 0 B
build/list-reusable-blocks/index.js 3.11 kB 0 B
build/list-reusable-blocks/style-rtl.css 476 B 0 B
build/list-reusable-blocks/style.css 476 B 0 B
build/media-utils/index.js 5.34 kB 0 B
build/notices/index.js 1.79 kB 0 B
build/nux/index.js 3.42 kB 0 B
build/nux/style-rtl.css 671 B 0 B
build/nux/style.css 668 B 0 B
build/plugins/index.js 2.56 kB 0 B
build/primitives/index.js 1.43 kB 0 B
build/priority-queue/index.js 791 B 0 B
build/redux-routine/index.js 2.84 kB 0 B
build/reusable-blocks/index.js 3.06 kB 0 B
build/rich-text/index.js 13.2 kB 0 B
build/server-side-render/index.js 2.77 kB 0 B
build/shortcode/index.js 1.69 kB 0 B
build/token-list/index.js 1.27 kB 0 B
build/url/index.js 4.06 kB 0 B
build/viewport/index.js 1.84 kB 0 B
build/warning/index.js 1.14 kB 0 B
build/wordcount/index.js 1.22 kB 0 B

compressed-size-action

@mapk
Copy link
Contributor Author

mapk commented Oct 27, 2020

The failed tests don't look like they are because of any CSS changes, so I'm going to merge this one.

@mapk mapk merged commit c56d489 into master Oct 27, 2020
@mapk mapk deleted the update/dark-theme-ui-for-quote-blocks branch October 27, 2020 19:42
@github-actions github-actions bot added this to the Gutenberg 9.3 milestone Oct 27, 2020
@@ -4,12 +4,22 @@
margin-bottom: 1.75em;
color: #555;

.is-dark-theme & {
border-top: 4px solid $light-gray-placeholder;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this an internal UI variable? Shouldn't we be avoiding the use of those on front-end block styles?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. This is where the styles were defined for the editor, so adding this to account for the styles against a dark background worked here. I believe that themes need to opt-in for this though, right? Reading from: #16732

If a theme opts in, these are provided in the front-end as well, via the theme.css stylesheet.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, themes need to opt-in to use this. I'm just not sure if this is the right approach. I mean, we're not using an SCSS variable for the non-dark-theme color, so why are we using one here? Or perhaps we should be using variables for both? It just seems inconsistent right now.

@youknowriad
Copy link
Contributor

Something feels off to me in this PR as well. I thought the dark theme support was about adapting the UI to the theme and this PR adapts the actual block styles. Isn't this better done in the theme CSS itself?

cc @jasmussen

@jasmussen
Copy link
Contributor

Yep this is off. is-dark-theme is for editor UI only. The idea being that when a theme registers itself as being "dark", then we can provide UI that contrasts it. Note here how the selected style for blocks has a white border instead of blue, and how the placeholder text is white instead of black:

dark theme

It is not meant for the frontend at all, and the is-dark-theme class should never be output there. The way I see it, there are two ways to fix #16732:

  1. Use currentColor, which I did in Pullquote opinionated styles: Try currentcolor #25358, and we decided that was too disruptive a change to a block in wide usage. We can revisit this decision.
  2. Embrace global styles as a provider of some of those baseline styles, so a theme can override it.

Another option is to do nothing — the visuals that style the Pullquote block to have light gray borders are stored in the theme.scss file, which means they are only output on the frontend if the them opts in using add_theme_support( 'wp-block-styles' );. And even then, if the theme knows it wants to use a dark background, it can provide additional CSS to override those styles.

@jasmussen
Copy link
Contributor

To clarify, the theme author adds the following action to opt in to showing the UI that works on dark backgrounds:

add_theme_support( 'dark-editor-style' );

In my testing, doing this only outputs the is-dark-theme class in the editor, not on the frontend, which is why this doesn't seem to work:

quote

@mapk
Copy link
Contributor Author

mapk commented Nov 3, 2020

First, thanks for digging in!
I'm a bit confused here between these two comments, @jasmussen. Can you help me understand further?

It is not meant for the frontend at all, and the is-dark-theme class should never be output there.

In my testing, doing this only outputs the is-dark-theme class in the editor, not on the frontend, which is why this doesn't seem to work:

My goal is to solve the issue with the citation placeholder text, and the borders which are both too difficult to see in the editor when using a dark theme. You can see in my screenshots in the description above. Doing nothing doesn't appear to be a good course of action here. I'd like to make sure these elements are visible while using a dark theme in the editor. I'm less concerned about the frontend because themes most likely style those elements for the frontend already. It's the editor that often suffers.

I'm totally okay with leaving the difficult borders as being a styling element that requires the theme to address. But the citation placeholder text which is not readable should be fixed as that is part of the UI in the Editor which falls on us to fix.

Shall we revert this change and target the citation placeholder text in another PR? If the theme.scss isn't the right place, should I move these into the editor.scss file instead?

@jasmussen
Copy link
Contributor

jasmussen commented Nov 4, 2020

Ah, that's helpful clarification.

  • The placeholder text color is appropriate to style for is-dark-theme, because it's meant for UI like that.
  • Borders or text color, anything that goes in either style.scss or theme.scss are not appropriate to style using is-dark-theme, because that's not block UI, that's part of the theme or block design itself.

The problem with this PR as it is, is that the frontend no longer matches the editor. The editor suggests your pullquote is going to have light borders and light text when you publish, but it doesn't. Same with the quote:

placeholders

I created two alternate PRs that change things up so that the placeholder text is both legible, and the frontend and editor are visually in sync.

The confusion in this PR is probably compounded by the fact that it's a bit hard to understand what the features at play here do. It would be nice to revisit documentation around these to better explain what they do:

  1. add_theme_support( 'dark-editor-style' ); is an opt-in that lets the theme tell the editor that it has a dark background, so the editor can provide UI that has sufficient contrast. That's all it does.
  2. add_theme_support( 'wp-block-styles' ); is an opt-in that lets the theme load the extra/opinionated CSS styles that are registered in theme.scss. Styles from theme.scss are always loaded in the editor, regardless of theme opt in.

I'd personally prefer we move forward with #26684, as although it can be disruptive to themes that opt into opinionated editor styles, I suspect that's fewer and fewer.

@aristath
Copy link
Member

aristath commented Nov 4, 2020

I'd personally prefer we move forward with #26684, as although it can be disruptive to themes that opt into opinionated editor styles, I suspect that's fewer and fewer.

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Pullquote Affects the Pullquote Block [Block] Quote Affects the Quote Block Needs Testing Needs further testing to be confirmed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider revising default quote and pullquote colors in dark mode.
5 participants