From c3d19a18b66085a1cb994073c5b75d560f5281a1 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Tue, 10 Dec 2024 18:41:53 +0900 Subject: [PATCH] ChildLayoutControl: Use units defined in theme.json --- .../src/components/child-layout-control/index.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/block-editor/src/components/child-layout-control/index.js b/packages/block-editor/src/components/child-layout-control/index.js index 022acf2e1074a4..20791d9751bcd4 100644 --- a/packages/block-editor/src/components/child-layout-control/index.js +++ b/packages/block-editor/src/components/child-layout-control/index.js @@ -9,6 +9,7 @@ import { __experimentalHStack as HStack, __experimentalVStack as VStack, __experimentalToolsPanelItem as ToolsPanelItem, + __experimentalUseCustomUnits as useCustomUnits, Flex, FlexItem, } from '@wordpress/components'; @@ -21,6 +22,7 @@ import { useSelect, useDispatch } from '@wordpress/data'; */ import { useGetNumberOfBlocksBeforeCell } from '../grid/use-get-number-of-blocks-before-cell'; import { store as blockEditorStore } from '../../store'; +import { useSettings } from '../use-settings'; function helpText( selfStretch, parentLayout ) { const { orientation = 'horizontal' } = parentLayout; @@ -98,6 +100,17 @@ function FlexControls( { const hasFlexValue = () => !! selfStretch; const flexResetLabel = orientation === 'horizontal' ? __( 'Width' ) : __( 'Height' ); + const [ availableUnits ] = useSettings( 'spacing.units' ); + const units = useCustomUnits( { + availableUnits: availableUnits || [ + '%', + 'px', + 'em', + 'rem', + 'vh', + 'vw', + ], + } ); const resetFlex = () => { onChange( { selfStretch: undefined, @@ -167,6 +180,7 @@ function FlexControls( { { selfStretch === 'fixed' && ( { onChange( { selfStretch,