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
[WIP] CYS - Core: add integration with the font library #44004
Conversation
Test Results SummaryCommit SHA: da98e3f
Please address the following issues prior to merging this pull request: |
…-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
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: |
There was a problem hiding this 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:
- 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
- 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.
- 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
plugins/woocommerce-admin/client/customize-store/design-without-ai/services.ts
Show resolved
Hide resolved
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! 🙏 |
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
@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? |
…-cys-ensure-the-fonts-selected-in-the-assembler-are-displayed-on-the-frontend
99376da
to
78e38ab
Compare
There was a problem hiding this 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:
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
Thanks for the review and for opening these issues! 🚀 |
* 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>
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 thewp_font_face
. For this reason, it is necessary to create awp_font_family
post 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:
Create a new WooCommerce installation with this version.
Ensure the WooCommerce Beta Tester plugin is installed and activated (available on this monorepo).
Head over to
/wp-admin/tools.php?page=woocommerce-admin-test-helper
and enablecustomize-store
feature flag.Install this build of Gutenberg that contains the new Font Library API:
gutenberg.zip
Visit the
wp-admin/admin.php?page=wc-admin&path=/customize-store
.Open the network tools.
Follow the process.
Ensure that there are several POST requests to the
/wp/v2/font-families/
endpoint.Click "Change fonts" on the left sidebar.
Select different fonts and ensure that the selected font is applied to the first title
Visit the
wp-admin/admin.php?page=wc-admin&path=/customize-store
.Open the network tools.
Ensure that no POST requests to the
/wp/v2/font-families/
endpoint are done.Warnings⚠️
Changelog entry
Significance
Type
Message
CYS - Core: add integration with the font library.
Comment