-
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
Components: move border style utils to block-editor
package
#61135
Comments
Since some of this logic is also used in the component itself, the problem with moving it to I think the order of preference should be:
I noticed that For the other two, have we considered passing them as metadata to the |
@mirka you're right, I hadn't realized that. Seems like I'll need to think deeper about this. Thanks for your input. |
@DaniGuardiola and I discussed this today. Ideally, as Dani originally suggested, we'd move these experimental helpers to another package. We can't move them to We concluded that the ideal scenario would be to move those and the semantically related functions (listed above by Dani) to a dedicated As a first step to reach the goal of cleaning up the wp-components re-exports, we thought that a good compromise was to copy the helper functions that are used outside closer to the consumers in the Gutenberg app. It seems that a module in the Looking forward to reading your thoughts! |
I think the general approach in #62155 is good enough to mitigate the immediate problem 👍 I wouldn't go as far as to introduce a dedicated // When split
{ top: { color: "red" }, left: { color: "red" }, ... }
// When not split
{ all: { color: "red" } } // now `hasSplitBorders()` can be replaced with a simple inline `border.all` check I really do hope this border data is an outlier, and we won't see more like it. |
Agreed with @mirka. We actively discourage utility packages and creating new packages should generally avoided, unless there's a niche need a package would occupy. Utility function packages are almost never a good scenario for that. |
There are some border-related utilities marked as experimental being exported from the components package:
gutenberg/packages/components/src/index.ts
Lines 33 to 35 in d89e5a8
Specifically:
hasSplitBorders
isDefinedBorder
isEmptyBorder
This raised some alarms when making experimental components officially public, since they seem out of place, see comment: #60837 (comment)
These utilities are used in various different packages and places across the Gutenberg repo. Upon investigation, I believe a better home for them is probably the
block-editor
editor package. See the README: https://github.com/WordPress/gutenberg/blob/dcbccfb1ca51c560481c018a9c6f45b0ffd6aee9/packages/block-editor/README.mdThis package contains a lot of style-related utilities for blocks, including the following:
cc @mirka
The text was updated successfully, but these errors were encountered: