Skip to content

Commit bae6236

Browse files
Infinite-NullInfinite-Nullfabiankaegy
authored
Refactor "Settings" panel of Login/Logour block to use ToolsPanel instead of PanelBody (#67909)
Co-authored-by: Infinite-Null <ankitkumarshah@git.wordpress.org> Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
1 parent afb6752 commit bae6236

File tree

1 file changed

+50
-20
lines changed
  • packages/block-library/src/loginout

1 file changed

+50
-20
lines changed

packages/block-library/src/loginout/edit.js

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,68 @@
11
/**
22
* WordPress dependencies
33
*/
4-
import { PanelBody, ToggleControl } from '@wordpress/components';
5-
import { __ } from '@wordpress/i18n';
64
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
5+
import {
6+
ToggleControl,
7+
__experimentalToolsPanel as ToolsPanel,
8+
__experimentalToolsPanelItem as ToolsPanelItem,
9+
} from '@wordpress/components';
10+
import { __ } from '@wordpress/i18n';
711

812
export default function LoginOutEdit( { attributes, setAttributes } ) {
913
const { displayLoginAsForm, redirectToCurrent } = attributes;
1014

1115
return (
1216
<>
1317
<InspectorControls>
14-
<PanelBody title={ __( 'Settings' ) }>
15-
<ToggleControl
16-
__nextHasNoMarginBottom
18+
<ToolsPanel
19+
label={ __( 'Settings' ) }
20+
resetAll={ () => {
21+
setAttributes( {
22+
displayLoginAsForm: false,
23+
redirectToCurrent: true,
24+
} );
25+
} }
26+
>
27+
<ToolsPanelItem
1728
label={ __( 'Display login as form' ) }
18-
checked={ displayLoginAsForm }
19-
onChange={ () =>
20-
setAttributes( {
21-
displayLoginAsForm: ! displayLoginAsForm,
22-
} )
29+
isShownByDefault
30+
hasValue={ () => displayLoginAsForm }
31+
onDeselect={ () =>
32+
setAttributes( { displayLoginAsForm: false } )
2333
}
24-
/>
25-
<ToggleControl
26-
__nextHasNoMarginBottom
34+
>
35+
<ToggleControl
36+
__nextHasNoMarginBottom
37+
label={ __( 'Display login as form' ) }
38+
checked={ displayLoginAsForm }
39+
onChange={ () =>
40+
setAttributes( {
41+
displayLoginAsForm: ! displayLoginAsForm,
42+
} )
43+
}
44+
/>
45+
</ToolsPanelItem>
46+
<ToolsPanelItem
2747
label={ __( 'Redirect to current URL' ) }
28-
checked={ redirectToCurrent }
29-
onChange={ () =>
30-
setAttributes( {
31-
redirectToCurrent: ! redirectToCurrent,
32-
} )
48+
isShownByDefault
49+
hasValue={ () => ! redirectToCurrent }
50+
onDeselect={ () =>
51+
setAttributes( { redirectToCurrent: true } )
3352
}
34-
/>
35-
</PanelBody>
53+
>
54+
<ToggleControl
55+
__nextHasNoMarginBottom
56+
label={ __( 'Redirect to current URL' ) }
57+
checked={ redirectToCurrent }
58+
onChange={ () =>
59+
setAttributes( {
60+
redirectToCurrent: ! redirectToCurrent,
61+
} )
62+
}
63+
/>
64+
</ToolsPanelItem>
65+
</ToolsPanel>
3666
</InspectorControls>
3767
<div
3868
{ ...useBlockProps( {

0 commit comments

Comments
 (0)