Skip to content
Merged
Prev Previous commit
Next Next commit
Move get label function to the useBlockDisplayInformation file
  • Loading branch information
andrewserong committed Jun 1, 2023
commit 434080580df760229ee4125930900e06efcd94ef
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import {
isReusableBlock,
isTemplatePart,
} from '@wordpress/blocks';
import { __ } from '@wordpress/i18n';

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

/** @typedef {import('@wordpress/blocks').WPIcon} WPIcon */

Expand All @@ -28,6 +28,26 @@ import { getPositionTypeLabel } from '../../hooks/position';
* @property {string} anchor HTML anchor.
*/

/**
* Get the display label for a block's position type.
*
* @param {Object} attributes Block attributes.
* @return {string} The position type label.
*/
function getPositionTypeLabel( attributes ) {
const positionType = attributes.style?.position?.type;

if ( positionType === 'sticky' ) {
return __( 'Sticky' );
}

if ( positionType === 'fixed' ) {
return __( 'Fixed' );
}

return null;
}

/**
* Hook used to try to find a matching block variation and return
* the appropriate information for display reasons. In order to
Expand Down
20 changes: 0 additions & 20 deletions packages/block-editor/src/hooks/position.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,26 +104,6 @@ export function getPositionCSS( { selector, style } ) {
return output;
}

/**
* Get the display label for a block's position type.
*
* @param {Object} attributes Block attributes.
* @return {string} The position type label.
*/
export function getPositionTypeLabel( attributes ) {
const positionType = attributes.style?.position?.type;

if ( positionType === 'sticky' ) {
return __( 'Sticky' );
}

if ( positionType === 'fixed' ) {
return __( 'Fixed' );
}

return null;
}

/**
* Determines if there is sticky position support.
*
Expand Down