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

Display Mini Cart overlay in template part editor #9014

Merged
merged 1 commit into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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