Tinkering with rendering an inner block
This commit is contained in:
parent
f8a5c745ac
commit
6172ccb498
|
@ -25,6 +25,8 @@ import {
|
||||||
getMiniCartTotalsFromServer,
|
getMiniCartTotalsFromServer,
|
||||||
} from './utils/data';
|
} from './utils/data';
|
||||||
import setStyles from '../mini-cart/utils/set-styles';
|
import setStyles from '../mini-cart/utils/set-styles';
|
||||||
|
import { getMiniCartContentsBlockMap } from './render-mini-cart-contents';
|
||||||
|
import { FilledMiniCartContentsBlock } from './mini-cart-contents/inner-blocks/filled-mini-cart-contents-block/frontend';
|
||||||
|
|
||||||
interface dependencyData {
|
interface dependencyData {
|
||||||
src: string;
|
src: string;
|
||||||
|
@ -163,15 +165,12 @@ const { state } = store< Store >( 'woocommerce/mini-cart-interactivity', {
|
||||||
components: {
|
components: {
|
||||||
BlockComponent: () => {
|
BlockComponent: () => {
|
||||||
return ( { children, ...props } ) => {
|
return ( { children, ...props } ) => {
|
||||||
const timems = Date.now();
|
console.log( 'props', props );
|
||||||
|
return h(
|
||||||
console.log( props );
|
FilledMiniCartContentsBlock,
|
||||||
|
{ className: props.class, ...props },
|
||||||
// manually add child text to children
|
children
|
||||||
const childText = h( 'p', {}, 'MiniCartContents: ' + timems );
|
);
|
||||||
const newChildren = [ ...children, childText ];
|
|
||||||
|
|
||||||
return h( 'div', { ...props }, newChildren );
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -18,6 +18,10 @@ const generateUniqueId = () => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getMiniCartContentsBlockMap = () => {
|
||||||
|
return getRegisteredBlockComponents( 'woocommerce/mini-cart-contents' );
|
||||||
|
};
|
||||||
|
|
||||||
// We load this async so that we don't have to load the mini-cart block.
|
// We load this async so that we don't have to load the mini-cart block.
|
||||||
export const renderMiniCartContents = ( templateElement: HTMLDivElement ) => {
|
export const renderMiniCartContents = ( templateElement: HTMLDivElement ) => {
|
||||||
const clonedTemplateNode = templateElement.cloneNode(
|
const clonedTemplateNode = templateElement.cloneNode(
|
||||||
|
|
Loading…
Reference in New Issue