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: add CSS var parsing capability to fontSize and fontFamily #5710

Conversation

ramonjd
Copy link
Member

@ramonjd ramonjd commented Nov 28, 2023

What

Syncs changes from WordPress/gutenberg#56528 by adding CSS var parsing capability to fontSize and fontFamily.

Testing

Ensure that there are no regressions in block supports styles. Here is some test code:

Example block code
<!-- wp:group {"style":{"border":{"radius":"20px","top":{"width":"14px"},"right":{"color":"#ec0303","width":"46px"},"bottom":{"color":"#d8613c","width":"14px"},"left":{"color":"#636363","width":"46px"}}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group" style="border-radius:20px;border-top-width:14px;border-right-color:#ec0303;border-right-width:46px;border-bottom-color:#d8613c;border-bottom-width:14px;border-left-color:#636363;border-left-width:46px"><!-- wp:heading {"style":{"elements":{"link":{"color":{"text":"var:preset|color|accent-5"}}},"typography":{"fontStyle":"normal","fontWeight":"500","textTransform":"uppercase"},"spacing":{"padding":{"bottom":"var:preset|spacing|40"}}},"textColor":"accent-5","fontSize":"large"} -->
<h2 class="wp-block-heading has-accent-5-color has-text-color has-link-color has-large-font-size" style="padding-bottom:var(--wp--preset--spacing--40);font-style:normal;font-weight:500;text-transform:uppercase">Heading</h2>
<!-- /wp:heading -->

<!-- wp:paragraph {"fontSize":"small"} -->
<p class="has-small-font-size">Paragraph</p>
<!-- /wp:paragraph -->

<!-- wp:list {"style":{"color":{"background":"#e6e3e3"},"spacing":{"margin":{"right":"var:preset|spacing|30","left":"var:preset|spacing|30"}}}} -->
<ul style="background-color:#e6e3e3;margin-right:var(--wp--preset--spacing--30);margin-left:var(--wp--preset--spacing--30)" class="has-background"><!-- wp:list-item -->
<li>List</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>List</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>List</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list --></div>
<!-- /wp:group -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->
Frontend output
<div class="wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained" style="border-radius:20px;border-top-width:14px;border-right-color:#ec0303;border-right-width:46px;border-bottom-color:#d8613c;border-bottom-width:14px;border-left-color:#636363;border-left-width:46px">
<h2 class="wp-block-heading has-accent-5-color has-text-color has-link-color has-large-font-size wp-elements-0ea8f7f38d9a71fcf3ae556b6ed1adb1" style="padding-bottom:var(--wp--preset--spacing--40);font-style:normal;font-weight:500;text-transform:uppercase">Heading</h2>



<p class="has-small-font-size">Paragraph</p>



<ul style="background-color:#e6e3e3;margin-right:var(--wp--preset--spacing--30);margin-left:var(--wp--preset--spacing--30)" class="has-background">
<li>List</li>



<li>List</li>



<li>List</li>
</ul>
</div>

Run the tests!
npm run test:php -- --filter Tests_wpStyleEngine

Trac ticket: https://core.trac.wordpress.org/ticket/59982


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Adds CSS var parsing capability to fontSize and fontFamily
Copy link
Contributor

@tellthemachines tellthemachines left a comment

Choose a reason for hiding this comment

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

LGTM and working as expected! Tested with provided markup and also changing font sizes on miscellaneous blocks. Front end looks the same on trunk and this branch.

@tellthemachines
Copy link
Contributor

Committed in r57253.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants