Skip to content

Commit

Permalink
Try icons in input prefix.
Browse files Browse the repository at this point in the history
  • Loading branch information
afercia committed Aug 30, 2024
1 parent 0c6651a commit 6eab042
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import {
__experimentalBoxControl as BoxControl,
__experimentalUnitControl as UnitControl,
__experimentalUseCustomUnits as useCustomUnits,
__experimentalInputControlPrefixWrapper as InputControlPrefixWrapper,
} from '@wordpress/components';
import { Icon, alignNone, stretchWide } from '@wordpress/icons';
import { useCallback, useState, Platform } from '@wordpress/element';

/**
Expand Down Expand Up @@ -474,12 +476,16 @@ export default function DimensionsPanel( {
__next40pxDefaultSize
label={ __( 'Content width' ) }
labelPosition="top"
__unstableInputWidth="112px"
value={ contentSizeValue || '' }
onChange={ ( nextContentSize ) => {
setContentSizeValue( nextContentSize );
} }
units={ units }
prefix={
<InputControlPrefixWrapper variant="icon">
<Icon icon={ alignNone } />
</InputControlPrefixWrapper>
}
/>
</ToolsPanelItem>
) }
Expand All @@ -497,12 +503,16 @@ export default function DimensionsPanel( {
__next40pxDefaultSize
label={ __( 'Wide width' ) }
labelPosition="top"
__unstableInputWidth="112px"
value={ wideSizeValue || '' }
onChange={ ( nextWideSize ) => {
setWideSizeValue( nextWideSize );
} }
units={ units }
prefix={
<InputControlPrefixWrapper variant="icon">
<Icon icon={ stretchWide } />
</InputControlPrefixWrapper>
}
/>
</ToolsPanelItem>
) }
Expand Down
22 changes: 19 additions & 3 deletions packages/block-editor/src/layouts/constrained.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ import {
__experimentalUnitControl as UnitControl,
__experimentalToggleGroupControl as ToggleGroupControl,
__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,
__experimentalInputControlPrefixWrapper as InputControlPrefixWrapper,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { justifyLeft, justifyCenter, justifyRight } from '@wordpress/icons';
import {
Icon,
alignNone,
stretchWide,
justifyLeft,
justifyCenter,
justifyRight,
} from '@wordpress/icons';
import { getCSSRules } from '@wordpress/style-engine';

/**
Expand Down Expand Up @@ -71,7 +79,6 @@ export default {
className="block-editor-hooks__layout-controls-unit-input"
label={ __( 'Content width' ) }
labelPosition="top"
__unstableInputWidth="112px"
value={ contentSize || wideSize || '' }
onChange={ ( nextWidth ) => {
nextWidth =
Expand All @@ -84,6 +91,11 @@ export default {
} );
} }
units={ units }
prefix={
<InputControlPrefixWrapper variant="icon">
<Icon icon={ alignNone } />
</InputControlPrefixWrapper>
}
/>
</div>
<div className="block-editor-hooks__layout-controls-unit">
Expand All @@ -92,7 +104,6 @@ export default {
className="block-editor-hooks__layout-controls-unit-input"
label={ __( 'Wide width' ) }
labelPosition="top"
__unstableInputWidth="112px"
value={ wideSize || contentSize || '' }
onChange={ ( nextWidth ) => {
nextWidth =
Expand All @@ -105,6 +116,11 @@ export default {
} );
} }
units={ units }
prefix={
<InputControlPrefixWrapper variant="icon">
<Icon icon={ stretchWide } />
</InputControlPrefixWrapper>
}
/>
</div>
<p className="block-editor-hooks__layout-controls-helptext">
Expand Down

0 comments on commit 6eab042

Please sign in to comment.