From d3aa78008eb717f39541bedf522e1b6ec0f98c82 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Tue, 19 Sep 2023 13:01:02 +0200 Subject: [PATCH] `SearchControl`: allow for 32px compact size, introduce option to change default size to 40px (#54548) * Add __next40pxDefaultSize prop to support 40px height default size * Add size prop with default and compact options * Clean up styles * Add size prop to README * CHANGELOG --- packages/components/CHANGELOG.md | 1 + .../components/src/search-control/README.md | 7 +++++++ .../components/src/search-control/index.tsx | 11 +++++++++- .../components/src/search-control/style.scss | 21 ++++++++++++------- .../components/src/search-control/types.ts | 12 +++++++++++ 5 files changed, 44 insertions(+), 8 deletions(-) diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index 054877bef4504..93b3f52d6e491 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -13,6 +13,7 @@ - `FormTokenField`: Update styling for consistency and increased visibility ([#54402](https://github.com/WordPress/gutenberg/pull/54402)). - `CircularOptionPicker`: Add option to use previous non-listbox behaviour, for contexts where buttons are more appropriate than a list of options ([#54290](https://github.com/WordPress/gutenberg/pull/54290)). - `DuotonePicker/ColorListPicker`: Adds appropriate labels to 'Duotone Filter' color pickers ([#54468](https://github.com/WordPress/gutenberg/pull/54468)). +- `SearchControl`: support new `40px` and `32px` sizes ([#54548](https://github.com/WordPress/gutenberg/pull/54548)). - `FormTokenField`: Add `tokenizeOnBlur` prop to add any incompleteTokenValue as a new token when field loses focus ([#54445](https://github.com/WordPress/gutenberg/pull/54445)). ### Bug Fix diff --git a/packages/components/src/search-control/README.md b/packages/components/src/search-control/README.md index 6f79d6cd9efd9..31c6c21e5222a 100644 --- a/packages/components/src/search-control/README.md +++ b/packages/components/src/search-control/README.md @@ -90,6 +90,13 @@ If true, the label will not be visible, but will be read by screen readers. Defa - Type: `Boolean` - Required: No +#### `size`: `'default'` | `'compact'` + +The size of the component. + +- Required: No +- Default: `'default'` + ## Related components - To offer users more constrained options for input, use TextControl, SelectControl, RadioControl, CheckboxControl, or RangeControl. diff --git a/packages/components/src/search-control/index.tsx b/packages/components/src/search-control/index.tsx index 528ae52b26bbc..723d754ba78ea 100644 --- a/packages/components/src/search-control/index.tsx +++ b/packages/components/src/search-control/index.tsx @@ -23,6 +23,7 @@ import type { ForwardedRef } from 'react'; function UnforwardedSearchControl( { __nextHasNoMarginBottom, + __next40pxDefaultSize = false, className, onChange, onKeyDown, @@ -32,6 +33,7 @@ function UnforwardedSearchControl( hideLabelFromVision = true, help, onClose, + size = 'default', ...restProps }: WordPressComponentProps< SearchControlProps, 'input', false >, forwardedRef: ForwardedRef< HTMLInputElement > @@ -44,9 +46,11 @@ function UnforwardedSearchControl( if ( onClose ) { return (