Style Engine: refactor global/theme.json styles to use the style engine #46563
Labels
Global Styles
Anything related to the broader Global Styles efforts, including Styles Engine and theme.json
[Package] Style Engine
/packages/style-engine
The proposal
The Style Engine generates CSS for block styles in WordPress, and hence knows how to parse block style objects.
Given that theme.json shares the block style object data model, it now should be possible to use the Style Engine to parse global style objects as well.
There will be some exceptions, and it's going to be a big job.
This goal of this issue is to break down and track the tasks/investigations.
Tasks
WP_Theme_JSON::compute_style_properties
WP_Theme_JSON::to_ruleset
methods with the Style Engine inWP_Theme_JSON::get_styles_for_block()
. The Style Engine can accept a single theme.json style node and a selector.blockGap
—wp—style—root—
properties andPROTECTED_PROPERTIES
if we're skippingcompute_style_properties
calls inget_styles_for_block
.__experimentalSelector
. These are the block support selectors that can be defined in block.json. Can be done by refactoring the relevant logic inWP_Theme_JSON::get_styles_for_block()
, and building nodes instead of declaration arrays.safecss_filter_attr
— for example, there are rules that might be applicable to global styles (e.g. settingdisplay: flex
on flex layouts) that are suitable for global styles rules, but that should not be exposed generally for users without theunfiltered_html
capability.kses
? E.g. if we were to allow transitions, transforms, or other fancy styling features in global styles, that we might not want to expose for all WordPress users.compute_style_properties
, update settings and styles validation to ensure that rules output via global styles are allowed for users without theunfiltered_html
capability.gutenberg_enqueue_global_styles
, taking into account the logic ingutenberg_add_global_styles_for_blocks
that enqueues block styles separately viawp_should_load_separate_core_block_assets()
More to come...
Previous, and maybe relevant, investigations
The text was updated successfully, but these errors were encountered: