Skip to content

Improve editor UI on dark backgrounds #28200

Closed

Description

@oandregal

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?

Activity

  1. added
    [Feature] Themes
    Global Styles
    on Jan 14, 2021
  2. skorasaurus commented on Jan 14, 2021

    @skorasaurus
    Member

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

  3. oandregal commented on Jan 14, 2021

    @oandregal
    MemberAuthor

    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).

  4. youknowriad commented on Jan 14, 2021

    @youknowriad
    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.

  5. jasmussen commented on Jan 15, 2021

    @jasmussen
    Contributor

    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 💕

  6. changed the title [-]Improve editor dark mode[/-] [+]Improve editor UI on dark backgrounds[/+] on Jan 15, 2021
  7. removed
    Global Styles
    on Jan 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] Themes

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions