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

Components: move border style utils to block-editor package #61135

Open
DaniGuardiola opened this issue Apr 26, 2024 · 2 comments
Open

Components: move border style utils to block-editor package #61135

DaniGuardiola opened this issue Apr 26, 2024 · 2 comments
Labels
[Feature] Block Styles Issues or PRs that are related to the `register_block_style` API [Feature] Component System WordPress component system [Package] Block editor /packages/block-editor [Package] Components /packages/components

Comments

@DaniGuardiola
Copy link
Contributor

There are some border-related utilities marked as experimental being exported from the components package:

hasSplitBorders as __experimentalHasSplitBorders,
isDefinedBorder as __experimentalIsDefinedBorder,
isEmptyBorder as __experimentalIsEmptyBorder,

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.md

This package contains a lot of style-related utilities for blocks, including the following:

  • getColorClassName
  • getColorObjectByAttributeValues
  • getColorObjectByColorValue
  • getComputedFluidTypographyValue
  • getCustomValueFromPreset
  • getFontSize
  • getFontSizeClass
  • getFontSizeObjectByValue
  • getGradientSlugByValue
  • getGradientValueBySlug
  • getPxFromCssUnit
  • getSpacingPresetCssVar
  • getTypographyClassesAndStyles

cc @mirka

@DaniGuardiola DaniGuardiola added [Package] Blocks /packages/blocks [Package] Block editor /packages/block-editor and removed [Package] Blocks /packages/blocks labels Apr 26, 2024
@DaniGuardiola DaniGuardiola added [Package] Components /packages/components [Feature] Component System WordPress component system [Feature] Block Styles Issues or PRs that are related to the `register_block_style` API labels Apr 26, 2024
@mirka
Copy link
Member

mirka commented Apr 26, 2024

Since some of this logic is also used in the component itself, the problem with moving it to wp-block-editor is that we'd either need to duplicate the logic, or we'd be importing functions from wp-block-editor into wp-components which is a violation of the dependency direction.

I think the order of preference should be:

  1. Remove (deprecate) if possible
  2. Incorporate into the component API if possible
  3. Move to another package

I noticed that isEmptyBorder is not used in the app anymore, so that seems like a candidate for deprecation.

For the other two, have we considered passing them as metadata to the onChange callback? Perhaps as the second argument.

@DaniGuardiola
Copy link
Contributor Author

@mirka you're right, I hadn't realized that. Seems like I'll need to think deeper about this. Thanks for your input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block Styles Issues or PRs that are related to the `register_block_style` API [Feature] Component System WordPress component system [Package] Block editor /packages/block-editor [Package] Components /packages/components
Projects
None yet
Development

No branches or pull requests

2 participants