Skip to content

Improve treatment of custom values in Gutenberg form fields #35558

Open

Description

theme.json and block markup can accept a wide range of values that can't (and probably shouldn't appear in the Gutenberg UI. For example:

  • CSS variables
  • calc()
  • clamp()
  • min()
  • max()
  • minmax()
  • etc.

All of these are valid block markup. When they are used, Gutenberg currently just shows an empty form field in the UI. For example, here's some sample markup that uses a max() value for padding:

<!-- wp:group {"style":{"spacing":{"padding":{"top":"max(1.25rem, 5vw)","right":"max(1.25rem, 5vw)","bottom":"max(1.25rem, 5vw)","left":"max(1.25rem, 5vw)"}}},"backgroundColor":"foreground","textColor":"background"} -->
<div class="wp-block-group has-background-color has-foreground-background-color has-text-color has-background" style="padding-top:max(1.25rem, 5vw);padding-right:max(1.25rem, 5vw);padding-bottom:max(1.25rem, 5vw);padding-left:max(1.25rem, 5vw)"><!-- wp:paragraph -->
<p>Hello</p>
<!-- /wp:paragraph --></div>
<!-- /wp:group -->

Result:

Screen Shot 2021-10-12 at 11 49 12 AM


We don't want to display these exact CSS calculations, since that'll be too complicated for the user. But we also shouldn't show a blank form field, since the user doesn't know that there's actually a value there. Is there something else we can display in cases like this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions