Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PanelBody for InspectorControls #33227

Merged
merged 1 commit into from
Jul 6, 2021
Merged
Changes from all 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
198 changes: 104 additions & 94 deletions packages/block-editor/src/components/inspector-controls/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ var el = wp.element.createElement,
RadioControl = wp.components.RadioControl,
TextControl = wp.components.TextControl,
ToggleControl = wp.components.ToggleControl,
SelectControl = wp.components.SelectControl;
SelectControl = wp.components.SelectControl,
PanelBody = wp.components.PanelBody;

registerBlockType( 'my-plugin/inspector-controls-example', {
apiVersion: 2,
Expand Down Expand Up @@ -96,58 +97,64 @@ registerBlockType( 'my-plugin/inspector-controls-example', {
el(
InspectorControls,
null,
el( CheckboxControl, {
heading: 'Checkbox Field',
label: 'Tick Me',
help: 'Additional help text',
checked: checkboxField,
onChange: onChangeCheckboxField,
} ),
el( RadioControl, {
label: 'Radio Field',
selected: radioField,
options: [
{
label: 'Yes',
value: 'yes',
},
{
label: 'No',
value: 'no',
},
],
onChange: onChangeRadioField,
} ),
el( TextControl, {
label: 'Text Field',
help: 'Additional help text',
value: textField,
onChange: onChangeTextField,
} ),
el( ToggleControl, {
label: 'Toggle Field',
checked: toggleField,
onChange: onChangeToggleField,
} ),
el( SelectControl, {
label: 'Select Field',
value: selectField,
options: [
{
value: 'a',
label: 'Option A',
},
{
value: 'b',
label: 'Option B',
},
{
value: 'c',
label: 'Option C',
},
],
onChange: onChangeSelectField,
} )
el(
PanelBody,
{
title: 'Settings',
},
el( CheckboxControl, {
heading: 'Checkbox Field',
label: 'Tick Me',
help: 'Additional help text',
checked: checkboxField,
onChange: onChangeCheckboxField,
} ),
el( RadioControl, {
label: 'Radio Field',
selected: radioField,
options: [
{
label: 'Yes',
value: 'yes',
},
{
label: 'No',
value: 'no',
},
],
onChange: onChangeRadioField,
} ),
el( TextControl, {
label: 'Text Field',
help: 'Additional help text',
value: textField,
onChange: onChangeTextField,
} ),
el( ToggleControl, {
label: 'Toggle Field',
checked: toggleField,
onChange: onChangeToggleField,
} ),
el( SelectControl, {
label: 'Select Field',
value: selectField,
options: [
{
value: 'a',
label: 'Option A',
},
{
value: 'b',
label: 'Option B',
},
{
value: 'c',
label: 'Option C',
},
],
onChange: onChangeSelectField,
} )
)
),
el(
RichText,
Expand Down Expand Up @@ -202,6 +209,7 @@ import {
TextControl,
ToggleControl,
SelectControl,
PanelBody
} from '@wordpress/components';
import {
RichText,
Expand Down Expand Up @@ -281,47 +289,49 @@ registerBlockType( 'my-plugin/inspector-controls-example', {
return (
<>
<InspectorControls>
<CheckboxControl
heading="Checkbox Field"
label="Tick Me"
help="Additional help text"
checked={ checkboxField }
onChange={ onChangeCheckboxField }
/>

<RadioControl
label="Radio Field"
selected={ radioField }
options={ [
{ label: 'Yes', value: 'yes' },
{ label: 'No', value: 'no' },
] }
onChange={ onChangeRadioField }
/>

<TextControl
label="Text Field"
help="Additional help text"
value={ textField }
onChange={ onChangeTextField }
/>

<ToggleControl
label="Toggle Field"
checked={ toggleField }
onChange={ onChangeToggleField }
/>

<SelectControl
label="Select Control"
value={ selectField }
options={ [
{ value: 'a', label: 'Option A' },
{ value: 'b', label: 'Option B' },
{ value: 'c', label: 'Option C' },
] }
onChange={ onChangeSelectField }
/>
<PanelBody title={__('Settings')}>
<CheckboxControl
heading="Checkbox Field"
label="Tick Me"
help="Additional help text"
checked={ checkboxField }
onChange={ onChangeCheckboxField }
/>

<RadioControl
label="Radio Field"
selected={ radioField }
options={ [
{ label: 'Yes', value: 'yes' },
{ label: 'No', value: 'no' },
] }
onChange={ onChangeRadioField }
/>

<TextControl
label="Text Field"
help="Additional help text"
value={ textField }
onChange={ onChangeTextField }
/>

<ToggleControl
label="Toggle Field"
checked={ toggleField }
onChange={ onChangeToggleField }
/>

<SelectControl
label="Select Control"
value={ selectField }
options={ [
{ value: 'a', label: 'Option A' },
{ value: 'b', label: 'Option B' },
{ value: 'c', label: 'Option C' },
] }
onChange={ onChangeSelectField }
/>
</PanelBody>
</InspectorControls>

<RichText
Expand Down