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

Extract CSS resets to reusable mixins #14509

Merged
merged 3 commits into from
Mar 21, 2019
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
216 changes: 216 additions & 0 deletions assets/stylesheets/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -343,3 +343,219 @@
animation-duration: 1ms !important;
}
}

/**
* Reset default styles for JavaScript UI based pages.
* This is a WP-admin agnostic reset
*/
@mixin reset {
box-sizing: border-box;

*,
*::before,
*::after {
box-sizing: inherit;
}

select {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ideally for reusable components using inputs/selects... we shouldn't rely on the existence of these resets because this "reset" mixins are not included in the styles of these reusable components which means if you use a given component outside of the Gutenberg context, it may not be shown properly.

This is a separate task though that should be done step by step.

font-size: $default-font-size;
color: $dark-gray-500;
}

.input-control, // Upstream name is `.regular-text`.
input[type="text"],
input[type="search"],
input[type="radio"],
input[type="tel"],
input[type="time"],
input[type="url"],
input[type="week"],
input[type="password"],
input[type="checkbox"],
input[type="color"],
input[type="date"],
input[type="datetime"],
input[type="datetime-local"],
input[type="email"],
input[type="month"],
input[type="number"],
select,
textarea {
Copy link
Member

Choose a reason for hiding this comment

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

I think this may have caused a regression on the appearance of the "Code Editor" textarea, where the reset of .block-editor textarea in assigning font-family takes specificity priority over the code styling applied by the .editor-post-text-editor selector.

.block-editor,
// The modals are shown outside the .block-editor wrapper, they need these styles
.components-modal__frame {
@include reset;
}

(011 vs. 010)

Before After
Before After

Aside: Should .block-editor styles be applied at edit-post/src/style.scss?

font-family: $default-font;
padding: 6px 8px;
@include input-style__neutral();

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

&:focus {
@include input-style__focus();
}
}

input[type="number"] {
padding-left: 4px;
padding-right: 4px;
}

select {
padding: 2px;

&:focus {
border-color: $blue-medium-600;
// Windows High Contrast mode will show this outline
outline: 2px solid transparent;
outline-offset: 0;
}
}

input[type="checkbox"],
input[type="radio"] {
border: $border-width + 1 solid $dark-gray-300;
margin-right: 12px;
transition: none;

&:focus {
border-color: $dark-gray-300;
box-shadow: 0 0 0 1px $dark-gray-300;
}

&:checked {
background: theme(toggle);
border-color: theme(toggle);
}

&:checked:focus {
box-shadow: 0 0 0 2px $dark-gray-500;
}
}

input[type="checkbox"] {
border-radius: $radius-round-rectangle / 2;

&:checked::before,
&[aria-checked="mixed"]::before {
margin: -3px -5px;
color: $white;

@include break-medium() {
margin: -4px 0 0 -5px;
}
}

&[aria-checked="mixed"] {
background: theme(toggle);
border-color: theme(toggle);

&::before {
// Inherited from `forms.css`.
// See: https://github.com/WordPress/wordpress-develop/tree/5.1.1/src/wp-admin/css/forms.css#L122-L132
content: "\f460";
float: left;
display: inline-block;
vertical-align: middle;
width: 16px;
/* stylelint-disable */
font: normal 30px/1 dashicons;
/* stylelint-enable */
speak: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;

@include break-medium() {
float: none;
font-size: 21px;
}
}

&:focus {
box-shadow: 0 0 0 2px $dark-gray-500;
}
}
}

input[type="radio"] {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we're missing some small-screen rules here: I just noticed our radio controls look a little weird on mobile. 😄 But that existed before this PR, and can be handled separately.

Screen Shot 2019-03-20 at 5 14 26 PM

border-radius: $radius-round;

&:checked::before {
margin: 3px 0 0 3px;
background-color: $white;
}
}

// Placeholder colors
input,
textarea {
// Use opacity to work in various editor styles.
&::-webkit-input-placeholder {
color: $dark-opacity-300;
}

&::-moz-placeholder {
opacity: 1; // Necessary because Firefox reduces this from 1.
color: $dark-opacity-300;
}

&:-ms-input-placeholder {
color: $dark-opacity-300;
}

.is-dark-theme & {
&::-webkit-input-placeholder {
color: $light-opacity-300;
}

&::-moz-placeholder {
opacity: 1; // Necessary because Firefox reduces this from 1.
color: $light-opacity-300;
}

&:-ms-input-placeholder {
color: $light-opacity-300;
}
}
}
}

/**
* Reset the WP Admin page styles for Gutenberg-like pages.
*/
@mixin wp-admin-reset( $content-container ) {
background: $white;

#wpcontent {
padding-left: 0;
}

#wpbody-content {
padding-bottom: 0;
}

/* We hide legacy notices in Gutenberg Based Pages, because they were not designed in a way that scaled well.
Plugins can use Gutenberg notices if they need to pass on information to the user when they are editing. */
#wpbody-content > div:not(#{ $content-container }):not(#screen-meta) {
display: none;
}

#wpfooter {
display: none;
}

.a11y-speak-region {
left: -1px;
top: -1px;
}

ul#adminmenu a.wp-has-current-submenu::after,
ul#adminmenu > li.current > a.current::after {
border-right-color: $white;
}

.media-frame select.attachment-filters:last-of-type {
width: auto;
max-width: 100%;
}
}
Loading