Skip to content

Commit

Permalink
Changes per review
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Dec 11, 2024
1 parent a9e0c21 commit 2b412cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 1 addition & 3 deletions packages/components/src/box-control/input-control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ export default function BoxInputControl( {
! hasPresets ||
( ! hasPresetValue && ! isMixed && mergedValue !== undefined )
);
const showRangeControl = true;
const presetIndex = hasPresetValue
? getPresetIndexFromValue( mergedValue, presetKey, presets )
: undefined;
Expand Down Expand Up @@ -240,7 +239,7 @@ export default function BoxInputControl( {
</>
) }

{ hasPresets && ! showCustomValueControl && showRangeControl && (
{ hasPresets && ! showCustomValueControl && (
<FlexedRangeControl
__next40pxDefaultSize
className="spacing-sizes-control__range-control"
Expand Down Expand Up @@ -289,7 +288,6 @@ export default function BoxInputControl( {
} }
isPressed={ showCustomValueControl }
size="small"
className="spacing-sizes-control__custom-toggle"
iconSize={ 24 }
/>
) }
Expand Down
7 changes: 5 additions & 2 deletions packages/components/src/box-control/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,17 @@ export function getPresetIndexFromValue(
presetKey: string,
presets: Preset[]
) {
if ( ! isValuePreset( value, presetKey ) === undefined ) {
if ( ! isValuePreset( value, presetKey ) ) {
return undefined;
}

const match = value.match(
new RegExp( `^var:preset\\|${ presetKey }\\|(.+)$` )
);
const slug = match ? match[ 1 ] : undefined;
if ( ! match ) {
return undefined;
}
const slug = match[ 1 ];
const index = presets.findIndex( ( preset ) => {
return preset.slug === slug;
} );
Expand Down

0 comments on commit 2b412cf

Please sign in to comment.