Skip to content

Commit

Permalink
TextControl: Add opt-in prop for 40px default size (#55471)
Browse files Browse the repository at this point in the history
* `TextControl`: Add opt-in prop for 40px default size

* Update changelog

* Update snapshots

* Remove unnecessary additions and update snapshots

* Update default size to 32px
  • Loading branch information
brookewp committed Nov 7, 2023
1 parent 3daa76a commit 6257737
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Expand Up @@ -13,6 +13,7 @@
### Enhancements

- `ToggleGroupControl`: Add opt-in prop for 40px default size ([#55789](https://github.com/WordPress/gutenberg/pull/55789)).
- `TextControl`: Add opt-in prop for 40px default size ([#55471](https://github.com/WordPress/gutenberg/pull/55471)).

## 25.11.0 (2023-11-02)

Expand Down
6 changes: 5 additions & 1 deletion packages/components/src/text-control/index.tsx
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import type { ChangeEvent, ForwardedRef } from 'react';
import classnames from 'classnames';

/**
* WordPress dependencies
Expand All @@ -22,6 +23,7 @@ function UnforwardedTextControl(
) {
const {
__nextHasNoMarginBottom,
__next40pxDefaultSize = false,
label,
hideLabelFromVision,
value,
Expand All @@ -46,7 +48,9 @@ function UnforwardedTextControl(
className={ className }
>
<input
className="components-text-control__input"
className={ classnames( 'components-text-control__input', {
'is-next-40px-default-size': __next40pxDefaultSize,
} ) }
type={ type }
id={ id }
value={ value }
Expand Down
5 changes: 5 additions & 0 deletions packages/components/src/text-control/style.scss
Expand Up @@ -13,5 +13,10 @@
.components-text-control__input[type="month"],
.components-text-control__input[type="number"] {
width: 100%;
height: $grid-unit-40;
@include input-control;

&.is-next-40px-default-size {
height: $grid-unit-50;
}
}
6 changes: 6 additions & 0 deletions packages/components/src/text-control/types.ts
Expand Up @@ -25,4 +25,10 @@ export type TextControlProps = Pick<
* @default 'text'
*/
type?: 'email' | 'number' | 'password' | 'tel' | 'text' | 'search' | 'url';
/**
* Start opting into the larger default height that will become the default size in a future version.
*
* @default false
*/
__next40pxDefaultSize?: boolean;
};

0 comments on commit 6257737

Please sign in to comment.