rebase from live enviornment

This commit is contained in:
Rachit Bhargava
2024-01-09 22:14:20 -05:00
parent ff0b49a046
commit 3a22fcaa4a
15968 changed files with 2344674 additions and 45234 deletions

View File

@@ -0,0 +1,26 @@
{
"name": "woocommerce/page-content-wrapper",
"version": "1.0.0",
"title": "WooCommerce Page",
"description": "Displays WooCommerce page content.",
"category": "woocommerce",
"keywords": [ "WooCommerce" ],
"textdomain": "woocommerce",
"supports": {
"html": false,
"multiple": false,
"inserter": false
},
"attributes": {
"page": {
"type": "string",
"default": ""
}
},
"providesContext": {
"postId": "postId",
"postType": "postType"
},
"apiVersion": 2,
"$schema": "https://schemas.wp.org/trunk/block.json"
}

View File

@@ -0,0 +1,3 @@
.wp-block-woocommerce-page-content-wrapper {
max-width: 100% !important;
}

View File

@@ -0,0 +1,88 @@
/**
* External dependencies
*/
import {
registerBlockType,
InnerBlockTemplate,
BlockAttributes,
} from '@wordpress/blocks';
import { __ } from '@wordpress/i18n';
import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';
import { page } from '@wordpress/icons';
import { CHECKOUT_PAGE_ID, CART_PAGE_ID } from '@woocommerce/block-settings';
import { useEffect } from '@wordpress/element';
/**
* Internal dependencies
*/
import metadata from './block.json';
import './editor.scss';
const Edit = ( {
attributes,
setAttributes,
}: {
attributes: BlockAttributes;
setAttributes: ( attrs: BlockAttributes ) => void;
} ) => {
const TEMPLATE: InnerBlockTemplate[] = [
[ 'core/post-title', { align: 'wide' } ],
[ 'core/post-content', { align: 'wide' } ],
];
const blockProps = useBlockProps( {
className: 'wp-block-woocommerce-page-content-wrapper',
} );
useEffect( () => {
if ( ! attributes.postId && attributes.page ) {
let postId = 0;
if ( attributes.page === 'checkout' ) {
postId = CHECKOUT_PAGE_ID;
}
if ( attributes.page === 'cart' ) {
postId = CART_PAGE_ID;
}
if ( postId ) {
setAttributes( { postId, postType: 'page' } );
}
}
}, [ attributes, setAttributes ] );
return (
<div { ...blockProps }>
<InnerBlocks template={ TEMPLATE } />
</div>
);
};
registerBlockType( metadata, {
icon: {
src: page,
},
edit: Edit,
save: () => <InnerBlocks.Content />,
variations: [
{
name: 'checkout-page',
title: __( 'Checkout Page', 'woo-gutenberg-products-block' ),
attributes: {
page: 'checkout',
},
isActive: ( blockAttributes, variationAttributes ) =>
blockAttributes.page === variationAttributes.page,
},
{
name: 'cart-page',
title: __( 'Cart Page', 'woo-gutenberg-products-block' ),
attributes: {
page: 'cart',
},
isActive: ( blockAttributes, variationAttributes ) =>
blockAttributes.page === variationAttributes.page,
},
],
} );