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

Add dark editor style support #9683

Merged
merged 4 commits into from
Sep 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/extensibility/theme-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,15 @@ function mytheme_block_editor_styles() {
add_action( 'enqueue_block_editor_assets', 'mytheme_block_editor_styles' );
```

If your editor style relies on a dark background, you can add the following to adjust the color of the UI to work on dark backgrounds:

```php
add_theme_support( 'editor-styles' );
add_theme_support( 'dark-editor-style' );
```

Note you don't need to add `add_theme_support( 'editor-styles' );` twice, but that rule does need to be present for the `dark-editor-style` rule to work.

### Basic colors

You can style the editor like any other webpage. Here's how to change the background color and the font color to blue:
Expand Down
8 changes: 6 additions & 2 deletions gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,10 @@ function toggleDropdown() {
* @return string The $classes string, with gutenberg-editor-page appended.
*/
function gutenberg_add_admin_body_class( $classes ) {
// Default to is-fullscreen-mode to avoid jumps in the UI.
return "$classes gutenberg-editor-page is-fullscreen-mode";
if ( current_theme_supports( 'editor-styles' ) && current_theme_supports( 'dark-editor-style' ) ) {
return "$classes gutenberg-editor-page is-fullscreen-mode is-dark-theme";
} else {
// Default to is-fullscreen-mode to avoid jumps in the UI.
return "$classes gutenberg-editor-page is-fullscreen-mode";
}
}