Skip to content

Commit

Permalink
ChildLayoutControl: Use units defined in theme.json (#67784)
Browse files Browse the repository at this point in the history
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: tellthemachines <isabel_brison@git.wordpress.org>
Co-authored-by: jhmonroe <jhmonroe@git.wordpress.org>
  • 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

1 comment on commit ed4c2d3

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in ed4c2d3.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12272177607
📝 Reported issues:

Please sign in to comment.