This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fine-tune the Add to cart form block (#8482)
* Restrict usage to the single product template. * Update class prefix from wc to wp * Move the add-to-cart-form block to atomic blocks so it is aligned with the updated structure adopted for single product related blocks. * Address CR * ditch woocommerce class. * remove attributes key * Add new styles to account for the removal of the .summary and .entry-summary selectors * Narrow down the styles to the add-to-cart-form class.
- Loading branch information
Showing
9 changed files
with
51 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
36 changes: 36 additions & 0 deletions
36
assets/js/atomic/blocks/product-elements/add-to-cart-form/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { registerBlockSingleProductTemplate } from '@woocommerce/atomic-utils'; | ||
import { registerBlockType, unregisterBlockType } from '@wordpress/blocks'; | ||
import { Icon, button } from '@wordpress/icons'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import metadata from './block.json'; | ||
import edit from './edit'; | ||
|
||
registerBlockSingleProductTemplate( { | ||
registerBlockFn: () => { | ||
// @ts-expect-error: `registerBlockType` is a function that is typed in WordPress core. | ||
registerBlockType( metadata, { | ||
icon: { | ||
src: ( | ||
<Icon | ||
icon={ button } | ||
className="wc-block-editor-components-block-icon" | ||
/> | ||
), | ||
}, | ||
edit, | ||
save() { | ||
return null; | ||
}, | ||
} ); | ||
}, | ||
unregisterBlockFn: () => { | ||
unregisterBlockType( metadata.name ); | ||
}, | ||
blockName: metadata.name, | ||
} ); |
6 changes: 6 additions & 0 deletions
6
assets/js/atomic/blocks/product-elements/add-to-cart-form/style.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.wp-block-add-to-cart-form { | ||
.woocommerce-Price-amount.amount, | ||
.woocommerce-grouped-product-list-item__price del { | ||
font-size: var(--wp--preset--font-size--large); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters