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

Fix the placeholder attribute and caption placeholder color #69333

Draft
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Draft
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
4 changes: 4 additions & 0 deletions packages/base-styles/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@
@include input-style__focus();
}

@include input-placeholder-color;
}

@mixin input-placeholder-color {
// Use opacity to work in various editor styles.
&::-webkit-input-placeholder {
color: $dark-gray-placeholder;
Expand Down
18 changes: 9 additions & 9 deletions packages/block-editor/src/components/rich-text/content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@

[data-rich-text-placeholder]::after {
content: attr(data-rich-text-placeholder);
// Use opacity to work in various editor styles.
// We don't specify the color here, because blocks or editor styles might provide their own.
opacity: 0.62;
// The RichText placeholder is the equivalent of the HTML placeholder
// attribute. As such, its color should have a sufficient contrast ratio
// with the background. However, themes, blocks or editor styles might
// provide their own color for the text of the block where RichText is
// used. For this reason, the RichText placeholder color should resemble
// the text color. We assume the block text color is responsible for
// providing sufficient contrast and slightly dim the placeholder color.
color: currentColor;
opacity: 85%;
}

&:focus {
Expand All @@ -16,12 +22,6 @@
}
}

// Captions may have lighter (gray) text, or be shown on a range of different background luminosites.
// To ensure legibility, we increase the default placeholder opacity to ensure contrast.
figcaption.block-editor-rich-text__editable [data-rich-text-placeholder]::before {
opacity: 0.8;
}

[data-rich-text-script] {
display: inline;

Expand Down
9 changes: 9 additions & 0 deletions packages/block-library/src/cover/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@
background-color: $black;
}

// Make sure the placeholder text is white when has-background-dim default background is black.
// the first selector is required for old Cover markup
&.has-background-dim:not([class*="-background-color"]):not(.is-light),
&:not(.is-light) .has-background-dim:not([class*="-background-color"]) {
& ~ .wp-block-cover__inner-container [data-rich-text-placeholder]::after {
color: $white;
}
}

.has-background-dim.has-background-gradient {
background-color: transparent;
}
Expand Down
12 changes: 1 addition & 11 deletions packages/editor/src/components/post-text-editor/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,5 @@ textarea.editor-post-text-editor {
position: relative;
}

&::-webkit-input-placeholder {
color: $dark-gray-placeholder;
}

&::-moz-placeholder {
color: $dark-gray-placeholder;
}

&:-ms-input-placeholder {
color: $dark-gray-placeholder;
}
@include input-placeholder-color;
}
Loading