-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 another pullquote style #9763
Conversation
Nice! I think you should be able to set a text color along with the background color. |
I love it. I also love how since we're deciding to not make the pullquote a variation of the stock quote, we are at least adding a bunch of decorative aspects to it! My GitFu hasn't yet learned how to check out two PRs at the same time, so if we can get #9599 merged, I can help you with this PR if you need it. This is how I'd love to see it work:
|
} | ||
let colorSettings = null; | ||
const isStylizedStyleVariation = includes( className, STYLIZED_CLASS ); | ||
if ( isStylizedStyleVariation ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking we could actually try calling this attribute just "Main Color", and use it in the default version for the thick borders.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds like a neat idea!
@@ -47,51 +64,89 @@ export const settings = { | |||
|
|||
attributes: blockAttributes, | |||
|
|||
styles: [ | |||
{ name: 'default', label: __( 'Regular' ), isDefault: true }, | |||
{ name: STYLIZED_STYLE_NAME, label: __( 'Stylized' ) }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe call this "Solid" instead? cc @jasmussen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or "Color"? Or "Solid Color"? I think it's fine to be slightly verbose here. Agree "Stylized" is not super descriptive. The block itself is stylized :D
5f7ceb9
to
17e4292
Compare
9a78cc0
to
56b0e47
Compare
17e4292
to
fc1eac0
Compare
56b0e47
to
dbeaa02
Compare
dbeaa02
to
ae30a3f
Compare
In the last change I'm a little confused about how to change the background color. The new "main color" only styles the border for me. I think we can actually be a bit simpler in the implementation:
What do you think? |
Hi @jasmussen,
So the "Main Color" has two different behaviors, with the default style it changes the border color, on the solid color style it changes the background color.
I also like this approach, and I'm open to both version. In this approach, we don't have an explicit style, right? The style changes when a background color is applied? |
Hah I see that now — okay, well, I honestly prefer the approach I suggested, but I can stomach the other appraoch too if Matías wants to drop the lead hammer 😉 — but as it is, I wasn't able to figure out how to make a solid background color, so we need a clearer UI in case we go that route. |
Is there any reason why we should not allow having a colored background for both style variations? |
Yes: fewer options, simplicity, ease of use. It's always a balancing act. |
ae30a3f
to
5aef403
Compare
A new feature suggested by @mtias that automatically computes the text color based on the background color if the user has not explicitly chosen a text color before was added. |
This sounds smart, especially if we can reuse the contrast code. But also perhaps a bit overkill. Could we use a CSS |
How would this work? |
@jasmussen I feel like the text alignment is a bit awkward in the above example. Not quite aligned with the main text, but not offset enough either. I like the presentation here, but wonder what you think: |
Like this. Okay that's not perfect. But it was really easy to write.
I think it's fine :D ship it. |
d44ac7c
to
d7a9ea8
Compare
I think the feedback was applied. Thank you for the reviews! And thank you @mtias for improving the UI. cc: @karmatosed for a last check up on the UX. |
d7a9ea8
to
0b2a18b
Compare
0b2a18b
to
463bf78
Compare
Given that @mtias and @jasmussen looked at this PR I'm going to merge so it gets on the next RC and we have more time to test it. |
@jorgefilipecosta I just noticed an issue with the automatic color picking: it does not work very well when you are using the Regular style variation. Can the automatic color picking be turned off for the Regular style? |
const { value, citation } = attributes; | ||
|
||
const { mainColor, customMainColor, textColor, customTextColor, value, citation, className } = attributes; | ||
const isSolidColorStyle = includes( className, SOLID_COLOR_CLASS ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a good way to check for the presence of a class, as it is very susceptible to false positives, such as this-style-solid-colorful-rainbow
. You might consider a regular expression matching spaces or \b
word boundary. Or better yet, the @wordpress/token-list
module (specifically TokenList#contains
) was designed for this purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what its worth, the very need to detect an assigned style appears to be a smell, as considered at #11352 (comment)
The PR adds a new style variation (whose name is yet to be decided) to the Pull Quote block.
This style has an additional feature that allows users to choose a background color.
This PR depends on #9599.
The design is open for feedback maybe we can improve the look of the block.
How has this been tested?
I used the new style and converted between styles and did not notice any problem.
I checked that we are compatible with pull quotes created on the previous WordPress version e.g: by pasting the following code block in the code editor.
Screenshots