Skip to content

Commit

Permalink
Move to prefix slot in Dimensions Panel
Browse files Browse the repository at this point in the history
  • Loading branch information
mirka committed Aug 15, 2024
1 parent 20d4901 commit 2b3e3a1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ import {
__experimentalToolsPanel as ToolsPanel,
__experimentalToolsPanelItem as ToolsPanelItem,
__experimentalBoxControl as BoxControl,
__experimentalHStack as HStack,
__experimentalUnitControl as UnitControl,
__experimentalUseCustomUnits as useCustomUnits,
__experimentalView as View,
Flex,
} from '@wordpress/components';
import { Icon, positionCenter, stretchWide } from '@wordpress/icons';
import { useCallback, useState, Platform } from '@wordpress/element';
Expand Down Expand Up @@ -474,23 +473,21 @@ export default function DimensionsPanel( {
}
panelId={ panelId }
>
<HStack alignment="flex-end" justify="flex-start">
<UnitControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
label={ __( 'Content' ) }
labelPosition="top"
__unstableInputWidth="80px"
value={ contentSizeValue || '' }
onChange={ ( nextContentSize ) => {
setContentSizeValue( nextContentSize );
} }
units={ units }
/>
<View>
<Icon icon={ positionCenter } />
</View>
</HStack>
<UnitControl
__next40pxDefaultSize
label={ __( 'Content' ) }
labelPosition="top"
value={ contentSizeValue || '' }
onChange={ ( nextContentSize ) => {
setContentSizeValue( nextContentSize );
} }
units={ units }
prefix={
<Flex className="block-editor-global-styles__dimensions-panel-input-prefix-wrapper">
<Icon icon={ positionCenter } />
</Flex>
}
/>
</ToolsPanelItem>
) }
{ showWideSizeControl && (
Expand All @@ -504,23 +501,21 @@ export default function DimensionsPanel( {
}
panelId={ panelId }
>
<HStack alignment="flex-end" justify="flex-start">
<UnitControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
label={ __( 'Wide' ) }
labelPosition="top"
__unstableInputWidth="80px"
value={ wideSizeValue || '' }
onChange={ ( nextWideSize ) => {
setWideSizeValue( nextWideSize );
} }
units={ units }
/>
<View>
<Icon icon={ stretchWide } />
</View>
</HStack>
<UnitControl
__next40pxDefaultSize
label={ __( 'Wide' ) }
labelPosition="top"
value={ wideSizeValue || '' }
onChange={ ( nextWideSize ) => {
setWideSizeValue( nextWideSize );
} }
units={ units }
prefix={
<Flex className="block-editor-global-styles__dimensions-panel-input-prefix-wrapper">
<Icon icon={ stretchWide } />
</Flex>
}
/>
</ToolsPanelItem>
) }
{ showPaddingControl && (
Expand Down
4 changes: 4 additions & 0 deletions packages/block-editor/src/components/global-styles/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,7 @@
margin-left: $grid-unit-30 - $grid-unit-10;
}
}

.block-editor-global-styles__dimensions-panel-input-prefix-wrapper {
margin-inline-start: $grid-unit-10;
}

0 comments on commit 2b3e3a1

Please sign in to comment.