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

Style engine: output global styles CSS rules using selectors #40955

Closed
wants to merge 7 commits into from

Conversation

ramonjd
Copy link
Member

@ramonjd ramonjd commented May 10, 2022

What?

Testing what, how and where we can output CSS rules using selectors for global styles in the backend.

This PR sends style nodes and a selector to the style engine to return

.selector {
   key: value;
}

It works!

It's possible that we can replace static::to_ruleset()

❗❗❗❗ Note: because there are loads of idiosyncrasies in global styles, we should find a way to implement this iteratively, so we support certain styles/features as they're built.

Alternative

Passing the entire global styles object: #42143

Why?

How?

Testing Instructions

Screenshots or screencast

@ramonjd ramonjd self-assigned this May 10, 2022
@ramonjd ramonjd added [Type] Experimental Experimental feature or API. [Package] Style Engine /packages/style-engine [Status] In Progress Tracking issues with work in progress labels May 10, 2022
'selector' => $selector,
'prettify' => defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG,
)
);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the style engine can support/accepted computing/computed preset vars and theme vars it might be able to replace static::to_ruleset( $selector, $declarations )

@ramonjd ramonjd force-pushed the try/style-engine-output-rules-with-selectors branch from 567978a to af4a9ff Compare June 6, 2022 03:12
@ramonjd ramonjd force-pushed the try/style-engine-output-rules-with-selectors branch from d90553f to 754d127 Compare June 22, 2022 02:16
@@ -1,11 +1,357 @@
{
"version": 2,
"customTemplates": [
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temporary, in order to test global styles output.

I'll revert.

@ramonjd ramonjd changed the title Style engine: output CSS rules using selectors Style engine: output global styles CSS rules using selectors Jun 22, 2022
@ramonjd ramonjd force-pushed the try/style-engine-output-rules-with-selectors branch from e07649b to 0e16df9 Compare July 1, 2022 02:31
$block_styles,
array(
'selector' => $selector,
'custom_metadata' => array(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking some inspiration from #41965

* Used to bypass safecss_filter_attr().
*/
const VALID_CUSTOM_PROPERTIES = array(
'--wp--style--block-gap' => array( 'spacing', 'blockGap' ),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to do this because safecss_filter_attr (kses.php) doesn't allow CSS custom properties.

@ramonjd ramonjd force-pushed the try/style-engine-output-rules-with-selectors branch 2 times, most recently from ac98cd3 to 73f3de3 Compare July 4, 2022 23:17
ramonjd added 7 commits July 5, 2022 09:46
Migrate get_block_classes to 6.1

Add prettify option

Testing rule generation for get_styles_for_block

Let the style engine take care of margin: 0 on the body
…ock-gap and gap.

Not a great way to tell the style engine to convert a key to a css custom property.. but...
@ramonjd
Copy link
Member Author

ramonjd commented Jul 11, 2022

closing in favour of #42143

@ramonjd ramonjd closed this Jul 11, 2022
@ramonjd ramonjd deleted the try/style-engine-output-rules-with-selectors branch July 11, 2022 06:05
@priethor priethor removed the [Status] In Progress Tracking issues with work in progress label Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Style Engine /packages/style-engine [Type] Experimental Experimental feature or API.
Projects
Status: 🗄 Closed / not merged
Development

Successfully merging this pull request may close these issues.

2 participants