Skip to content

Commit

Permalink
ChildLayoutControl: Use units defined in theme.json
Browse files Browse the repository at this point in the history
  • Loading branch information
t-hamano committed Dec 10, 2024
1 parent 244c145 commit c3d19a1
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 c3d19a1

Please sign in to comment.