Skip to content

Preset controls need the preset CSS variables in scope #26511

@oandregal

Description

@oandregal

Reported at https://github.com/Automattic/themes/pull/2659/files#r512186187

Theme authors can use CSS Custom Properties to define the presets, for example, to make the gradients depend on the solid colors:

{
  "color": {
    "gradients": [
      {
        "slug": "some-gradient",
        "gradient": "linear-gradient(to bottom, transparent 20%, var(--wp--preset--color--secondary) 20%, var(--wp--preset--color--secondary) 80%, transparent 80%)"
      }
    ],
    "palette": [
      {
        "slug": "primary",
        "color": "#000000"
      },
      {
        "slug": "secondary",
        "color": "#3C8067"
      }
    ]
  }
}

These definitions end up attached to the user-facing UI tools. The problem is that these tools aren't part of the editor canvas (wrapper by the .editor-styles-wrapper class), so the CSS Custom Properties aren't defined, hence it doesn't work. See what would happen in this case:

97214074-eaff4d80-1798-11eb-9969-18182f7a9939

This is because, both in the post-editor and the site-editor, the global styles are prefixed by the editor wrapper, hence its scope doesn't reach the UI controls.

Metadata

Metadata

Labels

Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions