-
Notifications
You must be signed in to change notification settings - Fork 219
Block Refinement: Price Block [draft] #9398
base: trunk
Are you sure you want to change the base?
Conversation
this would be good to derive from the WP entity store at ...this would be good to derive from the WP entity store at some point.
woocommerce-blocks/assets/js/atomic/blocks/product-elements/price/block-new-edit.tsx Lines 47 to 58 in 65db924
🚀 This comment was generated by the automations bot based on a
|
add template for initial price layoutadd template for initial price layout
woocommerce-blocks/assets/js/atomic/blocks/product-elements/price/block-new-edit.tsx Lines 127 to 139 in 65db924
🚀 This comment was generated by the automations bot based on a
|
need to replace with ProductPrice component from a (block...need to replace with ProductPrice component from a (block-new.tsx) implementation (see original price block) */ }
Lines 58 to 66 in 65db924
🚀 This comment was generated by the automations bot based on a
|
The release ZIP for this PR is accessible via:
Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the TypeScript Errors Report
assets/js/atomic/blocks/product-elements/price-v2/edit.tsx
assets/js/atomic/blocks/product-elements/price-v2/index.ts assets/js/atomic/blocks/product-elements/price-v2/inner-blocks/current-price/block.tsx assets/js/atomic/blocks/product-elements/price-v2/inner-blocks/current-price/edit.tsx assets/js/atomic/blocks/product-elements/price-v2/inner-blocks/current-price/index.ts assets/js/atomic/blocks/product-elements/price-v2/inner-blocks/discount/edit.tsx assets/js/atomic/blocks/product-elements/price-v2/inner-blocks/discount/index.ts assets/js/atomic/blocks/product-elements/price-v2/inner-blocks/discount/inner-blocks/discount-amount/block.tsx assets/js/atomic/blocks/product-elements/price-v2/inner-blocks/discount/inner-blocks/discount-amount/edit.tsx assets/js/atomic/blocks/product-elements/price-v2/inner-blocks/discount/inner-blocks/discount-amount/index.ts assets/js/atomic/blocks/product-elements/price-v2/inner-blocks/original-price/block.tsx assets/js/atomic/blocks/product-elements/price-v2/inner-blocks/original-price/edit.tsx assets/js/atomic/blocks/product-elements/price-v2/inner-blocks/original-price/index.ts assets/js/atomic/blocks/product-elements/price-v2/save.tsx assets/js/atomic/blocks/product-elements/price-v2/supports.ts assets/js/atomic/blocks/product-elements/price/block.tsx assets/js/base/components/cart-checkout/cart-line-items-table/cart-line-item-row.tsx assets/js/base/components/cart-checkout/order-summary/order-summary-item.tsx |
Size Change: +7.52 kB (+1%) Total Size: 1.35 MB
ℹ️ View Unchanged
|
65db924
to
9d76a53
Compare
This PR has been marked as If deemed still relevant, the pr can be kept active by ensuring it's up to date with the main branch and removing the stale label. |
3a67f0d
to
4f65d67
Compare
@shaunandrews I have a question regarding this control: Rather than making the stacking a property of the Price block, what are your thoughts on using the appropriate group block (or variation) in the template? It would align with how layout is configured generally in GB and provides access to all the controls associated with the group block and the layout options now (and in the future). I'm wary that by explicitly putting the layout controls on the Price container block itself, it could lead to potential clashes with usage of group (or other layout) blocks elsewhere in a design and particularly limit the creativity that theme development might go with this. |
Although, I guess the pagination block is using a similar design pattern as what you're proposing, so I could have the layout controls explicitly as a part of the price block 🤔 |
Edit: I decided to just add the layout controls to the top-level Price block. The only caveat is that these controls are experimental from GB. @shaunandrews, the latest build (as of this comment) is utilizing the group block so you can install and see the UX behaviour for the block. To test:
To set expectations, this is just to showcase the behaviour using the group block - I'm still working on the other design elements. |
ab38659
to
66991fd
Compare
can use __experimentalDefaultControls to influence which ...can use __experimentalDefaultControls to influence which controls are displayed by default
woocommerce-blocks/assets/js/atomic/blocks/product-elements/price-v2/supports.ts Lines 13 to 25 in cbc4715
🚀 This comment was generated by the automations bot based on a
|
cbc4715
to
863faed
Compare
0f09ffe
to
37b4a7e
Compare
lift all the preview pricing up to the parent block (acro...lift all the preview pricing up to the parent block (across all the price inner blocks)
woocommerce-blocks/assets/js/atomic/blocks/product-elements/price-v2/inner-blocks/discount/block.tsx Lines 62 to 76 in 37b4a7e
🚀 This comment was generated by the automations bot based on a
|
this assumes currentPrice is lower than originalPricethis assumes currentPrice is lower than originalPrice
woocommerce-blocks/assets/js/atomic/blocks/product-elements/price-v2/inner-blocks/discount/block.tsx Lines 18 to 29 in 37b4a7e
🚀 This comment was generated by the automations bot based on a
|
need to setup discountType and showDiscount as attributes...need to setup discountType and showDiscount as attributes/context from the parent block.
woocommerce-blocks/assets/js/atomic/blocks/product-elements/price-v2/inner-blocks/discount/block.tsx Lines 39 to 52 in 37b4a7e
🚀 This comment was generated by the automations bot based on a
|
37b4a7e
to
494faa3
Compare
From “Product Price” to “Price”
Adds `include` property and makes all properties optional.
I decided to create this refinement as a new block given the change in structure and the potential impact on styling etc. We can make a decision on whether this just replaces the existing block in the future, but for now, this allows testing both in tandem.
This allows for being able to edit the text portion of the discount rendering as its own entity.
cbde25b
to
6411938
Compare
"layout": { | ||
"allowSwitching": false, | ||
"allowInheriting": false, | ||
"default": { "type": "flex" } | ||
}, |
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.
Note, the layout
supports property only became recently available and will surface in WordPress 6.3. Prior to that it was __experimentalLayout
which is still supported. It may be better to ship with __experimentalLayout
if we want to support WP versions < 6.3 but even then testing should cover which versions of WP this will explicitly be supported by as that may influence what versions of WP this block is surfaced for.
"isDescendentOfSingleProductTemplate", | ||
"woocommerce/isDescendentOfSingleProductBlock": | ||
"isDescendentOfSingleProductBlock", | ||
"woocommerce/withSuperScriptStyle": "withSuperScriptStyle" |
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.
Not fully implemented yet, I added this as a context value so that it could be used to provide the ability for child blocks to keep their superscript style separate from the parent block. It's possible that isn't great UX in which case this property could potentially just be removed from block context.
{ "name": "default", "label": "Default", "isDefault": true }, | ||
{ "name": "price-super", "label": "Superscript", "isDefault": false } |
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.
Block Styles are usually utilized explicitly for css styles, however given withSuperScript
also impacts HTML, the selection also triggers attribute/context update.
…ginal-price blocks.
…view prices Refactor needed, but for now it shows on the editor
The price parent block also supports color but inner blocks colors take priority
This PR has been marked as If deemed still relevant, the pr can be kept active by ensuring it's up to date with the main branch and removing the stale label. |
Note: This is still a draft PR - I'll be updating as I work on it. I'll also make note when there is something testable (even early). I also will be breaking this out into smaller PRs.
I'm currently working on some refinements to the Price Block:
A major change here is the singular price block becomes a set of various price blocks to represent different price elements that will conditionally show depending on whether the product is on sale and/or user configuration. This allows for finer control over customizing the price display.
Due to this change, there are a number of things needing done to complete this work (list isn't exhaustive and will be updated as I work on this):
A few general notes:
withSuperScript
behaviour works but not sure it's the best approach. Also needs design review around default behaviour etc.Accessibility
prefers-reduced-motion
Other Checks
Screenshots
Testing
Automated Tests
User Facing Testing
WooCommerce Visibility
Performance Impact
Changelog