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

Add back ToggleButtonControl component in WC Blocks 8.9 so it supports WP 5.9 #8101

Merged
merged 5 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
95 changes: 45 additions & 50 deletions assets/js/atomic/blocks/product-elements/image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,8 @@ import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
import { createInterpolateElement, useEffect } from '@wordpress/element';
import { getAdminLink, getSettingWithCoercion } from '@woocommerce/settings';
import { isBoolean } from '@woocommerce/types';
import {
Disabled,
PanelBody,
ToggleControl,
// eslint-disable-next-line @wordpress/no-unsafe-wp-apis
__experimentalToggleGroupControl as ToggleGroupControl,
// eslint-disable-next-line @wordpress/no-unsafe-wp-apis
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
} from '@wordpress/components';
import { Disabled, PanelBody, ToggleControl } from '@wordpress/components';
import ToggleButtonControl from '@woocommerce/editor-components/toggle-button-control';

/**
* Internal dependencies
Expand Down Expand Up @@ -85,41 +78,42 @@ const Edit = ( { attributes, setAttributes, context } ) => {
}
/>
{ showSaleBadge && (
<ToggleGroupControl
<ToggleButtonControl
label={ __(
'Sale Badge Alignment',
'woo-gutenberg-products-block'
) }
value={ saleBadgeAlign }
options={ [
{
label: __(
'Left',
'woo-gutenberg-products-block'
),
value: 'left',
},
{
label: __(
'Center',
'woo-gutenberg-products-block'
),
value: 'center',
},
{
label: __(
'Right',
'woo-gutenberg-products-block'
),
value: 'right',
},
] }
onChange={ ( value ) =>
setAttributes( { saleBadgeAlign: value } )
}
>
<ToggleGroupControlOption
value="left"
label={ __(
'Left',
'woo-gutenberg-products-block'
) }
/>
<ToggleGroupControlOption
value="center"
label={ __(
'Center',
'woo-gutenberg-products-block'
) }
/>
<ToggleGroupControlOption
value="right"
label={ __(
'Right',
'woo-gutenberg-products-block'
) }
/>
</ToggleGroupControl>
/>
) }
{ ! isBlockThemeEnabled && (
<ToggleGroupControl
<ToggleButtonControl
label={ __(
'Image Sizing',
'woo-gutenberg-products-block'
Expand All @@ -146,22 +140,23 @@ const Edit = ( { attributes, setAttributes, context } ) => {
onChange={ ( value ) =>
setAttributes( { imageSizing: value } )
}
>
<ToggleGroupControlOption
value="full-size"
label={ __(
'Full Size',
'woo-gutenberg-products-block'
) }
/>
<ToggleGroupControlOption
value="cropped"
label={ __(
'Cropped',
'woo-gutenberg-products-block'
) }
/>
</ToggleGroupControl>
options={ [
{
label: __(
'Full Size',
'woo-gutenberg-products-block'
),
value: 'full-size',
},
{
label: __(
'Cropped',
'woo-gutenberg-products-block'
),
value: 'cropped',
},
] }
/>
) }
</PanelBody>
</InspectorControls>
Expand Down
47 changes: 21 additions & 26 deletions assets/js/blocks/active-filters/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,8 @@ import { __ } from '@wordpress/i18n';
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
import type { BlockEditProps } from '@wordpress/blocks';
import BlockTitle from '@woocommerce/editor-components/block-title';
import {
Disabled,
PanelBody,
withSpokenMessages,
// eslint-disable-next-line @wordpress/no-unsafe-wp-apis
__experimentalToggleGroupControl as ToggleGroupControl,
// eslint-disable-next-line @wordpress/no-unsafe-wp-apis
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
} from '@wordpress/components';
import { Disabled, PanelBody, withSpokenMessages } from '@wordpress/components';
import ToggleButtonControl from '@woocommerce/editor-components/toggle-button-control';

/**
* Internal dependencies
Expand Down Expand Up @@ -43,34 +36,36 @@ const Edit = ( {
'woo-gutenberg-products-block'
) }
>
<ToggleGroupControl
<ToggleButtonControl
label={ __(
'Display Style',
'woo-gutenberg-products-block'
) }
value={ displayStyle }
options={ [
{
label: __(
'List',
'woo-gutenberg-products-block'
),
value: 'list',
},
{
/* translators: "Chips" is a tag-like display style for chosen attributes. */
label: __(
'Chips',
'woo-gutenberg-products-block'
),
value: 'chips',
},
] }
onChange={ ( value: Attributes[ 'displayStyle' ] ) =>
setAttributes( {
displayStyle: value,
} )
}
className="wc-block-active-filter__style-toggle"
>
<ToggleGroupControlOption
value="list"
label={ __(
'List',
'woo-gutenberg-products-block'
) }
/>
<ToggleGroupControlOption
value="chips"
label={ __(
'Chips',
'woo-gutenberg-products-block'
) }
/>
</ToggleGroupControl>
/>
</PanelBody>
</InspectorControls>
);
Expand Down
110 changes: 55 additions & 55 deletions assets/js/blocks/attribute-filter/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@ import {
Button,
ToolbarGroup,
withSpokenMessages,
// eslint-disable-next-line @wordpress/no-unsafe-wp-apis
__experimentalToggleGroupControl as ToggleGroupControl,
// eslint-disable-next-line @wordpress/no-unsafe-wp-apis
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
} from '@wordpress/components';
import ToggleButtonControl from '@woocommerce/editor-components/toggle-button-control';

/**
* Internal dependencies
Expand Down Expand Up @@ -181,36 +178,37 @@ const Edit = ( {
} )
}
/>
<ToggleGroupControl
<ToggleButtonControl
label={ __(
'Allow selecting multiple options?',
'woo-gutenberg-products-block'
) }
value={ selectType || 'multiple' }
options={ [
{
label: __(
'Multiple',
'woo-gutenberg-products-block'
),
value: 'multiple',
},
{
label: __(
'Single',
'woo-gutenberg-products-block'
),
value: 'single',
},
] }
onChange={ ( value: string ) =>
setAttributes( {
selectType: value,
} )
}
className="wc-block-attribute-filter__multiple-toggle"
>
<ToggleGroupControlOption
value="multiple"
label={ __(
'Multiple',
'woo-gutenberg-products-block'
) }
/>
<ToggleGroupControlOption
value="single"
label={ __(
'Single',
'woo-gutenberg-products-block'
) }
/>
</ToggleGroupControl>
/>
{ selectType === 'multiple' && (
<ToggleGroupControl
<ToggleButtonControl
label={ __(
'Filter Conditions',
'woo-gutenberg-products-block'
Expand All @@ -232,25 +230,26 @@ const Edit = ( {
queryType: value,
} )
}
options={ [
{
label: __(
'All',
'woo-gutenberg-products-block'
),
value: 'and',
},
{
label: __(
'Any',
'woo-gutenberg-products-block'
),
value: 'or',
},
] }
className="wc-block-attribute-filter__conditions-toggle"
>
<ToggleGroupControlOption
value="and"
label={ __(
'All',
'woo-gutenberg-products-block'
) }
/>
<ToggleGroupControlOption
value="or"
label={ __(
'Any',
'woo-gutenberg-products-block'
) }
/>
</ToggleGroupControl>
/>
) }
<ToggleGroupControl
<ToggleButtonControl
label={ __(
'Display Style',
'woo-gutenberg-products-block'
Expand All @@ -261,23 +260,24 @@ const Edit = ( {
displayStyle: value,
} )
}
options={ [
{
label: __(
'List',
'woo-gutenberg-products-block'
),
value: 'list',
},
{
label: __(
'Dropdown',
'woo-gutenberg-products-block'
),
value: 'dropdown',
},
] }
className="wc-block-attribute-filter__display-toggle"
>
<ToggleGroupControlOption
value="list"
label={ __(
'List',
'woo-gutenberg-products-block'
) }
/>
<ToggleGroupControlOption
value="dropdown"
label={ __(
'Dropdown',
'woo-gutenberg-products-block'
) }
/>
</ToggleGroupControl>
/>
<ToggleControl
label={ __(
"Show 'Apply filters' button",
Expand Down
Loading