-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor inspector to use core's controls
- Loading branch information
1 parent
adc0b38
commit cf187c4
Showing
10 changed files
with
230 additions
and
240 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
packages/customize-widgets/src/components/block-inspector-button/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useMemo } from '@wordpress/element'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { MenuItem } from '@wordpress/components'; | ||
import { useSelect } from '@wordpress/data'; | ||
import { store as blockEditorStore } from '@wordpress/block-editor'; | ||
|
||
function BlockInspectorButton( { inspector, closeMenu, ...props } ) { | ||
const selectedBlockClientId = useSelect( | ||
( select ) => select( blockEditorStore ).getSelectedBlockClientId(), | ||
[] | ||
); | ||
|
||
const selectedBlock = useMemo( | ||
() => document.getElementById( `block-${ selectedBlockClientId }` ), | ||
[ selectedBlockClientId ] | ||
); | ||
|
||
return ( | ||
<MenuItem | ||
onClick={ () => { | ||
// Open the inspector. | ||
inspector.open( { | ||
returnFocusWhenClose: selectedBlock, | ||
} ); | ||
// Then close the dropdown menu. | ||
closeMenu(); | ||
} } | ||
{ ...props } | ||
> | ||
{ __( 'Show more settings' ) } | ||
</MenuItem> | ||
); | ||
} | ||
|
||
export default BlockInspectorButton; |
21 changes: 21 additions & 0 deletions
21
packages/customize-widgets/src/components/block-inspector-button/style.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#customize-theme-controls .customize-pane-child.accordion-section-content.customize-widgets-layout__inspector { | ||
background: $white; | ||
box-sizing: border-box; | ||
|
||
* { | ||
box-sizing: inherit; | ||
} | ||
|
||
.block-editor-block-inspector { | ||
margin: -$grid-unit-15; | ||
|
||
// To override the style in block-editor/block-inspector. | ||
h3 { | ||
margin-bottom: 0; | ||
} | ||
} | ||
} | ||
|
||
#customize-theme-controls .customize-pane-child.control-section-sidebar.is-sub-section-open { | ||
transform: translateX(-100%); | ||
} |
15 changes: 0 additions & 15 deletions
15
packages/customize-widgets/src/components/inspector/block-inspector-button.js
This file was deleted.
Oops, something went wrong.
122 changes: 0 additions & 122 deletions
122
packages/customize-widgets/src/components/inspector/index.js
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
packages/customize-widgets/src/components/inspector/style.scss
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.