Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

[Blockifying Product Archive Templates]: Implement the blockified template conversion for the Classic Template Block. #8248

Merged
merged 57 commits into from
Feb 27, 2023

Conversation

kmanijak
Copy link
Contributor

@kmanijak kmanijak commented Jan 20, 2023

Description

The scope of this PR:

  • Implement the blockified template conversion for the Classic Template Block. That covers:
    • Product Archive
    • Product Search Results
  • Update the placeholder description of the Classic Templates
  • Add "align" option to the Store Notices block
  • Improve how align attribute is passed to the PHP blocks

Remaining work:

Fixes #8066

Screenshots/video

Product Archive - side by side comparison (editor):

Classic Template Blockified Template
. image image

Product Archive - side by side comparison (frontend):

Classic Template Blockified Template
. image image

Product Archive - copy update (editor)

Before After
.image image

Single product - copy update (editor)

Before After
.image image

Video presents the replacement of a Classic Template on two templates: Product Catalog and Products by Category

classic-template.mov

Testing

Automated Tests

  • Changes in this PR are covered by Automated Tests.
    • Unit tests
    • E2E tests
      E2E tests will be added as a separate PR

User Facing Testing

Conversion is not yet possible (hidden behind feature flag)
Prerequisites:

WordPress: >=6.1
Make sure Single Product template is cleared out to the default state. To achieve that:

  1. Go to (/wp-admin/site-editor.php?postType=wp_template)
  2. Click three dots next to template and click "Clear customizations"
Steps
  1. Enter the Single Product template
Expected
  • Check that placeholder description says "This block serves as a placeholder for your WooCommerce Single Product Block. It will display the actual product image, title, price in your store. You can move this placeholder around and add more blocks around to customize the template."
  • "Upgrade to Products block" button is not visible.

Repeat for Product Catalog, Products by Category and Product Search Results templates. The placeholder description may vary slightly.

User Facing Testing - behind the experimental flag.

Conversion is not possible on WP lower than 6.1
Prerequisites:

WordPress: <6.1
Make sure Product Catalog and Products by Category templates are cleared out to the default state. To achieve that:

  1. Go to (/wp-admin/site-editor.php?postType=wp_template)
  2. Click three dots next to template and click "Clear customizations"
Steps
  1. Enter the Product Catalog template
Expected
  • Check that placeholder description says "This block serves as a placeholder for your WooCommerce Product Grid Block. It will display the actual product image, title, price in your store. You can move this placeholder around and add more blocks around to customize the template. Don't worry, you can always revert back."
  • "Upgrade to Products block" button is not visible.

Convert classic templates on Product Archive templates
Prerequisites:
  • WordPress: >=6.1
  • Make sure Product Catalog/Products by Category/Products by Attribute/Products by Tag/Product Search Results templates are cleared out to the default state. To achieve that:
  1. Go to (/wp-admin/site-editor.php?postType=wp_template)
  2. Click three dots next to template and click "Clear customizations"
Steps
  1. Enter the Product Catalog template
  2. Check that placeholder description says "This block serves as a placeholder for your WooCommerce Product Grid Block. We recommend upgrading to the Products block for more features to edit your products visually. Don't worry, you can always revert back."
  3. Open List View of the blocks
  4. Click "Upgrade to Products block" button

Screen Shot 2023-01-25 at 11 27 32 AM

Expected

WooCommerce Product Grid Block is replaced with blocks:

  • Products (Beta)
    • Store Breadcrumbs (video was recorded before Breadcrumbs were added)
    • Archive Title
    • Term Description (only in Products By * templates)
    • Store Notices
    • Row
      • Product Results Count
      • Catalog Sorting
    • Product Template
    • Pagination
    • No Results

image

Steps - continue
  1. Go to "Products (beta)" block settings
  2. Make sure "Inherit query from template" is ENABLED! It should be by default.
  3. Save the template
  4. Go to frontend (/shop) and check it the blocks are displayed correctly.
Expected
  • You should expect the view like this:

image

- Check the Product Results Count displays proper numbers, e.g. go to the page 2 (it should say "Showing 17–17 of 17 results" if you're using "standard" products set). - Check the Catalog Sorting sorts the products correctly, e.g. by price.

Repeat the above for template:

  • Products by Category (to check frontend, go to /product-category/clothing/)
  • Expected view contains Breadcrums

image


Convert classic templates on Product Search Results
Prerequisites:
  • WordPress: >=6.1
  • Make sure Product Search Results template is cleared out to the default state. To achieve that:
  1. Go to (/wp-admin/site-editor.php?postType=wp_template)
  2. Click three dots next to template and click "Clear customizations"
Steps
  1. Enter the Product Search Results template
  2. Check that placeholder description says "This block serves as a placeholder for your WooCommerce Product Search Results Block. We recommend upgrading to the Products block for more features to edit your products visually. Don't worry, you can always revert back."
  3. Open List View of the blocks
  4. Click "Upgrade to Products block" button

Screen Shot 2023-01-25 at 11 27 32 AM

Expected

WooCommerce Product Grid Block is replaced with blocks:

  • Products (Beta)
    • Search Results Title
    • Store Notices
    • Row
      • Product Results Count
      • Catalog Sorting
    • Product Template
    • Pagination
    • No Results
      • Paragraph (content: "No products were found matching your selection.")
      • Product Search

image

Steps - continue
  1. Go to "Products (beta)" block settings
  2. Make sure "Inherit query from template" is ENABLED! It should be by default.
  3. Add a Product Search block to the Header template
  4. Save the template
  5. Go to frontend (e.g. /shop)
  6. Use Product Search in the template
  7. Enter a phrase that would cover some product names like: t shirt or beanie
Expected
  • You should expect the product list

image

Steps - continue
  1. Enter a random phrase like blah blah or cars
Expected
  • You should expect the "No results" page with information and Product Search bar:

image


Align attribute is preserved
Prerequisites:

WordPress: >=6.1
Make sure Product Catalog template is cleared out to the default state. To achieve that:

  1. Go to (/wp-admin/site-editor.php?postType=wp_template)
  2. Click three dots next to template and click "Clear customizations"
Steps
  1. Enter the Product Catalog template
  2. Change the align setting of the Classic Template block to either "None" or "Full width"

image

3. Click "Upgrade to Products block" button
Expected
  • Blocks keeps the same align setting in Editor:
    • Store Breadcrumbs
    • Archive Title
    • Store Notices
    • Row
    • Products
Steps - continue
  1. Save the template
  2. Go to frontend (/shop)
Expected
  • Blocks keeps the same width (expected to be 650px wide in case of "None" and full available width in case of "Full width" option)

WooCommerce Visibility

  • WooCommerce Core
  • Feature plugin
  • Experimental

Changelog

Enable users to migrate to blockified Product Archive templates.

@kmanijak kmanijak changed the title ] [Blockifying Product Archive Templates]: Implement the blockified template conversion for the Classic Template Block. Jan 20, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jan 20, 2023

The release ZIP for this PR is accessible via:

https://wcblocks.wpcomstaging.com/wp-content/uploads/woocommerce-gutenberg-products-block-8248.zip

Script Dependencies Report

There is no changed script dependency between this branch and trunk.

This comment was automatically generated by the ./github/compare-assets action.

TypeScript Errors Report

  • Files with errors: 493
  • Total errors: 2340

⚠️ ⚠️ This PR introduces new TS errors on 4 files:

assets/js/blocks/classic-template/archive-product.ts

assets/js/blocks/classic-template/index.tsx

assets/js/blocks/classic-template/product-search-results.ts

assets/js/blocks/classic-template/utils.ts

comments-aggregator

@github-actions
Copy link
Contributor

github-actions bot commented Jan 20, 2023

Size Change: +2.78 kB (0%)

Total Size: 1.11 MB

Filename Size Change
build/active-filters.js 7.33 kB +8 B (0%)
build/all-products.js 36.4 kB +3 B (0%)
build/all-reviews.js 7.66 kB -4 B (0%)
build/attribute-filter.js 12.4 kB +1 B (0%)
build/cart.js 47.4 kB +15 B (0%)
build/catalog-sorting.js 1.7 kB -1 B (0%)
build/checkout.js 44.2 kB +2 B (0%)
build/customer-account.js 3.08 kB +3 B (0%)
build/featured-category.js 13.5 kB +157 B (+1%)
build/featured-product.js 13.7 kB +98 B (+1%)
build/filter-wrapper.js 2.39 kB -2 B (0%)
build/handpicked-products.js 7.24 kB +4 B (0%)
build/legacy-template.js 5.28 kB +2.43 kB (+85%) 🆘
build/mini-cart-contents.js 17.1 kB -10 B (0%)
build/price-filter.js 8.39 kB +5 B (0%)
build/product-add-to-cart.js 8.61 kB +4 B (0%)
build/product-best-sellers.js 7.6 kB -2 B (0%)
build/product-button--product-category-list--product-image--product-price--product-rating--product-sale-b--e17c7c01.js 499 B -1 B (0%)
build/product-button--product-image--product-price--product-rating--product-sale-badge--product-title.js 258 B -1 B (0%)
build/product-button.js 3.99 kB -1 B (0%)
build/product-categories.js 2.36 kB +2 B (0%)
build/product-category-list.js 502 B -1 B (0%)
build/product-image.js 4.09 kB -8 B (0%)
build/product-on-sale.js 7.91 kB +4 B (0%)
build/product-price.js 1.58 kB -1 B (0%)
build/product-query.js 6.6 kB +44 B (+1%)
build/product-rating.js 920 B +1 B (0%)
build/product-results-count.js 1.65 kB -2 B (0%)
build/product-sale-badge.js 815 B -2 B (0%)
build/product-search.js 2.63 kB +3 B (0%)
build/product-stock-indicator.js 645 B -1 B (0%)
build/product-tag-list.js 497 B -1 B (0%)
build/product-tag.js 8.07 kB +1 B (0%)
build/product-top-rated.js 7.82 kB +3 B (0%)
build/products-by-attribute.js 8.52 kB +3 B (0%)
build/rating-filter.js 7.42 kB +4 B (0%)
build/reviews-by-category.js 11.2 kB +8 B (0%)
build/reviews-by-product.js 12.3 kB +31 B (0%)
build/single-product.js 9.94 kB -37 B (0%)
build/stock-filter.js 8.13 kB +3 B (0%)
build/wc-blocks-vendors.js 64.4 kB +13 B (0%)
build/wc-blocks.js 2.63 kB +1 B (0%)
ℹ️ View Unchanged
Filename Size
build/active-filters-frontend.js 7.98 kB
build/active-filters-wrapper-frontend.js 5.99 kB
build/all-products-frontend.js 11.7 kB
build/attribute-filter-frontend.js 22.4 kB
build/attribute-filter-wrapper-frontend.js 7.08 kB
build/blocks-checkout.js 41.2 kB
build/breadcrumbs.js 2.05 kB
build/cart-blocks/cart-accepted-payment-methods-frontend.js 1.38 kB
build/cart-blocks/cart-cross-sells-frontend.js 253 B
build/cart-blocks/cart-cross-sells-products-frontend.js 9.67 kB
build/cart-blocks/cart-express-payment--checkout-blocks/express-payment-frontend.js 5.19 kB
build/cart-blocks/cart-express-payment-frontend.js 720 B
build/cart-blocks/cart-items-frontend.js 299 B
build/cart-blocks/cart-line-items--mini-cart-contents-block/products-table-frontend.js 5.35 kB
build/cart-blocks/cart-line-items-frontend.js 1.06 kB
build/cart-blocks/cart-order-summary-frontend.js 1.24 kB
build/cart-blocks/cart-totals-frontend.js 322 B
build/cart-blocks/empty-cart-frontend.js 345 B
build/cart-blocks/filled-cart-frontend.js 655 B
build/cart-blocks/order-summary-coupon-form-frontend.js 1.62 kB
build/cart-blocks/order-summary-discount-frontend.js 2.12 kB
build/cart-blocks/order-summary-fee-frontend.js 274 B
build/cart-blocks/order-summary-heading-frontend.js 455 B
build/cart-blocks/order-summary-shipping-frontend.js 14.8 kB
build/cart-blocks/order-summary-subtotal-frontend.js 275 B
build/cart-blocks/order-summary-taxes-frontend.js 434 B
build/cart-blocks/proceed-to-checkout-frontend.js 1.24 kB
build/cart-frontend.js 28.9 kB
build/checkout-blocks/actions-frontend.js 1.85 kB
build/checkout-blocks/billing-address--checkout-blocks/shipping-address-frontend.js 3.92 kB
build/checkout-blocks/billing-address-frontend.js 1.18 kB
build/checkout-blocks/contact-information-frontend.js 2.05 kB
build/checkout-blocks/express-payment-frontend.js 1.13 kB
build/checkout-blocks/fields-frontend.js 345 B
build/checkout-blocks/order-note-frontend.js 1.14 kB
build/checkout-blocks/order-summary-cart-items-frontend.js 3.67 kB
build/checkout-blocks/order-summary-coupon-form-frontend.js 1.79 kB
build/checkout-blocks/order-summary-discount-frontend.js 2.29 kB
build/checkout-blocks/order-summary-fee-frontend.js 276 B
build/checkout-blocks/order-summary-frontend.js 1.24 kB
build/checkout-blocks/order-summary-shipping-frontend.js 14.9 kB
build/checkout-blocks/order-summary-subtotal-frontend.js 275 B
build/checkout-blocks/order-summary-taxes-frontend.js 435 B
build/checkout-blocks/payment-frontend.js 8.43 kB
build/checkout-blocks/pickup-options-frontend.js 2.8 kB
build/checkout-blocks/shipping-address-frontend.js 1.14 kB
build/checkout-blocks/shipping-method-frontend.js 2.28 kB
build/checkout-blocks/shipping-methods-frontend.js 4.56 kB
build/checkout-blocks/terms-frontend.js 1.56 kB
build/checkout-blocks/totals-frontend.js 324 B
build/checkout-frontend.js 30.5 kB
build/filter-wrapper-frontend.js 14.1 kB
build/general-style-rtl.css 1.31 kB
build/general-style.css 1.31 kB
build/mini-cart-component-frontend.js 28 kB
build/mini-cart-contents-block/empty-cart-frontend.js 366 B
build/mini-cart-contents-block/filled-cart-frontend.js 268 B
build/mini-cart-contents-block/footer-frontend.js 2.86 kB
build/mini-cart-contents-block/items-frontend.js 237 B
build/mini-cart-contents-block/products-table-frontend.js 589 B
build/mini-cart-contents-block/shopping-button-frontend.js 313 B
build/mini-cart-contents-block/title-frontend.js 367 B
build/mini-cart-frontend.js 2 kB
build/mini-cart.js 4.29 kB
build/price-filter-frontend.js 13.8 kB
build/price-filter-wrapper-frontend.js 6.99 kB
build/price-format.js 1.19 kB
build/product-add-to-cart--product-button--product-category-list--product-image--product-price--product-r--a0326d00.js 253 B
build/product-add-to-cart--product-button--product-image--product-rating--product-title.js 151 B
build/product-add-to-cart-frontend.js 6.71 kB
build/product-button-frontend.js 2.19 kB
build/product-category-list-frontend.js 1.19 kB
build/product-category.js 8.58 kB
build/product-image-frontend.js 2.2 kB
build/product-new.js 7.58 kB
build/product-price-frontend.js 2.29 kB
build/product-rating-frontend.js 1.62 kB
build/product-sale-badge-frontend.js 1.43 kB
build/product-sku-frontend.js 629 B
build/product-sku.js 378 B
build/product-stock-indicator-frontend.js 1.31 kB
build/product-summary-frontend.js 1.58 kB
build/product-summary.js 920 B
build/product-tag-list-frontend.js 1.18 kB
build/product-title-frontend.js 1.61 kB
build/product-title.js 3.46 kB
build/rating-filter-frontend.js 20.9 kB
build/rating-filter-wrapper-frontend.js 5.61 kB
build/reviews-frontend.js 7.14 kB
build/single-product-frontend.js 17.9 kB
build/stock-filter-frontend.js 21.1 kB
build/stock-filter-wrapper-frontend.js 5.85 kB
build/store-notices.js 1.69 kB
build/vendors--attribute-filter-wrapper--cart-blocks/cart-cross-sells-products--cart-blocks/order-summary--82e4ed06-frontend.js 6.86 kB
build/vendors--attribute-filter-wrapper--rating-filter-wrapper--stock-filter-wrapper-frontend.js 7.69 kB
build/vendors--cart-blocks/cart-cross-sells-products--cart-blocks/cart-line-items--cart-blocks/cart-order--3c5fe802-frontend.js 5.26 kB
build/vendors--cart-blocks/cart-cross-sells-products--cart-blocks/order-summary-shipping--checkout-blocks--18f9376a-frontend.js 19.4 kB
build/vendors--cart-blocks/cart-cross-sells-products--product-add-to-cart-frontend.js 7.25 kB
build/vendors--cart-blocks/cart-line-items--checkout-blocks/order-summary-cart-items--mini-cart-contents---233ab542-frontend.js 3.14 kB
build/vendors--cart-blocks/order-summary-shipping--checkout-blocks/billing-address--checkout-blocks/order--5b8feb0b-frontend.js 4.83 kB
build/vendors--checkout-blocks/shipping-method-frontend.js 12 kB
build/vendors--checkout-blocks/shipping-methods-frontend.js 8.84 kB
build/wc-blocks-data.js 21.5 kB
build/wc-blocks-editor-style-rtl.css 5.72 kB
build/wc-blocks-editor-style.css 5.73 kB
build/wc-blocks-google-analytics.js 1.56 kB
build/wc-blocks-middleware.js 933 B
build/wc-blocks-registry.js 3.15 kB
build/wc-blocks-shared-context.js 1.52 kB
build/wc-blocks-shared-hocs.js 1.73 kB
build/wc-blocks-style-rtl.css 26.7 kB
build/wc-blocks-style.css 26.7 kB
build/wc-blocks-vendors-style-rtl.css 1.96 kB
build/wc-blocks-vendors-style.css 1.96 kB
build/wc-payment-method-bacs.js 816 B
build/wc-payment-method-cheque.js 811 B
build/wc-payment-method-cod.js 909 B
build/wc-payment-method-paypal.js 837 B
build/wc-settings.js 2.6 kB
build/wc-shipping-method-pickup-location.js 29.7 kB
build/woo-directives-runtime.js 2.52 kB
build/woo-directives-vendors.js 7.91 kB

compressed-size-action

Copy link
Contributor

@Aljullu Aljullu left a comment

Choose a reason for hiding this comment

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

Looks great. Very nice to see the progress of this project. 👏

I think we should wrap the Catalog Sorting and Product Result Count blocks in a Row block (which is a variation of the Group block), so they are in the same line.

imatge

Besides that, I left some comments inline.

assets/js/blocks/classic-template/index.tsx Outdated Show resolved Hide resolved
templates/templates/blockified/archive-product.ts Outdated Show resolved Hide resolved
templates/templates/blockified/archive-product.ts Outdated Show resolved Hide resolved
assets/js/blocks/classic-template/index.tsx Outdated Show resolved Hide resolved
@Aljullu
Copy link
Contributor

Aljullu commented Jan 23, 2023

To answer your questions:

  • should the new template (JS) be stored in templates/templates/blockified/archive-product.ts? Maybe it should lay down somewhere in the assets/** along with other JS code?

I left an inline comment regarding that. But considering this script is only called from the Classic Template block, I would move it there.

  • should the template export just the block structures or the block instance like it is right now (using createBlock method from @wordpress/blocks). Maybe there's another idea you may suggest?

I don't have any alternative idea. Let's see if somebody has one. Otherwise, this approach LGTM.

  • blocks used in the template require additional styles to layout them properly. Is that ok if they sit next to the template, so templates/templates/blockified/archive-product.scss? It doesn't sound right, especially that it would require adjusting the Webpack config to include the styles from there as well. I'll explore other possibilities, but I'm open for suggestions.

Which additional styles? If they need specific CSS, that should be probably be fixed in the block leve. 🤔

@kmanijak
Copy link
Contributor Author

@Aljullu, thank you so much for a great review! 🙏

But considering this script is only called from the Classic Template block, I would move it there.

Can I confirm, by "move it there", do you mean next to Classic Template or assets directory in general (for example /assets/js/blocks/product-query/ as you suggested in inline comment)?

Which additional styles? If they need specific CSS, that should be probably be fixed in the block leve. 🤔

I meant the styles related to lay outing the blocks, so putting Product Results Count and Catalog Ordering in a row. Exactly what you showed in a comment suggesting to use Row block. So with your recommendation, the additional styles won't be necessary anymore and so the custom class. 👍

When used in a Row block in a blockified Archive Product template, Product Results Count had additional unnecessary margin which caused misalignment with the Catalog Sorting block
@Aljullu
Copy link
Contributor

Aljullu commented Jan 24, 2023

Can I confirm, by "move it there", do you mean next to Classic Template or assets directory in general (for example /assets/js/blocks/product-query/ as you suggested in inline comment)?

I answered inline above. 🙂

I meant the styles related to lay outing the blocks, so putting Product Results Count and Catalog Ordering in a row. Exactly what you showed in a comment suggesting to use Row block. So with your recommendation, the additional styles won't be necessary anymore and so the custom class. 👍

Great!

It was added couple of commits earlier, since the template was kept there, but it was decided to move it to assets directory, so entry is no longer necessary
…on the availability to convert to Products block
@github-actions
Copy link
Contributor

Uncomment when Breadcrumb block becomes available await e...

Uncomment when Breadcrumb block becomes available await expect( page ).toMatchElement( breadcrumbs );


// TODO: Uncomment when Breadcrumb block becomes available
// await expect( page ).toMatchElement( breadcrumbs );
await expect( page ).toMatchElement( productResultsCount );
await expect( page ).toMatchElement( catalogSorting );
await expect( page ).toMatchElement( products );
} );
} );
describe( 'Product by Category block template', () => {

🚀 This comment was generated by the automations bot based on a todo comment in a52107d in #8248. cc @kmanijak

@github-actions
Copy link
Contributor

Uncomment and add selector when Breadcrumb block becomes ...

Uncomment and add selector when Breadcrumb block becomes available breadcrumbs: '',


// TODO: Uncomment and add selector when Breadcrumb block becomes available
// breadcrumbs: '',
productResultsCount: '.wc-block-product-results-count',
catalogSorting: '.wc-block-catalog-sorting',
products: '.wp-block-query',
},
};
const CUSTOMIZED_STRING = 'My awesome customization';

🚀 This comment was generated by the automations bot based on a todo comment in a52107d in #8248. cc @kmanijak

@kmanijak kmanijak added focus: template Related to API powering block template functionality in the Site Editor type: new block Applied to work that introduces a new block (typically used on an epic issue). labels Jan 25, 2023
@kmanijak kmanijak marked this pull request as ready for review January 25, 2023 11:01
@woocommercebot woocommercebot requested review from a team and removed request for a team January 25, 2023 11:02
@kmanijak
Copy link
Contributor Author

kmanijak commented Feb 2, 2023

As per the comment in similar PR, this PR is now extended with blockified config variation for Products By * templates. The difference between Product Catalog config is the Term Description block is included (commit).

@@ -11,7 +11,8 @@ import { TemplateDetails } from './types';
export const BLOCK_SLUG = 'woocommerce/legacy-template';
export const TYPES = {
singleProduct: 'single-product',
archiveProduct: 'archive-product',
productCatalog: 'product-catalog',
productsBy: 'products-by',
Copy link
Member

Choose a reason for hiding this comment

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

To me, it's a bit unclear what productsBy means. Can we consider other alternative here? Somethings like productTaxonomy, productLoop, productGrid? or even keep archiveProduct for shared template, and use productCatalog just for the catalog page.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To me, it's a bit unclear what productsBy means.

Thanks for feedback, makes sense! I Changed that to productTaxonomy (commit)

@danieldudzic danieldudzic removed their request for review February 12, 2023 23:27
@kmanijak
Copy link
Contributor Author

This PR has been waiting for a final decision if the blocks: Breadcrumbs, Store Notices, Product Result Count, Catalog Sorting should surround Products block or be inner blocks:

As per the PR: #8308, these blocks are the inner blocks of Products. This commit applies the change here. Also, the testing steps are amended now.

Given that, this PR is ready for final testing and review.

cc: @Aljullu, @albarin

@kmanijak kmanijak requested review from Aljullu and albarin February 22, 2023 11:30
Copy link
Contributor

@Aljullu Aljullu left a comment

Choose a reason for hiding this comment

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

This is looking awesome, good job! The code looks good and it's testing as expected. I have only seen one issue: when converting the Classic Template block to the new one, I can see several visual differences.

Classic template Blockified template
imatge imatge

Some things I see:

  • We should include the Product Rating block, which is not included in the default pattern of the Products block.
  • We should make the Product Title a link (I don't know why the Products block don't have it enabled by default, it might be better to fix it there?).
  • The Product Price should be centered (IMO, this might be worth doing in the Products block directly).

I noticed your screenshots don't have some these issues. So maybe I have been doing something wrong? 😕

@kmanijak
Copy link
Contributor Author

We should include the Product Rating block, which is not included in the default pattern of the Products block.

I started implementing that... But I think it's worth implementing it in Products block directly and include Product Rating by default in the Products inner blocks template. The reason being:

  • I don't want to hardcode the position where to inject the Product Rating (pseudocode: innerBlockTemplate[0][1] = createBlock('core/product-rating'))
  • I would like to avoid writing a generic function (so it's future proof) that would find a post-template and product-title to inject rating afterward. I think it's unnecessary complex comparing to the gain.
    I would raise the question about extending Products with Product Rating. What do you think? 🤔

We should make the Product Title a link (I don't know why the Products block don't have it enabled by default, it might be better to fix it there?).

Good catch. I see post-title has an attribute isLink. But I'll prepare a separate PR directly in Products block, so it can be confirmed by others.

The Product Price should be centered (IMO, this might be worth doing in the Products block directly).
I noticed your screenshots don't have some these issues. So maybe I have been doing something wrong? 😕

That's weird, it's centered by default for me and it's defined in here. So I'm not sure how to approach this one 🤔

@kmanijak
Copy link
Contributor Author

kmanijak commented Feb 23, 2023

The Product Price should be centered (IMO, this might be worth doing in the Products block directly).
I noticed your screenshots don't have some these issues. So maybe I have been doing something wrong? 😕

That's weird, it's centered by default for me and it's defined in here. So I'm not sure how to approach this one 🤔

@Aljullu, ok, I can reproduce it (here and on trunk). It shows centered in the Editor, but it is left-aligned in the FE. Seems the alignment is broken again :( I'll create an issue, I don't think the fix should be included in this PR. 🙏

EDIT: issue created: #8521

@kmanijak
Copy link
Contributor Author

Summary:

We should include the Product Rating block, which is not included in the default pattern of the Products block.

It's raised for internal discussion to confirm if the change could be included in the Products block directly. If not I'll add it to the templates within this PR.
Although, I tend to think we could merge this in a current shape (without Product Rating) and apply the change once there's a decision. The reasons would be:

We should make the Product Title a link (I don't know why the Products block doesn't have it enabled by default, it might be better to fix it there?).

It's fixed and merged to trunk (PR)

The Product Price should be centered (IMO, this might be worth doing in the Products block directly).

Reproducible on trunk, I created an issue: #8521

Copy link
Contributor

@Aljullu Aljullu left a comment

Choose a reason for hiding this comment

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

I would raise the question about extending Products with Product Rating. What do you think? 🤔

It makes sense to me. 👌

Good catch. I see post-title has an attribute isLink. But I'll prepare a separate PR directly in Products block, so it can be confirmed by others.

Thanks!

Although, I tend to think we could merge this in a current shape (without Product Rating) and apply the change once there's a decision.

Sounds good. I agree that we can merge this PR now and work on the remaining tasks in follow-up PRs.

Thanks, @kmanijak!

@github-actions github-actions bot added this to the 9.7.0 milestone Feb 23, 2023
@kmanijak kmanijak self-assigned this Feb 27, 2023
@kmanijak kmanijak merged commit a52be40 into trunk Feb 27, 2023
@kmanijak kmanijak deleted the add/convert-classic-template branch February 27, 2023 14:34
@dinhtungdu dinhtungdu added the type: enhancement The issue is a request for an enhancement. label Feb 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
focus: template Related to API powering block template functionality in the Site Editor type: enhancement The issue is a request for an enhancement. type: new block Applied to work that introduces a new block (typically used on an epic issue).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement the blockified template conversion for the Classic Template Block.
3 participants