-
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
Block library: Add text align support to List block #16792
Conversation
@ellatrix, is there any plan to move List controls out of |
@@ -463,7 +463,7 @@ RichTextContainer.Content = ( { value, tagName: Tag, multiline, ...props } ) => | |||
const content = <RawHTML>{ html }</RawHTML>; | |||
|
|||
if ( Tag ) { | |||
return <Tag { ...omit( props, [ 'format' ] ) }>{ content }</Tag>; | |||
return <Tag className={ className || undefined } { ...omit( props, [ 'format' ] ) }>{ content }</Tag>; |
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.
@ellatrix - this is necessary to avoid the case where <ul class="">...</ul>
is saved in the post content. Does it make sense?
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.
Why does the parent not pass undefined
? What value is it passing?
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.
it passes an empty string:
classnames() === '';
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.
Ok, but then it should be handled by the parent, as the parent uses classnames
, not RichText
? E.g. classnames() || null
.
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.
Yes, this is one approach but then all blocks need to do it which is suboptimal. I prefer we have it covered.
I can add this logic to the List block if you strongly disagree.
3c38745
to
f0b8632
Compare
@gziolo I'll have a look today. Ideally they should move to the list block, yes. |
Btw, does text alignment make sense at all on a list block? Shouldn't the bullets and everything move as well then? |
That's a very good question, I don't like how it looks as well. That's why I asked for design feedback. @mapk, @kjellr or @karmatosed - what do you think? |
Yeah, I think the bullets would need to move as well — for example, when using a RTL language the bullets move over to the right side: For center aligned lists, the bullets should just appear inline: ... But really, I don't think alternate alignments are all that common for the list block. I like including it in here for consistency's sake, but I don't think it'll be regularly used. If it's not a big deal implement these bullets, go for it. Otherwise, I think it's probably fine to leave alignment out for this block. |
Aside from the change on which you have discussed with @ellatrix, the code seems ok, but the result of using text align is questionable especially if using indent as well: |
f0b8632
to
422c987
Compare
422c987 contains all styling changes presented on screenshots presented in the previous comment. I think it looks better than I anticipated. I had to play a bit with the margin applied by default but I managed to skip it when text alignment is applied. |
Do you think nesting + aligning will work well? In the example above the text length of the nested items is shorter, so it looks like it's nested, but that will not always be the case. You may have some duplicate numbers without any indentation. |
I don't think this option will be super popular but it seems like we should offer it for consistency. There is a live preview of the effect so people can decide whether it makes sense in their particular case. I'm sure we can't anticipate all the reasons why people might want to use this capability. Theme authors might also have some good ideas about how this could be styled to make their design more compelling. |
422c987
to
86dd1ef
Compare
This seems like a bad idea. Just because other text-based blocks have alignment, doesn’t mean lists need it. Are there any real world use-cases for centered or right aligned lists? (And RTL doesn’t count, as the block should do that automatically.) |
I'd like to echo the concerns of the others here and say that while this consistency is nice, I can't really imagine a real-world use case that works aesthetically. I suggest NOT including alignment controls on the List block. |
That seems fine to me, too. It looks weird, and I don't think we've heard from anyone really asking for this feature. 👍 |
Thanks for all your feedback. Let's close this PR and update the original issues with what we agreed upon here 👍 |
Description
Partially implements #15096.
This PR adds text alignment support to the List block:
There is a different order on the screen above but it should be tackled seperately as it's baked in the
RichText
implementation.How has this been tested?
Add List block, set one of the existing text alignments and ensure that text alignment changes. In addition, inspect HTML output in the Code editor and ensure it looks like the following:
Screenshots
Types of changes
New feature/Enhancement.
Checklist: