[WIP] Style engine: register styles for enqueuing and rendering#41424
Closed
[WIP] Style engine: register styles for enqueuing and rendering#41424
Conversation
a6b7318 to
a55525a
Compare
Member
|
This looks very promising! 👍 |
Architecture need more thought.
ramonjd
commented
Jun 24, 2022
| if ( class_exists( 'WP_Style_Engine' ) ) { | ||
| $style_engine = WP_Style_Engine::get_instance(); | ||
| // Get style rules, then register/enqueue. | ||
| $new_options = array_merge( $options, array( 'enqueue' => true ) ); |
ramonjd
commented
Jun 27, 2022
Member
Author
There was a problem hiding this comment.
Just testing outputting cascade layers for now to test the concept.
We really want registered styles to be the focus beforehand.
TODO:
- Needs to be tested against other styles for specificity
- How to make this opt-in? (We're instantiating
WP_Style_Engineas a singleton, so should it be passed to the constructor somehow)
05b577f to
c72366e
Compare
ramonjd
commented
Jun 27, 2022
| * @param array $options An array of options to determine the output. | ||
| * @return void | ||
| */ | ||
| function wp_style_engine_enqueue_styles( $block_styles, $options = array() ) { |
Member
Author
There was a problem hiding this comment.
Here we're generating and enqueuing block styles, a.k.a values from a styles object { spacing: { ... }, typography: { ... }, ... }
So maybe it should be called wp_style_engine_enqueue_block_styles.
ramonjd
commented
Jun 27, 2022
| /** | ||
| * Creates a string consisting of CSS property declarations suitable for the value of an HTML element's style attribute. | ||
| * | ||
| * @param array $css_definitions An collection of CSS definitions `[ [ 'color' => 'red' ] ]`. |
Member
Author
There was a problem hiding this comment.
References to $css_definitions should rather be $css_declarations since they contain property: value pairs
aristath
reviewed
Jun 28, 2022
25 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WIP
What?
Background context: #40987 (comment)
Why?
One of the aims is to be able to bundle output styles, and also open up the possibility of pre-processing, e.g., deduping
How?
Creating separate methods to handle style registration, taking into account the various "levels" of styles e.g., global and block supports.
Testing Instructions
Using Empty Theme:
Example
Instead of a
<style />tag for each rule, we're collating them into one:The plan is to allow opt-in support for cascade layers as well: