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

Load same stylesheets in the Site Editor as in the frontend #36911

Merged
merged 5 commits into from Mar 17, 2023

Conversation

Aljullu
Copy link
Contributor

@Aljullu Aljullu commented Feb 21, 2023

All Submissions:

Changes proposed in this Pull Request:

Currently, in the Site Editor we are only loading two frontend styles: /assets/css/woocommerce.css and /assets/css/woocommerce-blocktheme.css. However, in some circumstances, there might be more CSS files or they might be replaced by others, for example, when using TT2 or TT3, which replace /assets/css/woocommerce.css with their own stylesheet. We would like to honor that in the editor so frontend and editor look as similar as possible.

This PR uses WC_Frontend_Scripts::get_styles() to get the list of styles which are loaded in the frontend to load them in the Site Editor.

  • This PR is a very minor change/addition and does not require testing instructions (if checked you can ignore/remove the next section).

How to test the changes in this Pull Request:

  1. You will need to install WC Blocks 9.7.0 or higher. This will enable the Product Details block.
  2. Install also TT2 or TT3 themes.
  3. Go to Appearance > Editor and edit the Single Product template.
  4. After the WooCommerce Single Product Block, add the Product Details block.
  5. Verify theme styles are applied properly:
Before After
imatge imatge

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you created a changelog file for each project being changed, ie pnpm --filter=<project> changelog add?

FOR PR REVIEWER ONLY:

  • I have reviewed that everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities. I made sure Linting is not ignored or disabled.

@Aljullu Aljullu self-assigned this Feb 21, 2023
@Aljullu Aljullu requested review from a team and Konamiman and removed request for a team February 21, 2023 14:02
@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Feb 21, 2023
Comment on lines -369 to -372
.woocommerce-tabs {
padding-top: var(--wp--style--block-gap);

ul.wc-tabs {
Copy link
Contributor Author

@Aljullu Aljullu Feb 21, 2023

Choose a reason for hiding this comment

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

Because the Product Details block is not inside a .woocommerce wrapper in the editor, we needed to move these styles out of .woocomerce { ... }. The change shouldn't be problematic because these classes are all prefixed with .woocommerce- or .wc-, so there won't be conflicts with styles from WP core or other plugins.

@codecov
Copy link

codecov bot commented Feb 21, 2023

Codecov Report

Merging #36911 (00b8a8e) into trunk (c8074a7) will decrease coverage by 0.0%.
The diff coverage is 0.0%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             trunk   #36911     +/-   ##
==========================================
- Coverage     46.7%    46.7%   -0.0%     
- Complexity   17178    17180      +2     
==========================================
  Files          429      429             
  Lines        64779    64784      +5     
==========================================
  Hits         30242    30242             
- Misses       34537    34542      +5     
Impacted Files Coverage Δ
...ocommerce/includes/admin/class-wc-admin-assets.php 0.0% <0.0%> (ø)

@github-actions
Copy link
Contributor

github-actions bot commented Feb 21, 2023

Test Results Summary

Commit SHA: 00b8a8e

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202611m 13s
E2E Tests189006019515m 40s

To view the full API test report, click here.
To view the full E2E test report, click here.
To view all test reports, visit the WooCommerce Test Reports Dashboard.

@Konamiman
Copy link
Contributor

This is how I see it with TT2 in a JN site, is this expected?

image

@Aljullu
Copy link
Contributor Author

Aljullu commented Mar 10, 2023

This is how I see it with TT2 in a JN site, is this expected?

Yes, it is. That gray color in the non-active tabs is coming from the theme stylesheet.

Before After
imatge imatge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: woocommerce Issues related to the WooCommerce Core plugin.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants