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

[pull] trunk from WordPress:trunk #79

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

### Deprecations

- `SelectControl`: Deprecate 36px default size ([#66898](https://github.com/WordPress/gutenberg/pull/66898)).
- `InputControl`: Deprecate 36px default size ([#66897](https://github.com/WordPress/gutenberg/pull/66897)).

## 29.0.0 (2024-12-11)

### Breaking Changes
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/dimension-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export function DimensionControl( props: DimensionControlProps ) {
<ContextSystemProvider value={ CONTEXT_VALUE }>
<SelectControl
__next40pxDefaultSize={ __next40pxDefaultSize }
__shouldNotWarnDeprecated36pxSize
__nextHasNoMarginBottom={ __nextHasNoMarginBottom }
className={ clsx(
className,
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/disabled/stories/index.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const Form = () => {
/>
<SelectControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label="Select Control"
onChange={ () => {} }
options={ [
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/input-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const Example = () => {

return (
<InputControl
__next40pxDefaultSize
value={ value }
onChange={ ( nextValue ) => setValue( nextValue ?? '' ) }
/>
Expand Down
10 changes: 10 additions & 0 deletions packages/components/src/input-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { space } from '../utils/space';
import { useDraft } from './utils';
import BaseControl from '../base-control';
import { useDeprecated36pxDefaultSizeProp } from '../utils/use-deprecated-props';
import { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';

const noop = () => {};

Expand All @@ -36,6 +37,7 @@ export function UnforwardedInputControl(
) {
const {
__next40pxDefaultSize,
__shouldNotWarnDeprecated36pxSize,
__unstableStateReducer: stateReducer = ( state ) => state,
__unstableInputWidth,
className,
Expand Down Expand Up @@ -68,6 +70,13 @@ export function UnforwardedInputControl(

const helpProp = !! help ? { 'aria-describedby': `${ id }__help` } : {};

maybeWarnDeprecated36pxSize( {
componentName: 'InputControl',
__next40pxDefaultSize,
size,
__shouldNotWarnDeprecated36pxSize,
} );

return (
<BaseControl
className={ classes }
Expand Down Expand Up @@ -125,6 +134,7 @@ export function UnforwardedInputControl(
*
* return (
* <InputControl
* __next40pxDefaultSize
* value={ value }
* onChange={ ( nextValue ) => setValue( nextValue ?? '' ) }
* />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const Default = Template.bind( {} );
Default.args = {
label: 'Value',
placeholder: 'Placeholder',
__next40pxDefaultSize: true,
};

export const WithHelpText = Template.bind( {} );
Expand Down Expand Up @@ -117,7 +118,6 @@ export const ShowPassword: StoryFn< typeof InputControl > = ( args ) => {
return (
<InputControl
type={ visible ? 'text' : 'password' }
label="Password"
suffix={
<InputControlSuffixWrapper variant="control">
<Button
Expand All @@ -132,3 +132,8 @@ export const ShowPassword: StoryFn< typeof InputControl > = ( args ) => {
/>
);
};
ShowPassword.args = {
...Default.args,
label: 'Password',
placeholder: undefined,
};
12 changes: 9 additions & 3 deletions packages/components/src/input-control/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ import BaseInputControl from '../';
const getInput = () => screen.getByTestId( 'input' );

describe( 'InputControl', () => {
const InputControl = ( props ) => (
<BaseInputControl { ...props } data-testid="input" />
);
const InputControl = ( props ) => {
return (
<BaseInputControl
{ ...props }
__next40pxDefaultSize
data-testid="input"
/>
);
};

describe( 'Basic rendering', () => {
it( 'should render', () => {
Expand Down
7 changes: 7 additions & 0 deletions packages/components/src/input-control/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ interface BaseProps {
* @default false
*/
__next40pxDefaultSize?: boolean;
/**
* Do not throw a warning for the deprecated 36px default size.
* For internal components of other components that already throw the warning.
*
* @ignore
*/
__shouldNotWarnDeprecated36pxSize?: boolean;
__unstableInputWidth?: CSSProperties[ 'width' ];
/**
* If true, the label will only be visible to screen readers.
Expand Down
5 changes: 4 additions & 1 deletion packages/components/src/modal/stories/index.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ const Template: StoryFn< typeof Modal > = ( { onRequestClose, ...args } ) => {
anim id est laborum.
</p>

<InputControl style={ { marginBottom: '20px' } } />
<InputControl
__next40pxDefaultSize
style={ { marginBottom: '20px' } }
/>

<Button variant="secondary" onClick={ closeModal }>
Close Modal
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/number-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ function UnforwardedNumberControl(
return stateReducerProp?.( baseState, action ) ?? baseState;
} }
size={ size }
__shouldNotWarnDeprecated36pxSize
suffix={
spinControls === 'custom' ? (
<>
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/palette-edit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const DEFAULT_COLOR = '#000';
function NameInput( { value, onChange, label }: NameInputProps ) {
return (
<NameInputControl
size="compact"
label={ label }
hideLabelFromVision
value={ value }
Expand Down
6 changes: 3 additions & 3 deletions packages/components/src/panel/stories/index.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ _PanelRow.args = {
children: (
<PanelBody title="My Profile">
<PanelRow>
<InputControl label="First name" />
<InputControl label="Last name" />
<InputControl label="First name" __next40pxDefaultSize />
<InputControl label="Last name" __next40pxDefaultSize />
</PanelRow>
<PanelRow>
<div style={ { flex: 1 } }>
<InputControl label="Email" />
<InputControl label="Email" __next40pxDefaultSize />
</div>
</PanelRow>
</PanelBody>
Expand Down
3 changes: 3 additions & 0 deletions packages/components/src/select-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const MySelectControl = () => {
{ label: 'Small', value: '25%' },
] }
onChange={ ( newSize ) => setSize( newSize ) }
__next40pxDefaultSize
__nextHasNoMarginBottom
/>
);
Expand All @@ -114,6 +115,7 @@ Render a user interface to select multiple users from a list.
{ value: 'b', label: 'User B' },
{ value: 'c', label: 'User c' },
] }
__next40pxDefaultSize
__nextHasNoMarginBottom
/>
```
Expand All @@ -129,6 +131,7 @@ const [ item, setItem ] = useState( '' );
label={ __( 'My dinosaur' ) }
value={ item } // e.g: value = 'a'
onChange={ ( selection ) => { setItem( selection ) } }
__next40pxDefaultSize
__nextHasNoMarginBottom
>
<optgroup label="Theropods">
Expand Down
10 changes: 10 additions & 0 deletions packages/components/src/select-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type { WordPressComponentProps } from '../context';
import type { SelectControlProps } from './types';
import SelectControlChevronDown from './chevron-down';
import { useDeprecated36pxDefaultSizeProp } from '../utils/use-deprecated-props';
import { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';

function useUniqueId( idProp?: string ) {
const instanceId = useInstanceId( SelectControl );
Expand Down Expand Up @@ -65,6 +66,7 @@ function UnforwardedSelectControl< V extends string >(
variant = 'default',
__next40pxDefaultSize = false,
__nextHasNoMarginBottom = false,
__shouldNotWarnDeprecated36pxSize,
...restProps
} = useDeprecated36pxDefaultSizeProp( props );
const id = useUniqueId( idProp );
Expand Down Expand Up @@ -94,6 +96,13 @@ function UnforwardedSelectControl< V extends string >(

const classes = clsx( 'components-select-control', className );

maybeWarnDeprecated36pxSize( {
componentName: 'SelectControl',
__next40pxDefaultSize,
size,
__shouldNotWarnDeprecated36pxSize,
} );

return (
<BaseControl
help={ help }
Expand Down Expand Up @@ -154,6 +163,7 @@ function UnforwardedSelectControl< V extends string >(
*
* return (
* <SelectControl
* __next40pxDefaultSize
* __nextHasNoMarginBottom
* label="Size"
* value={ size }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const SelectControlWithState: StoryFn< typeof SelectControl > = ( props ) => {

export const Default = SelectControlWithState.bind( {} );
Default.args = {
__next40pxDefaultSize: true,
__nextHasNoMarginBottom: true,
label: 'Label',
options: [
Expand All @@ -87,6 +88,7 @@ WithLabelAndHelpText.args = {
*/
export const WithCustomChildren = SelectControlWithState.bind( {} );
WithCustomChildren.args = {
__next40pxDefaultSize: true,
__nextHasNoMarginBottom: true,
label: 'Label',
children: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ import _SelectControl from '..';
const SelectControl = (
props: React.ComponentProps< typeof _SelectControl >
) => {
return <_SelectControl { ...props } __nextHasNoMarginBottom />;
return (
<_SelectControl
{ ...props }
__nextHasNoMarginBottom
__next40pxDefaultSize
/>
);
};

describe( 'SelectControl', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/select-control/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type SelectControlBaseProps< V extends string > = Pick<
InputBaseProps,
| '__next36pxDefaultSize'
| '__next40pxDefaultSize'
| '__shouldNotWarnDeprecated36pxSize'
| 'disabled'
| 'hideLabelFromVision'
| 'label'
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/tree-grid/stories/index.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ const Rows = ( {
label="Description"
hideLabelFromVision
placeholder="Description"
__next40pxDefaultSize
{ ...props }
/>
) }
Expand All @@ -121,6 +122,7 @@ const Rows = ( {
label="Notes"
hideLabelFromVision
placeholder="Notes"
__next40pxDefaultSize
{ ...props }
/>
) }
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/tree-select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export function TreeSelect( props: TreeSelectProps ) {
return (
<ContextSystemProvider value={ CONTEXT_VALUE }>
<SelectControl
__shouldNotWarnDeprecated36pxSize
{ ...{ label, options, onChange } }
value={ selectedId }
{ ...restProps }
Expand Down
Loading