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

Reuse useToolsPanelDropdownMenuProps util #64105

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Remove old utils
  • Loading branch information
SantosGuillamot authored and cbravobernal committed Aug 21, 2024
commit 1964e4f222564de7be4a1f8289eb6b2f719e08e0
14 changes: 0 additions & 14 deletions packages/block-editor/src/components/global-styles/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import fastDeepEqual from 'fast-deep-equal/es6';
/**
* WordPress dependencies
*/
import { useViewportMatch } from '@wordpress/compose';
import { getCSSValueFromRawStyle } from '@wordpress/style-engine';

/**
Expand Down Expand Up @@ -142,19 +141,6 @@ export const STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {
'typography.fontFamily': 'fontFamily',
};

export function useToolsPanelDropdownMenuProps() {
const isMobile = useViewportMatch( 'medium', '<' );
return ! isMobile
? {
popoverProps: {
placement: 'left-start',
// For non-mobile, inner sidebar width (248px) - button width (24px) - border (1px) + padding (16px) + spacing (20px)
offset: 259,
},
}
: {};
}

function findInPresetsBy(
features,
blockName,
Expand Down
13 changes: 13 additions & 0 deletions packages/block-editor/src/hooks/block-bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ import {
import { unlock } from '../lock-unlock';
import InspectorControls from '../components/inspector-controls';
import BlockContext from '../components/block-context';
<<<<<<< HEAD
import { useBlockBindingsUtils } from '../utils/block-bindings';
=======
import { useToolsPanelDropdownMenuProps } from '../utils/use-tools-panel-dropdown-menu-props';
>>>>>>> fcd2c19c62 (Remove old utils)

const {
DropdownMenuV2: DropdownMenu,
Expand All @@ -38,6 +42,7 @@ const {
DropdownMenuSeparatorV2: DropdownMenuSeparator,
} = unlock( componentsPrivateApis );

<<<<<<< HEAD
const useToolsPanelDropdownMenuProps = () => {
const isMobile = useViewportMatch( 'medium', '<' );
return ! isMobile
Expand All @@ -55,6 +60,14 @@ function BlockBindingsPanelDropdown( { fieldsList, attribute, binding } ) {
const { getBlockBindingsSources } = unlock( blocksPrivateApis );
const registeredSources = getBlockBindingsSources();
const { updateBlockBindings } = useBlockBindingsUtils();
=======
function BlockBindingsPanelDropdown( {
fieldsList,
addConnection,
attribute,
binding,
} ) {
>>>>>>> fcd2c19c62 (Remove old utils)
const currentKey = binding?.args?.key;
return (
<>
Expand Down
14 changes: 0 additions & 14 deletions packages/block-library/src/utils/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { useLayoutEffect, useEffect, useRef } from '@wordpress/element';
import { getBlobByURL, isBlobURL, revokeBlobURL } from '@wordpress/blob';
import { store as blockEditorStore } from '@wordpress/block-editor';
import { store as coreStore } from '@wordpress/core-data';
import { useViewportMatch } from '@wordpress/compose';

/**
* Returns whether the current user can edit the given entity.
Expand Down Expand Up @@ -88,16 +87,3 @@ export function useUploadMediaFromBlobURL( args = {} ) {
} );
}, [ getSettings ] );
}

export function useToolsPanelDropdownMenuProps() {
const isMobile = useViewportMatch( 'medium', '<' );
return ! isMobile
? {
popoverProps: {
placement: 'left-start',
// For non-mobile, inner sidebar width (248px) - button width (24px) - border (1px) + padding (16px) + spacing (20px)
offset: 259,
},
}
: {};
}