Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextControl: Deprecate 36px default size #66745

Merged
merged 6 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

- `BorderBoxControl`: Deprecate 36px default size ([#65752](https://github.com/WordPress/gutenberg/pull/65752)).
- `BorderControl`: Deprecate 36px default size ([#65755](https://github.com/WordPress/gutenberg/pull/65755)).
- `TextControl`: Deprecate 36px default size ([#66745](https://github.com/WordPress/gutenberg/pull/66745).

### Bug Fixes

Expand Down
1 change: 1 addition & 0 deletions packages/components/src/text-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const MyTextControl = () => {
return (
<TextControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label="Additional CSS Class"
value={ className }
onChange={ ( value ) => setClassName( value ) }
Expand Down
9 changes: 9 additions & 0 deletions packages/components/src/text-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { forwardRef } from '@wordpress/element';
import BaseControl from '../base-control';
import type { WordPressComponentProps } from '../context';
import type { TextControlProps } from './types';
import { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';

function UnforwardedTextControl(
props: WordPressComponentProps< TextControlProps, 'input', false >,
Expand All @@ -38,6 +39,13 @@ function UnforwardedTextControl(
const onChangeValue = ( event: ChangeEvent< HTMLInputElement > ) =>
onChange( event.target.value );

// Add Warning for deprecated 36px size.
mirka marked this conversation as resolved.
Show resolved Hide resolved
maybeWarnDeprecated36pxSize( {
componentName: 'TextControl',
size: undefined,
__next40pxDefaultSize,
} );

return (
<BaseControl
__nextHasNoMarginBottom={ __nextHasNoMarginBottom }
Expand Down Expand Up @@ -77,6 +85,7 @@ function UnforwardedTextControl(
* return (
* <TextControl
* __nextHasNoMarginBottom
* __next40pxDefaultSize
* label="Additional CSS Class"
* value={ className }
* onChange={ ( value ) => setClassName( value ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const Default: StoryFn< typeof TextControl > = DefaultTemplate.bind(
);
Default.args = {
__nextHasNoMarginBottom: true,
__next40pxDefaultSize: true,
};

export const WithLabelAndHelpText: StoryFn< typeof TextControl > =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ import { render, screen } from '@testing-library/react';
import _TextControl from '..';

const TextControl = ( props: React.ComponentProps< typeof _TextControl > ) => {
return <_TextControl { ...props } __nextHasNoMarginBottom />;
return (
<_TextControl
{ ...props }
__nextHasNoMarginBottom
__next40pxDefaultSize
/>
);
};

const noop = () => {};
Expand Down
Loading