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

Remove the ToggleButtonControl in favor of ToggleGroupControl #5967

Merged
merged 4 commits into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
93 changes: 48 additions & 45 deletions assets/js/atomic/blocks/product-elements/image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { Disabled, PanelBody, ToggleControl } from '@wordpress/components';
import {
Disabled,
PanelBody,
ToggleControl,
__experimentalToggleGroupControl as ToggleGroupControl,
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
} from '@wordpress/components';
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
import { createInterpolateElement } from '@wordpress/element';
import ToggleButtonControl from '@woocommerce/editor-components/toggle-button-control';
import { getAdminLink } from '@woocommerce/settings';

/**
Expand Down Expand Up @@ -64,41 +69,40 @@ const Edit = ( { attributes, setAttributes } ) => {
}
/>
{ showSaleBadge && (
<ToggleButtonControl
<ToggleGroupControl
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>
) }
<ToggleButtonControl
<ToggleGroupControl
label={ __(
'Image Sizing',
'woo-gutenberg-products-block'
Expand All @@ -122,26 +126,25 @@ const Edit = ( { attributes, setAttributes } ) => {
}
) }
value={ imageSizing }
options={ [
{
label: __(
'Full Size',
'woo-gutenberg-products-block'
),
value: 'full-size',
},
{
label: __(
'Cropped',
'woo-gutenberg-products-block'
),
value: 'cropped',
},
] }
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>
</PanelBody>
</InspectorControls>
<Disabled>
Expand Down
45 changes: 24 additions & 21 deletions assets/js/blocks/active-filters/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
*/
import { __ } from '@wordpress/i18n';
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
import { Disabled, PanelBody, withSpokenMessages } from '@wordpress/components';
import {
Disabled,
PanelBody,
withSpokenMessages,
__experimentalToggleGroupControl as ToggleGroupControl,
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
} from '@wordpress/components';
import HeadingToolbar from '@woocommerce/editor-components/heading-toolbar';
import BlockTitle from '@woocommerce/editor-components/block-title';
import ToggleButtonControl from '@woocommerce/editor-components/toggle-button-control';

/**
* Internal dependencies
Expand All @@ -29,35 +34,33 @@ const Edit = ( { attributes, setAttributes } ) => {
'woo-gutenberg-products-block'
) }
>
<ToggleButtonControl
<ToggleGroupControl
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 ) =>
setAttributes( {
displayStyle: value,
} )
}
/>
>
<ToggleGroupControlOption
value="list"
label={ __(
'List',
'woo-gutenberg-products-block'
) }
/>
<ToggleGroupControlOption
value="chips"
label={ __(
'Chips',
'woo-gutenberg-products-block'
) }
/>
</ToggleGroupControl>
<p>
{ __(
'Heading Level',
Expand Down
70 changes: 33 additions & 37 deletions assets/js/blocks/attribute-filter/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ import {
Button,
ToolbarGroup,
withSpokenMessages,
__experimentalToggleGroupControl as ToggleGroupControl,
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
} from '@wordpress/components';
import { Icon, category, external } from '@wordpress/icons';
import { SearchListControl } from '@woocommerce/editor-components/search-list-control';
import { mapValues, toArray, sortBy } from 'lodash';
import { getAdminLink, getSetting } from '@woocommerce/settings';
import HeadingToolbar from '@woocommerce/editor-components/heading-toolbar';
import BlockTitle from '@woocommerce/editor-components/block-title';
import ToggleButtonControl from '@woocommerce/editor-components/toggle-button-control';
import classnames from 'classnames';

/**
Expand Down Expand Up @@ -121,7 +122,7 @@ const Edit = ( { attributes, setAttributes, debouncedSpeak } ) => {
'woo-gutenberg-products-block'
) }
>
<ToggleButtonControl
<ToggleGroupControl
label={ __(
'Query Type',
'woo-gutenberg-products-block'
Expand All @@ -138,56 +139,51 @@ const Edit = ( { attributes, setAttributes, debouncedSpeak } ) => {
)
}
value={ queryType }
options={ [
{
label: __(
'And',
'woo-gutenberg-products-block'
),
value: 'and',
},
{
label: __(
'Or',
'woo-gutenberg-products-block'
),
value: 'or',
},
] }
onChange={ ( value ) =>
setAttributes( {
queryType: value,
} )
}
/>
<ToggleButtonControl
>
<ToggleGroupControlOption
value="and"
label={ __(
'And',
'woo-gutenberg-products-block'
) }
/>
<ToggleGroupControlOption
value="or"
label={ __( 'Or', 'woo-gutenberg-products-block' ) }
/>
</ToggleGroupControl>
<ToggleGroupControl
label={ __(
'Display Style',
'woo-gutenberg-products-block'
) }
value={ displayStyle }
options={ [
{
label: __(
'List',
'woo-gutenberg-products-block'
),
value: 'list',
},
{
label: __(
'Dropdown',
'woo-gutenberg-products-block'
),
value: 'dropdown',
},
] }
onChange={ ( value ) =>
setAttributes( {
displayStyle: value,
} )
}
/>
>
<ToggleGroupControlOption
value="list"
label={ __(
'List',
'woo-gutenberg-products-block'
) }
/>
<ToggleGroupControlOption
value="dropdown"
label={ __(
'Dropdown',
'woo-gutenberg-products-block'
) }
/>
</ToggleGroupControl>
<ToggleControl
label={ __(
'Filter button',
Expand Down
38 changes: 19 additions & 19 deletions assets/js/blocks/price-filter/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import {
PanelBody,
ToggleControl,
Button,
__experimentalToggleGroupControl as ToggleGroupControl,
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
} from '@wordpress/components';
import { getAdminLink } from '@woocommerce/settings';
import { blocksConfig } from '@woocommerce/block-settings';
import HeadingToolbar from '@woocommerce/editor-components/heading-toolbar';
import BlockTitle from '@woocommerce/editor-components/block-title';
import ToggleButtonControl from '@woocommerce/editor-components/toggle-button-control';
import { Icon, currencyDollar, external } from '@wordpress/icons';

/**
Expand Down Expand Up @@ -42,34 +43,33 @@ export default function ( { attributes, setAttributes } ) {
'woo-gutenberg-products-block'
) }
>
<ToggleButtonControl
<ToggleGroupControl
label={ __(
'Price Range',
'woo-gutenberg-products-block'
) }
value={ showInputFields ? 'editable' : 'text' }
options={ [
{
label: __(
'Editable',
'woo-gutenberg-products-block'
),
value: 'editable',
},
{
label: __(
'Text',
'woo-gutenberg-products-block'
),
value: 'text',
},
] }
onChange={ ( value ) =>
setAttributes( {
showInputFields: value === 'editable',
} )
}
/>
>
<ToggleGroupControlOption
value="editable"
label={ __(
'Editable',
'woo-gutenberg-products-block'
) }
/>
<ToggleGroupControlOption
value="text"
label={ __(
'Text',
'woo-gutenberg-products-block'
) }
/>
</ToggleGroupControl>
<ToggleControl
label={ __(
'Filter button',
Expand Down
Loading