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

[WIP] CYS - Core: add integration with the font library #44004

Conversation

gigitux
Copy link
Contributor

@gigitux gigitux commented Jan 23, 2024

Submission Review Guidelines:

Changes proposed in this Pull Request:

Closes #41924.

This PR implements the support for the Font Library to allow the user to pick different fonts on the Assembler.

Technical Details

Font Library API

The Font Library is based on two post types after the API refactor:
wp_font_family -> contains the data related to the Font Family (e.g.: slug)
wp_font_face -> includes the data of specific font faces of a particular font family.

There is a strict relationship between these two post types. The wp_font_family is the parent post of the wp_font_face. For this reason, it is necessary to create a wp_font_familypost before installing the various font faces.

CYS integration

The fonts installed are defined with the FONT_FAMILY_TO_INSTALL constant.

This constant is created manually by reading the value from the FONT_PAIRINGS_WHEN_AI_IS_OFFLINE constant (source code): we want to install only the necessary fonts to reduce the setup time and not install too many fonts. We could create a logic to generate this variable, but at this time, it isn't worth it, in my opinion.

During the initial setup, the client gets the already installed Font Families (and related Font Face). In this way, we can install only the fonts that aren't already installed. (source code)

After the setup is finished, when the Assembler is loaded, all the fonts are preloaded. (source code)

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

  1. Create a new WooCommerce installation with this version.

  2. Ensure the WooCommerce Beta Tester plugin is installed and activated (available on this monorepo).

  3. Head over to /wp-admin/tools.php?page=woocommerce-admin-test-helper and enable customize-store feature flag.

  4. Install this build of Gutenberg that contains the new Font Library API:
    gutenberg.zip

  5. Visit the wp-admin/admin.php?page=wc-admin&path=/customize-store.

  6. Open the network tools.

  7. Follow the process.

  8. Ensure that there are several POST requests to the /wp/v2/font-families/ endpoint.

  9. Click "Change fonts" on the left sidebar.

  10. Select different fonts and ensure that the selected font is applied to the first title

  11. Visit the wp-admin/admin.php?page=wc-admin&path=/customize-store.

  12. Open the network tools.

  13. Ensure that no POST requests to the /wp/v2/font-families/ endpoint are done.

image

Warnings ⚠️

Changelog entry

  • Automatically create a changelog entry from the details below.

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

CYS - Core: add integration with the font library.

Comment

Copy link
Contributor

github-actions bot commented Jan 23, 2024

Test Results Summary

Commit SHA: da98e3f

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 36s
E2E Tests2440262030817m 5s

⚠️ Warning

Please address the following issues prior to merging this pull request:
  • FAILED/BROKEN TESTS. There were failed and/or broken API and E2E tests.

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.

@gigitux gigitux self-assigned this Jan 24, 2024
@gigitux gigitux added team: Kirigami & Origami focus: customize-your-store Issues related to the Customize Your Store onboarding flow. labels Jan 24, 2024
@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Jan 24, 2024
Copy link
Contributor

github-actions bot commented Jan 24, 2024

Hi @albarin, @woocommerce/woo-fse

Apart from reviewing the code changes, please make sure to review the testing instructions as well.

You can follow this guide to find out what good testing instructions should look like:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

Copy link
Member

@nefeline nefeline left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, @gigitux ! A few notes on my end:

  1. Whenever running the Assembler for the first time, the default font pairing is not being pre-selected on the sidebar, so it's impossible to determine the one that is currently active:
Screen.Recording.2024-01-25.at.09.44.00.mov
  1. Some font pairings are influencing the size of other font pairings:
  • Click on Montserrat + Arvo
  • Click on Albert Sans + Lora, the size is the same.
  • Click on Rubik + Inter and you'll see the font is bigger.
  • Click back on Albert Sans + Lora and check how the font is bigger when compared to the initial Albert Sans + Lora pairing right after clicking on Montserrat + Arvo
Screen.Recording.2024-01-25.at.10.01.02.mov

Ideally, the size of the fonts should not be affected by the font family changes, independent of the provided combinations.

  1. Some fonts don't seem to be changing in certain patterns whenever selected, see example:
Screen.Recording.2024-01-25.at.10.03.47.mov

I've also left a note regarding the moment when font installation should be triggered

@gigitux
Copy link
Contributor Author

gigitux commented Jan 25, 2024

Thanks for working on this, @gigitux ! A few notes on my end:

  1. Whenever running the Assembler for the first time, the default font pairing is not being pre-selected on the sidebar, so it's impossible to determine the one that is currently active:

Screen.Recording.2024-01-25.at.09.44.00.mov
2. Some font pairings are influencing the size of other font pairings:

  • Click on Montserrat + Arvo
  • Click on Albert Sans + Lora, the size is the same.
  • Click on Rubik + Inter and you'll see the font is bigger.
  • Click back on Albert Sans + Lora and check how the font is bigger when compared to the initial Albert Sans + Lora pairing right after clicking on Montserrat + Arvo

Screen.Recording.2024-01-25.at.10.01.02.mov
Ideally, the size of the fonts should not be affected by the font family changes, independent of the provided combinations.

  1. Some fonts don't seem to be changing in certain patterns whenever selected, see example:

Screen.Recording.2024-01-25.at.10.03.47.mov
I've also left a note regarding the moment when font installation should be triggered

Regarding the points 2 and 3, I guess that it is something related to this issue #44010, but I will double-check them!

Nice catch regarding the first point!

Thanks for your great review! 🙏

@gigitux
Copy link
Contributor Author

gigitux commented Jan 29, 2024

WordPress/gutenberg#58222 implements some changes to the API. fcc774b adapt the code with the new shape of the API

…-cys-ensure-the-fonts-selected-in-the-assembler-are-displayed-on-the-frontend
…-cys-ensure-the-fonts-selected-in-the-assembler-are-displayed-on-the-frontend
…-cys-ensure-the-fonts-selected-in-the-assembler-are-displayed-on-the-frontend
@gigitux
Copy link
Contributor Author

gigitux commented Feb 1, 2024

@nefeline With 10cb26e I did another optimization to improve the font installation speed.

I think that it could make sense to review/merge this PR because it is already pretty big. As follow-up:

WDYT?

@gigitux gigitux marked this pull request as ready for review February 1, 2024 11:24
…-cys-ensure-the-fonts-selected-in-the-assembler-are-displayed-on-the-frontend
@woocommercebot woocommercebot requested a review from a team February 1, 2024 11:30
@gigitux gigitux force-pushed the 41924-cys-ensure-the-fonts-selected-in-the-assembler-are-displayed-on-the-frontend branch from 99376da to 78e38ab Compare February 1, 2024 12:59
Copy link
Member

@nefeline nefeline left a comment

Choose a reason for hiding this comment

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

@nefeline With 10cb26e I did another optimization to improve the font installation speed.

Excellent! Thanks for your work here, @gigitux.

I think that it could make sense to review/merge this PR because it is already pretty big. As follow-up:

Agreed 🤝 . Adding a note here for future reference the following issues must be addressed in order to ensure a successful implementation of this feature on core:

#44259
#44258
#44257
#44010

With that said, I'm going ahead and approving the PR so we can unblock the work for the aforementioned bug fixes & improvements.

…-cys-ensure-the-fonts-selected-in-the-assembler-are-displayed-on-the-frontend
@gigitux gigitux enabled auto-merge (squash) February 1, 2024 17:05
@gigitux
Copy link
Contributor Author

gigitux commented Feb 1, 2024

@nefeline With 10cb26e I did another optimization to improve the font installation speed.

Excellent! Thanks for your work here, @gigitux.

I think that it could make sense to review/merge this PR because it is already pretty big. As follow-up:

Agreed 🤝 . Adding a note here for future reference the following issues must be addressed in order to ensure a successful implementation of this feature on core:

#44259 #44258 #44257 #44010

With that said, I'm going ahead and approving the PR so we can unblock the work for the aforementioned bug fixes & improvements.

Thanks for the review and for opening these issues! 🚀

@gigitux gigitux merged commit e0972ef into trunk Feb 1, 2024
23 of 25 checks passed
@gigitux gigitux deleted the 41924-cys-ensure-the-fonts-selected-in-the-assembler-are-displayed-on-the-frontend branch February 1, 2024 17:16
@github-actions github-actions bot added this to the 8.7.0 milestone Feb 1, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label Feb 1, 2024
thealexandrelara pushed a commit that referenced this pull request Feb 1, 2024
* CYS - Core: add integration with the font library

* install font only when necessary

* refactor logic

* add try catch

* renaming font

* refactor some code

* refactor some logic

* Add changefile(s) from automation for the following project(s): woocommerce

* remove not used import

* avoid mutability

* improve performance

* update name variable

* fix naming

* fix endpoints after font collection rest controller improvements

* use promise.all into the map

* improve performance

* fix lint error

---------

Co-authored-by: github-actions <github-actions@github.com>
@veljkho veljkho added needs: internal testing Indicates if the PR requires further testing conducted by Solaris status: analysis complete Indicates if a PR has been analysed by Solaris and removed needs: analysis Indicates if the PR requires a PR testing scrub session. labels Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: customize-your-store Issues related to the Customize Your Store onboarding flow. needs: internal testing Indicates if the PR requires further testing conducted by Solaris plugin: woocommerce Issues related to the WooCommerce Core plugin. status: analysis complete Indicates if a PR has been analysed by Solaris team: Kirigami & Origami
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CYS on Core] Ensure the fonts selected in the Assembler are displayed on the frontend
3 participants