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

Commit

Permalink
Change default template to use the core/group block with a row layout.
Browse files Browse the repository at this point in the history
  • Loading branch information
nerrad committed May 23, 2023
1 parent 4f65d67 commit ab38659
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 24 deletions.
6 changes: 5 additions & 1 deletion assets/js/atomic/blocks/product-elements/price-v2/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ const EditBlock = ( {
>
<div className={ parentClassName }>
<InnerBlocks
allowedBlocks={ [ originalPriceName, currentPriceName ] }
allowedBlocks={ [
originalPriceName,
currentPriceName,
'core/group',
] }
// todo add template for initial price layout
template={ TEMPLATE }
/>
Expand Down
2 changes: 1 addition & 1 deletion assets/js/atomic/blocks/product-elements/price-v2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { registerBlockType } from '@wordpress/blocks';
*/
import sharedConfig from '../shared/config';
import edit from './edit';
import { save } from './save';
import save from './save';
import attributes from './attributes';
import { supports } from './supports';
import {
Expand Down
17 changes: 4 additions & 13 deletions assets/js/atomic/blocks/product-elements/price-v2/save.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
/**
* External dependencies
*/
import classnames from 'classnames';
import { useInnerBlocksProps, useBlockProps } from '@wordpress/block-editor';

export const save = ( { attributes } ) => {
if (
attributes.isDescendentOfSingleProductBlock ||
attributes.isDescendentOfSingleProductTemplate
) {
return null;
}

return (
<div className={ classnames( 'is-loading', attributes.className ) } />
);
};
export default function save() {
return <div { ...useInnerBlocksProps.save( useBlockProps.save() ) } />;
}
7 changes: 0 additions & 7 deletions assets/js/atomic/blocks/product-elements/price-v2/style.scss

This file was deleted.

10 changes: 8 additions & 2 deletions assets/js/atomic/blocks/product-elements/price-v2/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
import { InnerBlockTemplate } from '@wordpress/blocks';

export const TEMPLATE: InnerBlockTemplate[] = [
[ 'woocommerce/original-price', {}, [] ],
[ 'woocommerce/current-price', {}, [] ],
[
'core/group',
{ layout: { type: 'flex', flexWrap: 'nowrap' } },
[
[ 'woocommerce/original-price', {}, [] ],
[ 'woocommerce/current-price', {}, [] ],
],
],
];

0 comments on commit ab38659

Please sign in to comment.