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

Base Styles: Add the editor input reset with increased specificity #49831

Merged
merged 2 commits into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
25 changes: 25 additions & 0 deletions packages/base-styles/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,31 @@
}
}

// The editor input reset with increased specificity to avoid theme styles bleeding in.
@mixin editor-input-reset() {
font-family: $editor-html-font !important;
color: $gray-900 !important;
background: $white !important;
padding: $grid-unit-15 !important;
border: $border-width solid $gray-900 !important;
box-shadow: none !important;
border-radius: $radius-block-ui !important;

/* Fonts smaller than 16px causes mobile safari to zoom. */
Copy link
Contributor

Choose a reason for hiding this comment

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

If I recall correctly, /* */ in the SCSS compiler is kept in place, whereas // is stripped out. I think we may have used this in the past for anyone reviewing the CSS files, not just the SCSS files. But in part, I think "View source" is increasingly not something people do, and in part I also think there's some minification that happens with mixins making all context lost here. So it might be good to change this to the // syntax.

font-size: $mobile-text-min-font-size !important;
@include break-small {
font-size: $default-font-size !important;
}

&:focus {
border-color: var(--wp-admin-theme-color) !important;
box-shadow: 0 0 0 ($border-width-focus - $border-width) var(--wp-admin-theme-color) !important;

// Windows High Contrast mode will show this outline, but not the box-shadow.
outline: 2px solid transparent !important;
}
}

/**
* Reset the WP Admin page styles for Gutenberg-like pages.
*/
Expand Down
23 changes: 2 additions & 21 deletions packages/block-library/src/html/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,8 @@
// The editing view for the HTML block is equivalent to block UI.
// Therefore we increase specificity to avoid theme styles bleeding in.
.block-editor-plain-text {
font-family: $editor-html-font !important;
color: $gray-900 !important;
background: $white !important;
padding: $grid-unit-15 !important;
border: $border-width solid $gray-900 !important;
box-shadow: none !important;
border-radius: $radius-block-ui !important;
box-sizing: border-box;
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a minor bug fix to contain the HTML block inside the content box.

max-height: 250px;

/* Fonts smaller than 16px causes mobile safari to zoom. */
font-size: $mobile-text-min-font-size !important;
@include break-small {
font-size: $default-font-size !important;
}

&:focus {
border-color: var(--wp-admin-theme-color) !important;
box-shadow: 0 0 0 ($border-width-focus - $border-width) var(--wp-admin-theme-color) !important;

// Windows High Contrast mode will show this outline, but not the box-shadow.
outline: 2px solid transparent !important;
}
@include editor-input-reset();
}
}
22 changes: 1 addition & 21 deletions packages/block-library/src/shortcode/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,8 @@
// The editing view for the Shortcode block is equivalent to block UI.
// Therefore we increase specificity to avoid theme styles bleeding in.
.blocks-shortcode__textarea {
font-family: $editor-html-font !important;
color: $gray-900 !important;
background: $white !important;
padding: $grid-unit-15 !important;
border: $border-width solid $gray-900 !important;
box-shadow: none !important;
border-radius: $radius-block-ui !important;
box-sizing: border-box;
max-height: 250px;
resize: none;

/* Fonts smaller than 16px causes mobile safari to zoom. */
font-size: $mobile-text-min-font-size !important;
@include break-small {
font-size: $default-font-size !important;
}

&:focus {
border-color: var(--wp-admin-theme-color) !important;
box-shadow: 0 0 0 ($border-width-focus - $border-width) var(--wp-admin-theme-color) !important;

// Windows High Contrast mode will show this outline, but not the box-shadow.
outline: 2px solid transparent !important;
}
@include editor-input-reset();
}