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

BoxControl: Add custom units #27626

Merged
merged 2 commits into from
Dec 14, 2020
Merged
Changes from all commits
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
8 changes: 6 additions & 2 deletions packages/block-editor/src/hooks/padding.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { __experimentalBoxControl as BoxControl } from '@wordpress/components';
* Internal dependencies
*/
import { cleanEmptyObject } from './utils';
import { useCustomUnits } from '../components/unit-control';
import useEditorFeature from '../components/use-editor-feature';

export const SPACING_SUPPORT_KEY = 'spacing';

Expand All @@ -33,7 +33,11 @@ export function PaddingEdit( props ) {
setAttributes,
} = props;

const units = useCustomUnits();
const customUnits = useEditorFeature( 'spacing.units' );
const units = customUnits?.map( ( unit ) => ( {
value: unit,
label: unit,
} ) );

if ( ! hasPaddingSupport( blockName ) ) {
return null;
Expand Down