Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
6bcef66
Add BlockControlsFirst slot to block controls groups
michalczaplinski Feb 19, 2024
3d6fe72
Add connection icon to BlockControls toolbar button
michalczaplinski Feb 19, 2024
385b13c
Add block binding toolbar button if block is connected to a source
michalczaplinski Feb 19, 2024
44b1c72
Add i18n support for block toolbar button label
michalczaplinski Feb 21, 2024
91c78a4
Add BlockBindingsButton component and remove BlockControlsFirst group
michalczaplinski Feb 21, 2024
be8afcd
Refactor BlockBindingsButton to check for block connections
michalczaplinski Feb 22, 2024
1c51cc2
Change the ToolbarButton label
michalczaplinski Feb 22, 2024
752dcc3
Update block-bindings-button import to block-bindings-indicator
michalczaplinski Feb 22, 2024
bbdd7bf
Block Bindings: Add connection icon to list view (#59331)
artemiomorales Feb 26, 2024
3bc3062
Move bindings style to useBlockProps
artemiomorales Feb 27, 2024
9d6f97c
Remove extraneous comment
artemiomorales Feb 27, 2024
ec3885d
Move bindings selector logic to toolbar
artemiomorales Feb 28, 2024
d9a4b88
Rename indicator file
artemiomorales Feb 28, 2024
d571f82
Move purple stroke style from SVG markup to CSS
artemiomorales Feb 28, 2024
6cd25eb
Merge branch 'trunk' into fix/update-block-bindings-ui-indicator
artemiomorales Feb 28, 2024
ac72c0a
Check if block can be bound before adding styles
artemiomorales Feb 28, 2024
f63e4ef
Simplify the SVG icon:
michalczaplinski Feb 29, 2024
3f9fa3b
Update the CSS namespacing to include the `__`
michalczaplinski Feb 29, 2024
4dc1103
Fix issues with block binding indicator color
michalczaplinski Feb 29, 2024
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
Prev Previous commit
Next Next commit
Move bindings selector logic to toolbar
  • Loading branch information
artemiomorales committed Feb 28, 2024
commit ec3885dcca2e3c851f6b1dd3a2461a8f8e300c91
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,11 @@
* WordPress dependencies
*/
import { ToolbarItem, ToolbarGroup, Icon } from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import { connection } from '@wordpress/icons';
import { _x } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import { store as blockEditorStore } from '../../store';

export default function BlockBindingsIndicator( { clientId } ) {
const isConnected = useSelect(
( select ) => {
const attributes =
select( blockEditorStore ).getBlockAttributes( clientId );

return !! attributes?.metadata?.bindings;
},
[ clientId ]
);

return isConnected ? (
export default function BlockBindingsIndicator() {
return (
<ToolbarGroup>
<ToolbarItem
as={ 'div' }
Expand All @@ -32,5 +16,5 @@ export default function BlockBindingsIndicator( { clientId } ) {
<Icon icon={ connection } size={ 24 } />
</ToolbarItem>
</ToolbarGroup>
) : null;
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export function PrivateBlockToolbar( {
blockType,
shouldShowVisualToolbar,
showParentSelector,
isUsingBindings,
} = useSelect( ( select ) => {
const {
getBlockName,
Expand All @@ -73,6 +74,7 @@ export function PrivateBlockToolbar( {
isBlockValid,
getBlockRootClientId,
getBlockEditingMode,
getBlockAttributes,
} = select( blockEditorStore );
const selectedBlockClientIds = getSelectedBlockClientIds();
const selectedBlockClientId = selectedBlockClientIds[ 0 ];
Expand All @@ -89,6 +91,8 @@ export function PrivateBlockToolbar( {
const isVisual = selectedBlockClientIds.every(
( id ) => getBlockMode( id ) === 'visual'
);
const _isUsingBindings = !! getBlockAttributes( selectedBlockClientId )
?.metadata?.bindings;
return {
blockClientId: selectedBlockClientId,
blockClientIds: selectedBlockClientIds,
Expand All @@ -109,6 +113,7 @@ export function PrivateBlockToolbar( {
) &&
selectedBlockClientIds.length === 1 &&
_isDefaultEditingMode,
isUsingBindings: _isUsingBindings,
};
}, [] );

Expand Down Expand Up @@ -167,7 +172,7 @@ export function PrivateBlockToolbar( {
{ ! isMultiToolbar &&
isLargeViewport &&
isDefaultEditingMode && <BlockParentSelector /> }
<BlockBindingsIndicator clientId={ blockClientId } />
{ isUsingBindings && <BlockBindingsIndicator /> }
{ ( shouldShowVisualToolbar || isMultiToolbar ) &&
isDefaultEditingMode && (
<div
Expand Down