-
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.
Add initial pass at bindings panel in Block Inspector
- Loading branch information
1 parent
e993fd6
commit 74a900c
Showing
2 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
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
41 changes: 41 additions & 0 deletions
41
packages/block-editor/src/components/inspector-controls/bindings-panel.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,41 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { store as blocksStore } from '@wordpress/blocks'; | ||
import { | ||
PanelBody, | ||
__experimentalItemGroup as ItemGroup, | ||
__experimentalItem as Item, | ||
} from '@wordpress/components'; | ||
import { useSelect } from '@wordpress/data'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { unlock } from '../../lock-unlock'; | ||
|
||
export const BindingsPanel = ( { block } ) => { | ||
const bindings = block?.attributes?.metadata?.bindings; | ||
|
||
const sources = useSelect( ( select ) => | ||
unlock( select( blocksStore ) ).getAllBlockBindingsSources() | ||
); | ||
|
||
return ( | ||
<PanelBody title={ __( 'Bindings' ) }> | ||
<ItemGroup isBordered isSeparated size="large"> | ||
{ Object.keys( bindings ).map( ( key, index ) => { | ||
return ( | ||
<Item key={ index }> | ||
<div> | ||
{ key } :{ ' ' } | ||
{ sources[ bindings[ key ].source ].label } | ||
</div> | ||
</Item> | ||
); | ||
} ) } | ||
</ItemGroup> | ||
</PanelBody> | ||
); | ||
}; |