Skip to content

Commit

Permalink
ChildLayoutControl: Use units defined in theme.json (WordPress#67784)
Browse files Browse the repository at this point in the history
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: tellthemachines <[email protected]>
Co-authored-by: jhmonroe <[email protected]>
  • Loading branch information
4 people authored Dec 11, 2024
1 parent 849ee8d commit ed4c2d3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/block-editor/src/components/child-layout-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
__experimentalHStack as HStack,
__experimentalVStack as VStack,
__experimentalToolsPanelItem as ToolsPanelItem,
__experimentalUseCustomUnits as useCustomUnits,
Flex,
FlexItem,
} from '@wordpress/components';
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -167,6 +180,7 @@ function FlexControls( {
{ selfStretch === 'fixed' && (
<UnitControl
size="__unstable-large"
units={ units }
onChange={ ( value ) => {
onChange( {
selfStretch,
Expand Down

0 comments on commit ed4c2d3

Please sign in to comment.