Skip to content

Commit

Permalink
UnitControl: Add flag for larger default size (#40627)
Browse files Browse the repository at this point in the history
* Add prop to types

* Simplify paddingRight override logic

* Add changelog
  • Loading branch information
mirka authored Apr 28, 2022
1 parent 4a95a27 commit 04d733d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Enhancements

- `InputControl`: Add `__next36pxDefaultSize` flag for larger default size ([#40622](https://github.com/WordPress/gutenberg/pull/40622)).
- `UnitControl`: Add `__next36pxDefaultSize` flag for larger default size ([#40627](https://github.com/WordPress/gutenberg/pull/40627)).

## 19.9.0 (2022-04-21)

Expand Down
16 changes: 3 additions & 13 deletions packages/components/src/unit-control/styles/unit-control-styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,11 @@ export const Root = styled.div`
position: relative;
`;

const paddingStyles = ( { disableUnits, size }: InputProps ) => {
const paddings = {
default: {
paddingRight: 8,
},
small: {
paddingRight: 8,
},
'__unstable-large': {
paddingRight: disableUnits ? 16 : 8,
},
};
const paddingStyles = ( { disableUnits }: InputProps ) => {
if ( disableUnits ) return '';

return css`
${ rtl( paddings[ size ] )() };
${ rtl( { paddingRight: 8 } )() };
`;
};

Expand Down
5 changes: 4 additions & 1 deletion packages/components/src/unit-control/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ export type UnitSelectControlProps = {

// TODO: when available, should (partially) extend `NumberControl` props.
export type UnitControlProps = Omit< UnitSelectControlProps, 'unit' > &
Pick< InputControlProps, 'hideLabelFromVision' > & {
Pick<
InputControlProps,
'hideLabelFromVision' | '__next36pxDefaultSize'
> & {
__unstableStateReducer?: StateReducer;
__unstableInputWidth?: CSSProperties[ 'width' ];
/**
Expand Down

0 comments on commit 04d733d

Please sign in to comment.