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

Improve editor UI on dark backgrounds #28200

Closed
oandregal opened this issue Jan 14, 2021 · 4 comments · Fixed by #28233
Closed

Improve editor UI on dark backgrounds #28200

oandregal opened this issue Jan 14, 2021 · 4 comments · Fixed by #28233
Labels
[Feature] Themes Questions or issues with incorporating or styling blocks in a theme.

Comments

@oandregal
Copy link
Member

Here's the lowdown of how dark mode works in the editor at the moment (hat tip: @jasmussen):

  • WordPress does not support Dark Mode™ yet.
  • Themes might.
  • Whether Dark Mode or not, a theme might simply have a dark background.
  • On a dark background, an empty paragraph needs to have white placeholder text, or it won’t be legible.

The current solution is a boolean opt-in, that inverts the UI. This opt-in, add_theme_support( 'dark-editor-style' );, simply outputs is-dark-theme as a class in the body tag. This same class is also used in Cover to tell the editor UI to be inverted if Cover detects a dark background.

Can we refactor the is-dark-theme class name to be output based on the luminosity chosen by the background color of the root element in Global Styles, dynamically?

@oandregal oandregal added [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Jan 14, 2021
@oandregal oandregal mentioned this issue Jan 14, 2021
82 tasks
@skorasaurus
Copy link
Member

note there's some existing discussion in #9483 ; may want to merge this issue with that?

@oandregal
Copy link
Member Author

Oh, thanks for bringing that up. Just took a look at #9483 and it seems that it's about the parts of the editor UI that aren't affected by themes. This one would target the opposite areas: how do we make sure the editing canvas looks right (ex: placeholder for paragraphs) depending on the background theme color (which may or may not be related to dark/light user preferences).

@youknowriad
Copy link
Contributor

Ideally, it's not just the background color from global styles but sometimes also the background color of the parent elements.

What if a paragraph has a dark background, what if it's inside a group that has a dark color. What if it's an image background?

We could also try a DOM approach: trying to guess the current's background lightness dynamically no matter how it's actually applied.

@jasmussen
Copy link
Contributor

jasmussen commented Jan 15, 2021

Thanks so much for ticketing this.

I always try to be very careful in the use of terminology: "Dark Mode™" is increasingly an operating system switch that makes the user interface generally darker. This dark mode choice can be picked up by websites, themes, WordPress itself, using prefers-color-scheme.

But sometimes a website just has a black or dark background. Or as Riad says, sometimes a background image is dark, or has a dark scrim overlay. None of that is "Dark Mode".

In other words, whether through Dark Mode or not, the block editor user interface (such as focus styles, borders, placeholder text) needs to work both black and white backgrounds. That's the primary goal of this ticket. I took the liberty of renaming this ticket to better represent that, I hope that's okay 💕

@jasmussen jasmussen changed the title Improve editor dark mode Improve editor UI on dark backgrounds Jan 15, 2021
@oandregal oandregal removed the Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json label Jan 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Themes Questions or issues with incorporating or styling blocks in a theme.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants