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

Improve the way we handle custom units and how we interact with themes config. #33470

Open
youknowriad opened this issue Jul 15, 2021 · 0 comments
Open

Comments

@youknowriad
Copy link
Contributor

@youknowriad youknowriad commented Jul 15, 2021

There are a couple of issues with the way we handle units right now. Themes provide the available themes by adding spacing.units to their theme.json or by defining add_theme_support( 'custom-units' )

I noticed a number of issues though:

  • If the theme doesn't define anything, we end up with false value for the config but since we have fallbacks each time we do useSetting( 'spacing.units' ) in core blocks, it means we'll still allow custom units. I guess that means custom units are opt-out these days, that's fine but we should clarify how themes can opt-out of custom units and if that's even something we allow.
  • The other point is that if a theme removes % from the available units, it is still possible to use a pattern or a variation with that unit (for instance columns variations), Right now, the block works well but the UI in the inspector shows another unit as selected, maybe we should show the unit but disabled?
  • The third item I noted is that right now it's too complex for blocks to use the units config, a fallback is necessary and a call to an experimental useCustomUnits hook is needed, I think ideally we should simplify that and just pass useSetting( 'spacing.units' ) as a prop to the UI component. Some refactoring/simplification might be needed there.

cc @nosolosw @aristath

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant