🎨 Minor code simplification

This commit is contained in:
Philipp Stracker 2025-01-23 13:32:26 +01:00
parent 7f861c5825
commit 00b720088a
No known key found for this signature in database
3 changed files with 30 additions and 38 deletions

View file

@ -1,23 +1,19 @@
import { ToggleControl } from '@wordpress/components';
import { Action, Description } from '../Elements';
const ControlToggleButton = ( { label, description, value, onChange } ) => {
const descriptionContent = description ? (
<Description>{ description }</Description>
) : null;
return (
<Action>
<ToggleControl
className="ppcp--control-toggle"
__nextHasNoMarginBottom={ true }
checked={ value }
onChange={ onChange }
label={ label }
help={ descriptionContent }
/>
</Action>
);
};
const ControlToggleButton = ( { label, description, value, onChange } ) => (
<Action>
<ToggleControl
className="ppcp--control-toggle"
__nextHasNoMarginBottom={ true }
checked={ value }
onChange={ onChange }
label={ label }
help={
description ? <Description>{ description }</Description> : null
}
/>
</Action>
);
export default ControlToggleButton;