Skip to content

Commit

Permalink
refactor: replace type control with wp toggleGroupControl
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaHungDinh committed Apr 15, 2024
1 parent 9623b44 commit 8522ad3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {BaseControl} from '@wordpress/components';
import {__} from '@wordpress/i18n';
import cx from 'classnames';
import './styles.scss';
import {
__experimentalToggleGroupControl as ToggleGroupControl,
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
} from '@wordpress/components';

type DonationTypeControlProps = {
priceOption: string;
Expand All @@ -19,41 +20,20 @@ export default function DonationTypeControl({priceOption, setAttributes, attribu
};

return (
<BaseControl
id={'givewp-donation-type-controls'}
<ToggleGroupControl
__nextHasNoMarginBottom
isBlock
label={__('Donation Type', 'give')}
onChange={handleTypeChange}
value={priceOption}
help={
'multi' === priceOption
? __('Set multiple price donations for this form.', 'give')
: __('The donation amount is fixed to the following amount:', 'give')
}
>
<div className={'givewp-donation-type-control'}>
<label
className={cx('givewp-donation-type-control__multi', {
['givewp-donation-type-control__multi--selected']: priceOption === 'multi',
})}
>
{__('Multi-level', 'give')}
<input
className={'givewp-donation-type-control__multi__input'}
type={'checkbox'}
onChange={() => handleTypeChange('multi')}
/>
</label>
<label
className={cx('givewp-donation-type-control__set', {
['givewp-donation-type-control__set--selected']: priceOption === 'set',
})}
>
{__('Fixed', 'give')}
<input
className={'givewp-donation-type-control__set__input'}
type={'checkbox'}
onChange={() => handleTypeChange('set')}
/>
</label>
</div>
</BaseControl>
<ToggleGroupControlOption label={__('Multi-level', 'give')} value="multi" />
<ToggleGroupControlOption label={__('Fixed', 'give')} value="set" />
</ToggleGroupControl>
);
}

This file was deleted.

0 comments on commit 8522ad3

Please sign in to comment.