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

Commit

Permalink
Mini Cart Contents block: allow changing the width only in the featur…
Browse files Browse the repository at this point in the history
…e plugin
  • Loading branch information
Aljullu committed Apr 25, 2023
1 parent 697b17c commit 7ae66fb
Showing 1 changed file with 33 additions and 27 deletions.
60 changes: 33 additions & 27 deletions assets/js/blocks/mini-cart/mini-cart-contents/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
InspectorControls,
} from '@wordpress/block-editor';
import { EditorProvider } from '@woocommerce/base-context';
import { isFeaturePluginBuild } from '@woocommerce/block-settings';
import type { TemplateArray } from '@wordpress/blocks';
import { useEffect } from '@wordpress/element';
import type { FocusEvent, ReactElement } from 'react';
Expand Down Expand Up @@ -125,33 +126,38 @@ const Edit = ( {

return (
<>
<InspectorControls key="inspector">
<PanelBody
title={ __( 'Dimensions', 'woo-gutenberg-products-block' ) }
initialOpen
>
<UnitControl
onChange={ ( value ) => {
setAttributes( { width: value } );
} }
onBlur={ ( e: FocusEvent< HTMLInputElement > ) => {
if ( Number( e.target.value ) < MIN_WIDTH ) {
setAttributes( {
width: MIN_WIDTH,
} );
}
} }
value={ width }
units={ [
{
value: 'px',
label: 'px',
default: defaultAttributes.width.default,
},
] }
/>
</PanelBody>
</InspectorControls>
{ isFeaturePluginBuild() && (
<InspectorControls key="inspector">
<PanelBody
title={ __(
'Dimensions',
'woo-gutenberg-products-block'
) }
initialOpen
>
<UnitControl
onChange={ ( value ) => {
setAttributes( { width: value } );
} }
onBlur={ ( e: FocusEvent< HTMLInputElement > ) => {
if ( Number( e.target.value ) < MIN_WIDTH ) {
setAttributes( {
width: MIN_WIDTH,
} );
}
} }
value={ width }
units={ [
{
value: 'px',
label: 'px',
default: defaultAttributes.width.default,
},
] }
/>
</PanelBody>
</InspectorControls>
) }
<div
className="wc-block-components-drawer__screen-overlay"
aria-hidden="true"
Expand Down

0 comments on commit 7ae66fb

Please sign in to comment.