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

Commit

Permalink
Display Mini Cart overlay in template part editor (#9014)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aljullu authored Apr 14, 2023
1 parent 9f3da2f commit 2dc0a52
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
28 changes: 18 additions & 10 deletions assets/js/blocks/mini-cart/mini-cart-contents/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const Edit = ( {
}, [] );

return (
<div { ...blockProps }>
<>
<InspectorControls key="inspector">
<PanelBody
title={ __( 'Dimensions', 'woo-gutenberg-products-block' ) }
Expand All @@ -144,15 +144,23 @@ const Edit = ( {
/>
</PanelBody>
</InspectorControls>
<EditorProvider currentView={ currentView }>
<InnerBlocks
allowedBlocks={ ALLOWED_BLOCKS }
template={ defaultTemplate }
templateLock={ false }
/>
</EditorProvider>
<MiniCartInnerBlocksStyle style={ blockProps.style } />
</div>
<div
className="wc-block-components-drawer__screen-overlay"
aria-hidden="true"
></div>
<div className="wc-block-editor-mini-cart-contents__wrapper">
<div { ...blockProps }>
<EditorProvider currentView={ currentView }>
<InnerBlocks
allowedBlocks={ ALLOWED_BLOCKS }
template={ defaultTemplate }
templateLock={ false }
/>
</EditorProvider>
<MiniCartInnerBlocksStyle style={ blockProps.style } />
</div>
</div>
</>
);
};

Expand Down
13 changes: 9 additions & 4 deletions assets/js/blocks/mini-cart/mini-cart-contents/editor.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
.editor-styles-wrapper .wp-block-woocommerce-mini-cart-contents {
/* We need to override the margin top here to simulate the layout of
the mini cart contents on the front end. */
margin: 0 auto !important;
// Extra classes added for specificity, so we get rid of a top margin added by GB.
.editor-styles-wrapper .wc-block-editor-mini-cart-contents__wrapper.wc-block-editor-mini-cart-contents__wrapper {
display: flex;
justify-content: center;
margin: 0;
position: relative;
z-index: 9999;
}

.editor-styles-wrapper .wp-block-woocommerce-mini-cart-contents {
.wp-block-woocommerce-empty-mini-cart-contents-block[hidden],
.wp-block-woocommerce-filled-mini-cart-contents-block[hidden] {
display: none;
Expand Down

0 comments on commit 2dc0a52

Please sign in to comment.