-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Abstract Justification Toolbar to it's own block-editor component #28439
Conversation
Size Change: +243 B (0%) Total Size: 1.37 MB
ℹ️ View Unchanged
|
Cool work, looks and works as advertised: Code looks good and this is a nice enhancement. I CC'ed Nik for a quick sanity check as I know he's been looking at adjacent things. One question, though, about this code:
I know this is existing code that has shipped for months and months, so it's probably not feasible to course correct. But what this code tells me is that you can't use justification controls unless the child elements are inside an unordered list. Is there any way to change this to be less opinionated about what elements are being used? Could be fine as a followup if possible. |
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.
Thanks for working on this @mkaz !
Maybe by including an integration in another component as well, besides Navigation
, will be better, as it will help identify more things or problems we have to solve.
@ntsekouras @jasmussen So looking at the CSS we could probably tackle it a couple of different ways, but tricky for implementation due to existing blocks, classnames, and markup. So, what I'm thinking is don't include any CSS in the controls at let the component using them implement as needed. This is how it works on navigation, the justify controls takes an Looking at how I would implement the same controls with CSS for buttons is tricky sine the buttons component uses a different set of classnames, so changing either way will have some deprecation issues. The downside is the controls aren't simple to drop-in and you automatically get all the classnames needed. Thoughts? |
This seems right to me. There will likely be enough use cases for justification controls, that the markup can't always be the same anyway. But I will defer to Nik! |
Maybe it's better this way yes. We can revisit if needed, when applying this control to other blocks. |
We could write a "best practices" and suggest some good defaults, so the inconsistent markup behavior doesn't grow out of hands, in case we want to revisit? |
Thanks, I've updated the component and I think it is ready. Joen, good suggestion on the documentation, I updated the readme to I hope clarify. I'm keeping the CSS with the component, this will help standardize people using the same classnames when used. It will be left to the consumer of the controls to place the classname where needed, and we can revisit after seeing how it used and adjust. |
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.
Thanks for working on this! I've left a couple of minor comments but this works well.
Buttons
at least will need a deprecation
when we'll integrate, but seems to provide a base component to use for other new components.
- Updates style moving to component - Fix exporting for component - Initial stubbed documentation
- Simplifies CSS for toolbar to be generic, not just ul tag. - Adds CSS back to navigation block since it is needed for > ul - Updated documentation for using controls
f8439b1
to
247a6f8
Compare
'space-between': justifySpaceBetween, | ||
}; | ||
|
||
export function JustifyToolbar( { |
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.
Is the name good enough for a public API? Is it consistent with other *Toolbar
components? Maybe it is, just making sure it's considered carefully.
Description
Move the toolbar created for the Navigation block to add justification controls, mainly space-between, to it's own component within the block-editor components. We want to add these controls additional to the Social Links block, but first need this PR to abstract it out and then can use in both spots without duplicating work.
How has this been tested?
Types of changes
No functional changes, just code organization and clean up making the component reusable.