Skip to content

Commit

Permalink
prefer __unstableInputWidth over a css override
Browse files Browse the repository at this point in the history
  • Loading branch information
chad1008 committed Jun 20, 2023
1 parent da32f2d commit 6fec45f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
4 changes: 4 additions & 0 deletions packages/components/src/range-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {

import type { RangeControlProps } from './types';
import type { WordPressComponentProps } from '../ui/context';
import { space } from '../ui/utils/space';

const noop = () => {};

Expand Down Expand Up @@ -313,6 +314,9 @@ function UnforwardedRangeControl(
? '__unstable-large'
: 'default'
}
__unstableInputWidth={
__next40pxDefaultSize ? space( 20 ) : space( 16 )
}
step={ step }
// @ts-expect-error TODO: Investigate if the `null` value is necessary
value={ inputSliderValue }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import type {
WrapperProps,
RangeControlProps,
} from '../types';
import type { NumberControlProps } from '../../number-control/types';

const rangeHeightValue = 30;
const railHeight = 4;
Expand Down Expand Up @@ -301,28 +300,12 @@ export const Tooltip = styled.span< TooltipProps >`
) }
`;

const inputNumberWidth = ( {
size = 'default',
}: {
size: Exclude< Pick< NumberControlProps, 'size' >[ 'size' ], 'small' >;
} ) => {
const sizes = {
default: space( 16 ),
'__unstable-large': space( 20 ),
};

return css`
width: ${ sizes[ size ?? 'default' ] };
`;
};

// @todo: Refactor RangeControl with latest HStack configuration
// @wordpress/components/ui/hstack.
export const InputNumber = styled( NumberControl )`
display: inline-block;
font-size: 13px;
margin-top: 0;
${ inputNumberWidth };
input[type='number']& {
${ rangeHeight };
Expand Down

0 comments on commit 6fec45f

Please sign in to comment.